forked from extern/egroupware
Remove category from contacts when category is deleted
This commit is contained in:
parent
6a9d8f1b3b
commit
efc61a3243
@ -1504,6 +1504,15 @@ 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)
|
||||
{
|
||||
parent::delete_category($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by edit-account hook, when an account get edited --> not longer used
|
||||
*
|
||||
|
@ -778,6 +778,20 @@ class addressbook_so
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove deleted category from addresses
|
||||
*/
|
||||
function delete_category($data)
|
||||
{
|
||||
// Get addresses that use the category
|
||||
$ids = $this->search(array('cat_id' => $data['cat_id']), array('contact_id', 'cat_id'));
|
||||
foreach($ids as &$info)
|
||||
{
|
||||
$info['cat_id'] = implode(',',array_diff(explode(',',$info['cat_id']), array($data['cat_id'])));
|
||||
$this->save($info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return the backend, to be used for the given $contact_id
|
||||
*
|
||||
|
@ -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