From d7168805c92007bf33df8f49f1d02b14c0ce68a0 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 27 Sep 2010 16:39:54 +0000 Subject: [PATCH] When deleting but keeping contacts, hold on to links as well so they can be restored if contact is restored. --- addressbook/inc/class.addressbook_bo.inc.php | 7 +++++++ addressbook/inc/class.addressbook_ui.inc.php | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index b93309c649..8eec13613e 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -724,6 +724,7 @@ class addressbook_bo extends addressbook_so $delete = $old; $delete['tid'] = addressbook_so::DELETED_TYPE; $ok = $this->save($delete); + egw_link::unlink(0,'addressbook',$id,'','','',true); } elseif (($ok = parent::delete($id,$check_etag))) { @@ -848,6 +849,12 @@ class addressbook_bo extends addressbook_so // Notify linked apps about changes in the contact data egw_link::notify_update('addressbook', $contact['id'], $contact); + // Check for restore of deleted contact, restore held links + if($old['tid'] == addressbook_so::DELETED_TYPE && $contact['tid'] != addressbook_so::DELETED_TYPE) + { + egw_link::restore('addressbook', $contact['id']); + } + // Record change history for sql - doesn't work for LDAP accounts if(!$contact['account_id'] || $contact['account_id'] && $this->account_repository == 'sql') { $deleted = ($old['tid'] == addressbook_so::DELETED_TYPE || $contact['tid'] == addressbook_so::DELETED_TYPE); diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 772e6b2d03..7c64a8825b 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -1516,6 +1516,12 @@ class addressbook_ui extends addressbook_bo 'to_id' => $content['link_to']['to_id'], ); + // Links for deleted entries + if($content['tid'] == addressbook_so::DELETED_TYPE) + { + $content['link_to']['show_deleted'] = true; + } + // Enable history $this->setup_history($content, $sel_options); @@ -1690,6 +1696,11 @@ class addressbook_ui extends addressbook_bo 'to_app' => 'addressbook', 'to_id' => $content['id'], ); + // Links for deleted entries + if($content['tid'] == addressbook_so::DELETED_TYPE) + { + $content['link_to']['show_deleted'] = true; + } $readonlys['link_to'] = $readonlys['customfields'] = $readonlys['fileas_type'] = true; $readonlys['button[save]'] = $readonlys['button[apply]'] = $readonlys['change_photo'] = true; $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(EGW_ACL_DELETE,$content);