diff --git a/addressbook/inc/class.addressbook_so.inc.php b/addressbook/inc/class.addressbook_so.inc.php index 2fe0efbbec..233a2d2824 100755 --- a/addressbook/inc/class.addressbook_so.inc.php +++ b/addressbook/inc/class.addressbook_so.inc.php @@ -791,20 +791,17 @@ class addressbook_so if (!$new_owner) { - $this->somain->delete(array('owner' => $account_id)); + $this->somain->delete(array('owner' => $account_id)); // so_sql_cf::delete() takes care of cfs too + if(!($this->somain instanceof addressbook_sql)) { - $this->soextra->delete_customfields(array($this->extra_owner => $account_id)); + $lists = $this->somain->get_lists($account_id); + $this->somain->delete_list(array_keys($lists)); } } else { $this->somain->change_owner($account_id,$new_owner); - $this->db->update($this->soextra->table_name,array( - $this->extra_owner => $new_owner - ),array( - $this->extra_owner => $account_id - ),__LINE__,__FILE__); } } diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index 76f7d0cdde..e499cd66a3 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -454,7 +454,7 @@ class addressbook_sql extends so_sql_cf } /** - * Change the ownership of contacts owned by a given account + * Change the ownership of contacts and distribution-lists owned by a given account * * @param int $account_id account-id of the old owner * @param int $new_owner account-id of the new owner @@ -463,13 +463,28 @@ class addressbook_sql extends so_sql_cf { if (!$new_owner) // otherwise we would create an account (contact_owner==0) { - die("socontacts_sql::change_owner($account_id,$new_owner) new owner must not be 0"); + throw egw_exception_wrong_parameter(__METHOD__."($account_id, $new_owner) new owner must not be 0!"); } + // contacts $this->db->update($this->table_name,array( 'contact_owner' => $new_owner, ),array( 'contact_owner' => $account_id, ),__LINE__,__FILE__); + + // cfs + $this->db->update($this->soextra->table_name,array( + $this->extra_owner => $new_owner + ),array( + $this->extra_owner => $account_id + ),__LINE__,__FILE__); + + // lists + $this->db->update($this->lists_table, array( + 'list_owner' => $new_owner, + ),array( + 'list_owner' => $account_id, + ),__LINE__,__FILE__); } /**