ct.pl delete_contact: Fehler abgefangen.
authorSven Schöling <s.schoeling@linet-services.de>
Mon, 20 Feb 2012 12:24:03 +0000 (13:24 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Mon, 20 Feb 2012 12:24:03 +0000 (13:24 +0100)
bin/mozilla/ct.pl

index 2eb6c24..5a579e9 100644 (file)
@@ -734,18 +734,23 @@ sub delete_contact {
   $::lxdebug->enter_sub;
   $::auth->assert('customer_vendor_edit');
 
-  CT->get_contact(\%::myconfig, $::form);
+  if (!$::form->{cp_id}) {
+    flash('error', $::locale->text('No contact selected to delete'));
+  } else {
 
-  my $contact = SL::DB::Manager::Contact->find_by(cp_id => $::form->{cp_id});
+    CT->get_contact(\%::myconfig, $::form);
 
-  if ($contact->used) {
-    $contact->detach;
-    flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
-  } else {
-    $contact->delete;
-    flash('info', $::locale->text('Contact deleted.'));
+    my $contact = SL::DB::Manager::Contact->find_by(cp_id => $::form->{cp_id});
+
+    if ($contact->used) {
+      $contact->detach;
+      flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
+    } else {
+      $contact->delete;
+      flash('info', $::locale->text('Contact deleted.'));
+    }
+    delete $::form->{$_} for grep /^cp_/, keys %$::form;
   }
-  delete $::form->{$_} for grep /^cp_/, keys %$::form;
 
   edit();