From 9d208f8e3effbecf0427f855a1d0b4473016cc39 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 20 Feb 2012 13:24:03 +0100 Subject: [PATCH] ct.pl delete_contact: Fehler abgefangen. --- bin/mozilla/ct.pl | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 2eb6c242f..5a579e92a 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -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(); -- 2.20.1