Commit | Line | Data |
---|---|---|
25523059 CW |
1 | <?php |
2 | ||
fbf3a315 | 3 | require_once 'search_kit.civix.php'; |
25523059 CW |
4 | |
5 | /** | |
6 | * Implements hook_civicrm_config(). | |
7 | * | |
8 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/ | |
9 | */ | |
fbf3a315 CW |
10 | function search_kit_civicrm_config(&$config) { |
11 | _search_kit_civix_civicrm_config($config); | |
a92d81a1 | 12 | Civi::dispatcher()->addListener('hook_civicrm_alterAngular', ['\Civi\Search\AfformSearchMetadataInjector', 'preprocess'], 1000); |
25523059 CW |
13 | } |
14 | ||
15 | /** | |
16 | * Implements hook_civicrm_xmlMenu(). | |
17 | * | |
18 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu | |
19 | */ | |
fbf3a315 CW |
20 | function search_kit_civicrm_xmlMenu(&$files) { |
21 | _search_kit_civix_civicrm_xmlMenu($files); | |
25523059 CW |
22 | } |
23 | ||
25523059 CW |
24 | /** |
25 | * Implements hook_civicrm_managed(). | |
26 | * | |
27 | * Generate a list of entities to create/deactivate/delete when this module | |
28 | * is installed, disabled, uninstalled. | |
29 | * | |
30 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed | |
31 | */ | |
fbf3a315 CW |
32 | function search_kit_civicrm_managed(&$entities) { |
33 | _search_kit_civix_civicrm_managed($entities); | |
25523059 CW |
34 | } |
35 | ||
36 | /** | |
37 | * Implements hook_civicrm_angularModules(). | |
38 | * | |
39 | * Generate a list of Angular modules. | |
40 | * | |
41 | * Note: This hook only runs in CiviCRM 4.5+. It may | |
42 | * use features only available in v4.6+. | |
43 | * | |
44 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules | |
45 | */ | |
fbf3a315 CW |
46 | function search_kit_civicrm_angularModules(&$angularModules) { |
47 | _search_kit_civix_civicrm_angularModules($angularModules); | |
14564ba5 CW |
48 | // Fetch all search tasks provided by extensions and add their Angular modules as crmSearchTasks dependencies |
49 | $tasks = []; | |
1e313889 | 50 | $null = NULL; |
14564ba5 CW |
51 | $checkPermissions = FALSE; |
52 | \CRM_Utils_Hook::singleton()->invoke(['tasks', 'checkPermissions', 'userId'], | |
53 | $tasks, $checkPermissions, $null, | |
54 | $null, $null, $null, 'civicrm_searchKitTasks' | |
1e313889 CW |
55 | ); |
56 | foreach ($tasks as $entityTasks) { | |
57 | foreach ($entityTasks as $task) { | |
58 | if (isset($task['module']) && $task['module'] !== 'crmSearchTasks' && | |
59 | !in_array($task['module'], $angularModules['crmSearchTasks']['requires'], TRUE) | |
60 | ) { | |
61 | $angularModules['crmSearchTasks']['requires'][] = $task['module']; | |
62 | } | |
63 | } | |
64 | } | |
25523059 CW |
65 | } |
66 | ||
67 | /** | |
68 | * Implements hook_civicrm_alterSettingsFolders(). | |
69 | * | |
70 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders | |
71 | */ | |
fbf3a315 CW |
72 | function search_kit_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) { |
73 | _search_kit_civix_civicrm_alterSettingsFolders($metaDataFolders); | |
25523059 CW |
74 | } |
75 | ||
76 | /** | |
77 | * Implements hook_civicrm_entityTypes(). | |
78 | * | |
79 | * Declare entity types provided by this module. | |
80 | * | |
81 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes | |
82 | */ | |
fbf3a315 CW |
83 | function search_kit_civicrm_entityTypes(&$entityTypes) { |
84 | _search_kit_civix_civicrm_entityTypes($entityTypes); | |
25523059 CW |
85 | } |
86 | ||
87 | /** | |
e991ce44 | 88 | * Implements hook_civicrm_themes(). |
25523059 | 89 | */ |
fbf3a315 CW |
90 | function search_kit_civicrm_themes(&$themes) { |
91 | _search_kit_civix_civicrm_themes($themes); | |
25523059 | 92 | } |
e991ce44 CW |
93 | |
94 | /** | |
95 | * Implements hook_civicrm_pre(). | |
96 | */ | |
fbf3a315 | 97 | function search_kit_civicrm_pre($op, $entity, $id, &$params) { |
e991ce44 CW |
98 | // Supply default name/label when creating new SearchDisplay |
99 | if ($entity === 'SearchDisplay' && $op === 'create') { | |
100 | if (empty($params['label'])) { | |
101 | $params['label'] = $params['name']; | |
102 | } | |
103 | elseif (empty($params['name'])) { | |
104 | $params['name'] = \CRM_Utils_String::munge($params['label']); | |
105 | } | |
106 | } | |
107 | } |