3 require_once 'search.civix.php';
6 * Implements hook_civicrm_config().
8 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
10 function search_civicrm_config(&$config) {
11 _search_civix_civicrm_config($config);
15 * Implements hook_civicrm_xmlMenu().
17 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu
19 function search_civicrm_xmlMenu(&$files) {
20 _search_civix_civicrm_xmlMenu($files);
24 * Implements hook_civicrm_install().
26 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
28 function search_civicrm_install() {
29 _search_civix_civicrm_install();
33 * Implements hook_civicrm_postInstall().
35 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
37 function search_civicrm_postInstall() {
38 _search_civix_civicrm_postInstall();
42 * Implements hook_civicrm_uninstall().
44 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall
46 function search_civicrm_uninstall() {
47 _search_civix_civicrm_uninstall();
51 * Implements hook_civicrm_enable().
53 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
55 function search_civicrm_enable() {
56 _search_civix_civicrm_enable();
60 * Implements hook_civicrm_disable().
62 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable
64 function search_civicrm_disable() {
65 _search_civix_civicrm_disable();
69 * Implements hook_civicrm_upgrade().
71 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
73 function search_civicrm_upgrade($op, CRM_Queue_Queue
$queue = NULL) {
74 return _search_civix_civicrm_upgrade($op, $queue);
78 * Implements hook_civicrm_managed().
80 * Generate a list of entities to create/deactivate/delete when this module
81 * is installed, disabled, uninstalled.
83 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed
85 function search_civicrm_managed(&$entities) {
86 _search_civix_civicrm_managed($entities);
90 * Implements hook_civicrm_angularModules().
92 * Generate a list of Angular modules.
94 * Note: This hook only runs in CiviCRM 4.5+. It may
95 * use features only available in v4.6+.
97 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
99 function search_civicrm_angularModules(&$angularModules) {
100 _search_civix_civicrm_angularModules($angularModules);
104 * Implements hook_civicrm_alterSettingsFolders().
106 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
108 function search_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
109 _search_civix_civicrm_alterSettingsFolders($metaDataFolders);
113 * Implements hook_civicrm_entityTypes().
115 * Declare entity types provided by this module.
117 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
119 function search_civicrm_entityTypes(&$entityTypes) {
120 _search_civix_civicrm_entityTypes($entityTypes);
124 * Implements hook_civicrm_themes().
126 function search_civicrm_themes(&$themes) {
127 _search_civix_civicrm_themes($themes);
131 * Implements hook_civicrm_pre().
133 function search_civicrm_pre($op, $entity, $id, &$params) {
134 // Supply default name/label when creating new SearchDisplay
135 if ($entity === 'SearchDisplay' && $op === 'create') {
136 if (empty($params['label'])) {
137 $params['label'] = $params['name'];
139 elseif (empty($params['name'])) {
140 $params['name'] = \CRM_Utils_String
::munge($params['label']);
146 * Injects settings data to search displays embedded in afforms
148 * @param \Civi\Angular\Manager $angular
149 * @see CRM_Utils_Hook::alterAngular()
151 function search_civicrm_alterAngular($angular) {
152 $changeSet = \Civi\Angular\ChangeSet
::create('searchSettings')
153 ->alterHtml(';\\.aff\\.html$;', function($doc, $path) {
154 $displayTypes = array_column(\Civi\Search\Display
::getDisplayTypes(['name']), 'name');
157 $componentNames = 'crm-search-display-' . implode(', crm-search-display-', $displayTypes);
158 foreach (pq($componentNames, $doc) as $component) {
159 $searchName = pq($component)->attr('search-name');
160 $displayName = pq($component)->attr('display-name');
161 if ($searchName && $displayName) {
162 $display = \Civi\Api4\SearchDisplay
::get(FALSE)
163 ->addWhere('name', '=', $displayName)
164 ->addWhere('saved_search.name', '=', $searchName)
165 ->addSelect('settings', 'saved_search.api_entity', 'saved_search.api_params')
166 ->execute()->first();
168 pq($component)->attr('settings', CRM_Utils_JS
::encode($display['settings'] ??
[]));
169 pq($component)->attr('api-entity', CRM_Utils_JS
::encode($display['saved_search.api_entity']));
170 pq($component)->attr('api-params', CRM_Utils_JS
::encode($display['saved_search.api_params']));
176 $angular->add($changeSet);