contactcats/contactcats.php
2025-05-06 16:40:11 +01:00

72 lines
2 KiB
PHP

<?php
require_once 'contactcats.civix.php';
use CRM_Contactcats_ExtensionUtil as E;
/**
* Implements hook_civicrm_config().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
*/
function contactcats_civicrm_config(&$config): void {
_contactcats_civix_civicrm_config($config);
}
/**
* Implements hook_civicrm_install().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
*/
function contactcats_civicrm_install(): void {
_contactcats_civix_civicrm_install();
}
/**
* Implements hook_civicrm_enable().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
*/
function contactcats_civicrm_enable(): void {
_contactcats_civix_civicrm_enable();
}
/**
* Implements hook_civicrm_navigationMenu().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu
*/
function contactcats_civicrm_navigationMenu(&$menu) {
_contactcats_civix_insert_navigation_menu($menu, 'Contacts', [
'label' => E::ts('Categories'),
'name' => 'contact_categories',
'url' => 'civicrm/admin/contactcategory',
'permission' => 'edit all contacts',
'operator' => 'OR',
'separator' => 0,
]);
_contactcats_civix_insert_navigation_menu($menu, 'Reports', [
'label' => E::ts('Contact Category Flows'),
'name' => 'contact_category_flows',
'url' => 'civicrm/reports/contact-category-flows',
'permission' => 'access CiviCRM',
'operator' => 'OR',
'separator' => 0,
]);
_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");
}
}