mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-22 21:30:54 +01:00
Remove category from contacts when category is deleted
This commit is contained in:
parent
9578edb5ca
commit
0f222126c3
@ -1459,6 +1459,38 @@ class addressbook_bo extends addressbook_so
|
||||
parent::deleteaccount($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by delete_category hook, when a category gets deleted.
|
||||
* Removes the category from addresses
|
||||
*/
|
||||
function delete_category($data)
|
||||
{
|
||||
// get all cats if you want to drop sub cats
|
||||
$drop_subs = ($data['drop_subs'] && !$data['modify_subs']);
|
||||
if($drop_subs)
|
||||
{
|
||||
$cats = new categories('', 'addressbook');
|
||||
$cat_ids = $cats->return_all_children($data['cat_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cat_ids = array($data['cat_id']);
|
||||
}
|
||||
|
||||
// Get addresses that use the category
|
||||
@set_time_limit( 0 );
|
||||
$ids = array();
|
||||
foreach($cat_ids as $cat_id)
|
||||
{
|
||||
$ids = $this->search(array('cat_id' => $cat_id), false);
|
||||
foreach($ids as &$info)
|
||||
{
|
||||
$info['cat_id'] = implode(',',array_diff(explode(',',$info['cat_id']), $cat_ids));
|
||||
$this->save($info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by edit-account hook, when an account get edited --> not longer used
|
||||
*
|
||||
|
@ -38,6 +38,7 @@ $setup_info['addressbook']['hooks']['sidebox_menu'] = 'addressbook_hooks::all_ho
|
||||
$setup_info['addressbook']['hooks']['settings'] = 'addressbook_hooks::settings';
|
||||
$setup_info['addressbook']['hooks'][] = 'home';
|
||||
$setup_info['addressbook']['hooks']['deleteaccount'] = 'addressbook.addressbook_bo.deleteaccount';
|
||||
$setup_info['addressbook']['hooks']['delete_category'] = 'addressbook.addressbook_bo.delete_category';
|
||||
$setup_info['addressbook']['hooks']['search_link'] = 'addressbook_hooks::search_link';
|
||||
$setup_info['addressbook']['hooks']['calendar_resources'] = 'addressbook_hooks::calendar_resources';
|
||||
$setup_info['addressbook']['hooks']['edit_user'] = 'addressbook_hooks::edit_user';
|
||||
|
Loading…
Reference in New Issue
Block a user