From 08e40605cc7b6fca08fa861eec037e506cd48386 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 7 Mar 2012 12:05:35 +0000 Subject: [PATCH] * Admin/Addressbook: do NOT mark accounts as deleted, as accounts do NOT know that state, always deleted them and allow to cleanup already marked as deleted accounts in addressbook --- addressbook/inc/class.addressbook_bo.inc.php | 10 +++++++--- addressbook/inc/class.addressbook_ui.inc.php | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index 0111faf213..9d91a367bc 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -746,7 +746,10 @@ class addressbook_bo extends addressbook_so if ($this->check_perms(EGW_ACL_DELETE,$c,$deny_account_delete)) { if (!($old = $this->read($id))) return false; - if ($this->delete_history != '' && $old['tid'] != addressbook_so::DELETED_TYPE) + // check if we only mark contacts as deleted, or really delete them + // already marked as deleted item and accounts are always really deleted + // we cant mark accounts as deleted, as no such thing exists for accounts! + if ($old['owner'] && $this->delete_history != '' && $old['tid'] != addressbook_so::DELETED_TYPE) { $delete = $old; $delete['tid'] = addressbook_so::DELETED_TYPE; @@ -767,10 +770,11 @@ class addressbook_bo extends addressbook_so } else { - return $ok; + break; } } - return true; + //error_log(__METHOD__.'('.array2string($contact).', deny_account_delete='.array2string($deny_account_delete).', check_etag='.array2string($check_etag).' returning '.array2string($ok)); + return $ok; } /** diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index f7109abfda..415a05b5fa 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -948,9 +948,11 @@ class addressbook_ui extends addressbook_bo $action_msg = lang('deleted'); if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact))) { - if ($contact['owner']) // regular contact + if ($contact['owner'] || // regular contact or + // already deleted account (should no longer happen, but needed to allow for cleanup) + $contact['tid'] == addressbook_so::DELETED_TYPE) { - $Ok = $this->delete($id); + $Ok = $this->delete($id, $contact['tid'] != addressbook_so::DELETED_TYPE); } // delete single account --> redirect to admin elseif (count($checked) == 1 && $contact['account_id'])