From 13439ea6ac5bf1008b573077b49b7016f43ce9b6 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 18 Sep 2006 08:15:08 +0000 Subject: [PATCH] Fixed problem reported on the developer list: editing an account under the SQL backend removes first and last name --- addressbook/inc/class.bocontacts.inc.php | 38 +++++------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/addressbook/inc/class.bocontacts.inc.php b/addressbook/inc/class.bocontacts.inc.php index 590075137e..903dda84df 100755 --- a/addressbook/inc/class.bocontacts.inc.php +++ b/addressbook/inc/class.bocontacts.inc.php @@ -752,7 +752,7 @@ class bocontacts extends socontacts } /** - * Delete contact linked to account, called by delete-account hook, when an account get deleted + * Called by delete-account hook, when an account get deleted --> deletes/moves the personal addressbook * * @param array $data */ @@ -760,42 +760,20 @@ class bocontacts extends socontacts { // delete/move personal addressbook parent::deleteaccount($data); - - // delete contact linked to account - if (($contact_id = $GLOBALS['egw']->accounts->id2name($data['account_id'],'person_id'))) - { - $this->delete($contact_id); - } } /** - * Update contact if linked account get updated, called by edit-account hook, when an account get edited + * Called by edit-account hook, when an account get edited --> not longer used + * + * This function is still there, to not give a fatal error, if the hook still exists. + * Can be removed after the next db-update, which also reloads the hooks. RalfBecker 2006/09/18 * * @param array $data */ function editaccount($data) { - //echo "bocontacts::editaccount()"; _debug_array($data); - - // check if account is linked to a contact - if (($contact_id = $GLOBALS['egw']->accounts->id2name($data['account_id'],'person_id')) && - ($contact = $this->read($contact_id))) - { - $need_update = false; - foreach(array( - 'n_family' => 'lastname', - 'n_given' => 'firstname', - 'email' => 'email', - ) as $cname => $aname) - { - if ($contact[$cname] != $data[$aname]) $need_update = true; - - $contact[$cname] = $data[$aname]; - } - if ($need_update) - { - $this->save($contact); - } - } + // just force a new registration of the addressbook hooks + include(EGW_INCLUDE_ROOT.'/addressbook/setup/setup.inc.php'); + $GLOBALS['egw']->hooks->register_hooks('addressbook',$setup_info['addressbook']['hooks']); } }