mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-25 04:48:05 +02:00
Permit merging contacts when both have a category
This commit is contained in:
parent
d8a87d03d3
commit
d78a9ea9f0
1 changed files with 15 additions and 0 deletions
|
@ -55,3 +55,18 @@ function contactcats_civicrm_navigationMenu(&$menu) {
|
|||
]);
|
||||
_contactcats_civix_navigationMenu($menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_merge()
|
||||
*
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_merge/
|
||||
*/
|
||||
function contactcats_civicrm_merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
|
||||
if ($type === 'sqls' && $otherId) {
|
||||
// delete the 'other' contact's category; we cannot have two per contacts.
|
||||
\Civi\Api4\ContactCategory::delete(FALSE)
|
||||
->addWhere('id', '=', $otherId)
|
||||
->execute();
|
||||
Civi::log()->debug("ContactCategory: deleted category for $otherId before merge into $mainId");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue