mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-02 12:54:18 +01:00
* Addressbook: deleting an account now also takes care of deleting or changing ownership of distribution lists (beside contacts as before)
r43694: fixed not working delete-account hook
This commit is contained in:
parent
79ebc92349
commit
97c1c1e75d
@ -791,20 +791,17 @@ class addressbook_so
|
|||||||
|
|
||||||
if (!$new_owner)
|
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))
|
|
||||||
|
if(method_exists($this->somain, 'get_lists'))
|
||||||
{
|
{
|
||||||
$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
|
else
|
||||||
{
|
{
|
||||||
$this->somain->change_owner($account_id,$new_owner);
|
$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__);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,8 @@ class addressbook_sql extends so_sql_cf
|
|||||||
*/
|
*/
|
||||||
var $ab2list_table = 'egw_addressbook2list';
|
var $ab2list_table = 'egw_addressbook2list';
|
||||||
|
|
||||||
|
const EXTRA_TABLE = 'egw_addressbook_extra';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -61,7 +63,7 @@ class addressbook_sql extends so_sql_cf
|
|||||||
*/
|
*/
|
||||||
function __construct(egw_db $db=null)
|
function __construct(egw_db $db=null)
|
||||||
{
|
{
|
||||||
parent::__construct('phpgwapi','egw_addressbook','egw_addressbook_extra','contact_',
|
parent::__construct('phpgwapi', 'egw_addressbook', self::EXTRA_TABLE, 'contact_',
|
||||||
$extra_key='_name',$extra_value='_value',$extra_id='_id',$db);
|
$extra_key='_name',$extra_value='_value',$extra_id='_id',$db);
|
||||||
|
|
||||||
// Get custom fields from addressbook instead of phpgwapi
|
// Get custom fields from addressbook instead of phpgwapi
|
||||||
@ -454,7 +456,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 $account_id account-id of the old owner
|
||||||
* @param int $new_owner account-id of the new owner
|
* @param int $new_owner account-id of the new owner
|
||||||
@ -463,13 +465,28 @@ class addressbook_sql extends so_sql_cf
|
|||||||
{
|
{
|
||||||
if (!$new_owner) // otherwise we would create an account (contact_owner==0)
|
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(
|
$this->db->update($this->table_name,array(
|
||||||
'contact_owner' => $new_owner,
|
'contact_owner' => $new_owner,
|
||||||
),array(
|
),array(
|
||||||
'contact_owner' => $account_id,
|
'contact_owner' => $account_id,
|
||||||
),__LINE__,__FILE__);
|
),__LINE__,__FILE__);
|
||||||
|
|
||||||
|
// cfs
|
||||||
|
$this->db->update(self::EXTRA_TABLE, array(
|
||||||
|
'contact_owner' => $new_owner
|
||||||
|
),array(
|
||||||
|
'contact_owner' => $account_id
|
||||||
|
), __LINE__, __FILE__);
|
||||||
|
|
||||||
|
// lists
|
||||||
|
$this->db->update($this->lists_table, array(
|
||||||
|
'list_owner' => $new_owner,
|
||||||
|
),array(
|
||||||
|
'list_owner' => $account_id,
|
||||||
|
),__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user