From e297cc3fa1933f4c01f1d25fe1c5e624cb60cb77 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 7 Mar 2012 12:06:20 +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 2fef671243..997387566e 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -725,7 +725,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; @@ -745,10 +748,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 71309a9b2e..937fa78c4b 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -691,9 +691,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'])