3 // AUTO-GENERATED FILE -- Civix may overwrite any changes made to this file
6 * (Delegated) Implementation of hook_civicrm_config
8 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
11 function _angularex_civix_civicrm_config(&$config = NULL) {
12 static $configured = FALSE;
18 $template =& CRM_Core_Smarty
::singleton();
20 $extRoot = dirname(__FILE__
) . DIRECTORY_SEPARATOR
;
21 $extDir = $extRoot . 'templates';
23 if (is_array($template->template_dir
)) {
24 array_unshift($template->template_dir
, $extDir);
27 $template->template_dir
= [$extDir, $template->template_dir
];
30 $include_path = $extRoot . PATH_SEPARATOR
. get_include_path();
31 set_include_path($include_path);
35 * (Delegated) Implementation of hook_civicrm_xmlMenu
37 * @param $files array(string)
38 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
40 function _angularex_civix_civicrm_xmlMenu(&$files) {
41 foreach (_angularex_civix_glob(__DIR__
. '/xml/Menu/*.xml') as $file) {
47 * Implementation of hook_civicrm_install
49 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
51 function _angularex_civix_civicrm_install() {
52 _angularex_civix_civicrm_config();
53 if ($upgrader = _angularex_civix_upgrader()) {
54 return $upgrader->onInstall();
59 * Implementation of hook_civicrm_uninstall
61 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
63 function _angularex_civix_civicrm_uninstall() {
64 _angularex_civix_civicrm_config();
65 if ($upgrader = _angularex_civix_upgrader()) {
66 return $upgrader->onUninstall();
71 * (Delegated) Implementation of hook_civicrm_enable
73 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
75 function _angularex_civix_civicrm_enable() {
76 _angularex_civix_civicrm_config();
77 if ($upgrader = _angularex_civix_upgrader()) {
78 if (is_callable([$upgrader, 'onEnable'])) {
79 return $upgrader->onEnable();
85 * (Delegated) Implementation of hook_civicrm_disable
87 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
89 function _angularex_civix_civicrm_disable() {
90 _angularex_civix_civicrm_config();
91 if ($upgrader = _angularex_civix_upgrader()) {
92 if (is_callable([$upgrader, 'onDisable'])) {
93 return $upgrader->onDisable();
99 * (Delegated) Implementation of hook_civicrm_upgrade
101 * @param $op string, the type of operation being performed; 'check' or 'enqueue'
102 * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
104 * @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
105 * for 'enqueue', returns void
107 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
109 function _angularex_civix_civicrm_upgrade($op, CRM_Queue_Queue
$queue = NULL) {
110 if ($upgrader = _angularex_civix_upgrader()) {
111 return $upgrader->onUpgrade($op, $queue);
116 * @return CRM_Angularex_Upgrader
118 function _angularex_civix_upgrader() {
119 if (!file_exists(__DIR__
. '/CRM/Angularex/Upgrader.php')) {
123 return CRM_Angularex_Upgrader_Base
::instance();
128 * Search directory tree for files which match a glob pattern
130 * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
131 * Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles()
133 * @param $dir string, base dir
134 * @param $pattern string, glob pattern, eg "*.txt"
135 * @return array(string)
137 function _angularex_civix_find_files($dir, $pattern) {
138 if (is_callable(['CRM_Utils_File', 'findFiles'])) {
139 return CRM_Utils_File
::findFiles($dir, $pattern);
144 while (!empty($todos)) {
145 $subdir = array_shift($todos);
146 foreach (_angularex_civix_glob("$subdir/$pattern") as $match) {
147 if (!is_dir($match)) {
151 if ($dh = opendir($subdir)) {
152 while (FALSE !== ($entry = readdir($dh))) {
153 $path = $subdir . DIRECTORY_SEPARATOR
. $entry;
154 if ($entry{0} == '.') {
156 elseif (is_dir($path)) {
167 * (Delegated) Implementation of hook_civicrm_managed
169 * Find any *.mgd.php files, merge their content, and return.
171 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
174 function _angularex_civix_civicrm_managed(&$entities) {
175 $mgdFiles = _angularex_civix_find_files(__DIR__
, '*.mgd.php');
176 foreach ($mgdFiles as $file) {
178 foreach ($es as $e) {
179 if (empty($e['module'])) {
180 $e['module'] = 'org.civicrm.angularex';
188 * (Delegated) Implementation of hook_civicrm_caseTypes
190 * Find any and return any files matching "xml/case/*.xml"
192 * Note: This hook only runs in CiviCRM 4.4+.
194 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
198 function _angularex_civix_civicrm_caseTypes(&$caseTypes) {
199 if (!is_dir(__DIR__
. '/xml/case')) {
203 foreach (_angularex_civix_glob(__DIR__
. '/xml/case/*.xml') as $file) {
204 $name = preg_replace('/\.xml$/', '', basename($file));
205 if ($name != CRM_Case_XMLProcessor
::mungeCaseType($name)) {
206 $errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor
::mungeCaseType($name));
207 CRM_Core_Error
::fatal($errorMessage);
208 // throw new CRM_Core_Exception($errorMessage);
210 $caseTypes[$name] = [
211 'module' => 'org.civicrm.angularex',
219 * Glob wrapper which is guaranteed to return an array.
221 * The documentation for glob() says, "On some systems it is impossible to
222 * distinguish between empty match and an error." Anecdotally, the return
223 * result for an empty match is sometimes array() and sometimes FALSE.
224 * This wrapper provides consistency.
226 * @link http://php.net/glob
227 * @param string $pattern
228 * @return array, possibly empty
230 function _angularex_civix_glob($pattern) {
231 $result = glob($pattern);
232 return is_array($result) ?
$result : [];
236 * Inserts a navigation menu item at a given place in the hierarchy
238 * $menu - menu hierarchy
239 * $path - path where insertion should happen (ie. Administer/System Settings)
240 * $item - menu you need to insert (parent/child attributes will be filled for you)
241 * $parentId - used internally to recurse in the menu structure
245 * @param null $parentId
248 function _angularex_civix_insert_navigation_menu(&$menu, $path, $item, $parentId = NULL) {
251 // If we are done going down the path, insert menu
254 $navId = CRM_Core_DAO
::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
258 'attributes' => array_merge($item, [
259 'label' => $item['name'] ??
NULL,
261 'parentID' => $parentId,
268 // Find an recurse into the next level down
270 $path = explode('/', $path);
271 $first = array_shift($path);
272 foreach ($menu as $key => &$entry) {
273 if ($entry['attributes']['name'] == $first) {
274 if (!$entry['child']) {
275 $entry['child'] = [];
277 $found = _angularex_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item, $key);
285 * (Delegated) Implementation of hook_civicrm_alterSettingsFolders
287 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
288 * @param null $metaDataFolders
290 function _angularex_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
291 static $configured = FALSE;
297 $settingsDir = __DIR__
. DIRECTORY_SEPARATOR
. 'settings';
298 if (is_dir($settingsDir) && !in_array($settingsDir, $metaDataFolders)) {
299 $metaDataFolders[] = $settingsDir;