diff --git a/CRM/Custompermission/Upgrader/Base.php b/CRM/Custompermission/Upgrader/Base.php index 7b55bb9..38384ec 100644 --- a/CRM/Custompermission/Upgrader/Base.php +++ b/CRM/Custompermission/Upgrader/Base.php @@ -1,6 +1,7 @@ ctx = array_shift($args); $instance->queue = $instance->ctx->queue; $method = array_shift($args); - return call_user_func_array([$instance, $method], $args); } @@ -88,54 +90,54 @@ public function __construct($extensionName, $extensionDir) { /** * Run a CustomData file. * - * @param string $relativePath the CustomData XML file path (relative to this - * extension's dir) - * + * @param string $relativePath + * the CustomData XML file path (relative to this extension's dir) * @return bool - * @throws \CRM_Core_Exception */ public function executeCustomDataFile($relativePath) { $xml_file = $this->extensionDir . '/' . $relativePath; - return $this->executeCustomDataFileByAbsPath($xml_file); } /** * Run a CustomData file * - * @param string $xml_file the CustomData XML file path (absolute path) + * @param string $xml_file + * the CustomData XML file path (absolute path) * * @return bool - * @throws \CRM_Core_Exception */ - protected static function executeCustomDataFileByAbsPath($xml_file) { + protected function executeCustomDataFileByAbsPath($xml_file) { $import = new CRM_Utils_Migrate_Import(); - $import->run($xml_file); - return TRUE; } /** * Run a SQL file. * - * @param string $relativePath the SQL file path (relative to this - * extension's dir) + * @param string $relativePath + * the SQL file path (relative to this extension's dir) * * @return bool */ public function executeSqlFile($relativePath) { - CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $this->extensionDir . DIRECTORY_SEPARATOR . $relativePath); - + CRM_Utils_File::sourceSQLFile( + CIVICRM_DSN, + $this->extensionDir . DIRECTORY_SEPARATOR . $relativePath + ); return TRUE; } /** + * Run the sql commands in the specified file. + * * @param string $tplFile * The SQL file path (relative to this extension's dir). * Ex: "sql/mydata.mysql.tpl". * * @return bool + * @throws \CRM_Core_Exception */ public function executeSqlTemplate($tplFile) { // Assign multilingual variable to Smarty. @@ -143,11 +145,10 @@ public function executeSqlTemplate($tplFile) { $tplFile = CRM_Utils_File::isAbsolute($tplFile) ? $tplFile : $this->extensionDir . DIRECTORY_SEPARATOR . $tplFile; $smarty = CRM_Core_Smarty::singleton(); - $smarty->assign('domainID', CRM_Core_Config::domainID()); - - CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $smarty->fetch($tplFile), NULL, TRUE); - + CRM_Utils_File::sourceSQLFile( + CIVICRM_DSN, $smarty->fetch($tplFile), NULL, TRUE + ); return TRUE; } @@ -155,18 +156,19 @@ public function executeSqlTemplate($tplFile) { * Run one SQL query. * * This is just a wrapper for CRM_Core_DAO::executeSql, but it - * provides syntatic sugar for queueing several tasks that + * provides syntactic sugar for queueing several tasks that * run different queries + * + * @return bool */ public function executeSql($query, $params = []) { // FIXME verify that we raise an exception on error CRM_Core_DAO::executeQuery($query, $params); - return TRUE; } /** - * Syntatic sugar for enqueuing a task which calls a function in this class. + * Syntactic sugar for enqueuing a task which calls a function in this class. * * The task is weighted so that it is processed * as part of the currently-pending revision. @@ -177,12 +179,11 @@ public function executeSql($query, $params = []) { public function addTask($title) { $args = func_get_args(); $title = array_shift($args); - - $task = new CRM_Queue_Task([ - get_class($this), - '_queueAdapter', - ], $args, $title); - + $task = new CRM_Queue_Task( + [get_class($this), '_queueAdapter'], + $args, + $title + ); return $this->queue->createItem($task, ['weight' => -1]); } @@ -192,7 +193,6 @@ public function addTask($title) { * Determine if there are any pending revisions. * * @return bool - * @throws \ReflectionException */ public function hasPendingRevisions() { $revisions = $this->getRevisions(); @@ -201,7 +201,6 @@ public function hasPendingRevisions() { if (empty($revisions)) { return FALSE; } - if (empty($currentRevision)) { return TRUE; } @@ -211,33 +210,34 @@ public function hasPendingRevisions() { /** * Add any pending revisions to the queue. + * + * @param CRM_Queue_Queue $queue */ public function enqueuePendingRevisions(CRM_Queue_Queue $queue) { $this->queue = $queue; $currentRevision = $this->getCurrentRevision(); - foreach ($this->getRevisions() as $revision) { if ($revision > $currentRevision) { - $title = ts('Upgrade %1 to revision %2', [ + $title = E::ts('Upgrade %1 to revision %2', [ 1 => $this->extensionName, 2 => $revision, ]); // note: don't use addTask() because it sets weight=-1 - $task = new CRM_Queue_Task([ - get_class($this), - '_queueAdapter', - ], ['upgrade_' . $revision], $title); - + $task = new CRM_Queue_Task( + [get_class($this), '_queueAdapter'], + ['upgrade_' . $revision], + $title + ); $this->queue->createItem($task); - $task = new CRM_Queue_Task([ - get_class($this), - '_queueAdapter', - ], ['setCurrentRevision', $revision], $title); - + $task = new CRM_Queue_Task( + [get_class($this), '_queueAdapter'], + ['setCurrentRevision', $revision], + $title + ); $this->queue->createItem($task); } } @@ -246,8 +246,8 @@ public function enqueuePendingRevisions(CRM_Queue_Queue $queue) { /** * Get a list of revisions. * - * @return array(revisionNumbers) sorted numerically - * @throws \ReflectionException + * @return array + * revisionNumbers sorted numerically */ public function getRevisions() { if (!is_array($this->revisions)) { @@ -255,139 +255,105 @@ public function getRevisions() { $clazz = new ReflectionClass(get_class($this)); $methods = $clazz->getMethods(); - foreach ($methods as $method) { if (preg_match('/^upgrade_(.*)/', $method->name, $matches)) { $this->revisions[] = $matches[1]; } } - sort($this->revisions, SORT_NUMERIC); } return $this->revisions; } - /** - * @return mixed|string - */ public function getCurrentRevision() { $revision = CRM_Core_BAO_Extension::getSchemaVersion($this->extensionName); - if (!$revision) { $revision = $this->getCurrentRevisionDeprecated(); } - return $revision; } - /** - * @return mixed - */ private function getCurrentRevisionDeprecated() { $key = $this->extensionName . ':version'; - - if ($revision = CRM_Core_BAO_Setting::getItem('Extension', $key)) { + if ($revision = \Civi::settings()->get($key)) { $this->revisionStorageIsDeprecated = TRUE; } - return $revision; } - /** - * @param $revision - * - * @return bool - */ public function setCurrentRevision($revision) { CRM_Core_BAO_Extension::setSchemaVersion($this->extensionName, $revision); // clean up legacy schema version store (CRM-19252) $this->deleteDeprecatedRevision(); - return TRUE; } - /** - * deleteDeprecatedRevision - */ private function deleteDeprecatedRevision() { if ($this->revisionStorageIsDeprecated) { $setting = new CRM_Core_BAO_Setting(); $setting->name = $this->extensionName . ':version'; $setting->delete(); - - CRM_Core_Error::debug_log_message('Migrated extension schema revision ID for ' . $this->extensionName . ' from civicrm_setting (deprecated) to civicrm_extension.' . "\n"); + CRM_Core_Error::debug_log_message("Migrated extension schema revision ID for {$this->extensionName} from civicrm_setting (deprecated) to civicrm_extension.\n"); } } // ******** Hook delegates ******** /** - * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install + * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install */ public function onInstall() { $files = glob($this->extensionDir . '/sql/*_install.sql'); - if (is_array($files)) { foreach ($files as $file) { CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $file); } } - $files = glob($this->extensionDir . '/sql/*_install.mysql.tpl'); - if (is_array($files)) { foreach ($files as $file) { $this->executeSqlTemplate($file); } } - $files = glob($this->extensionDir . '/xml/*_install.xml'); - if (is_array($files)) { foreach ($files as $file) { $this->executeCustomDataFileByAbsPath($file); } } - if (is_callable([$this, 'install'])) { $this->install(); } } /** - * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_postInstall + * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall */ public function onPostInstall() { $revisions = $this->getRevisions(); - if (!empty($revisions)) { $this->setCurrentRevision(max($revisions)); } - if (is_callable([$this, 'postInstall'])) { $this->postInstall(); } } /** - * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall + * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall */ public function onUninstall() { $files = glob($this->extensionDir . '/sql/*_uninstall.mysql.tpl'); - if (is_array($files)) { foreach ($files as $file) { $this->executeSqlTemplate($file); } } - if (is_callable([$this, 'uninstall'])) { $this->uninstall(); } - $files = glob($this->extensionDir . '/sql/*_uninstall.sql'); - if (is_array($files)) { foreach ($files as $file) { CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $file); @@ -396,7 +362,7 @@ public function onUninstall() { } /** - * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable + * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable */ public function onEnable() { // stub for possible future use @@ -406,7 +372,7 @@ public function onEnable() { } /** - * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable + * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable */ public function onDisable() { // stub for possible future use @@ -415,12 +381,6 @@ public function onDisable() { } } - /** - * @param $op - * @param \CRM_Queue_Queue|NULL $queue - * - * @return array|void - */ public function onUpgrade($op, CRM_Queue_Queue $queue = NULL) { switch ($op) { case 'check': diff --git a/custompermission.civix.php b/custompermission.civix.php index 5cbe708..2fc7e47 100644 --- a/custompermission.civix.php +++ b/custompermission.civix.php @@ -7,11 +7,8 @@ * extension. */ class CRM_Custompermission_ExtensionUtil { - const SHORT_NAME = 'custompermission'; - const LONG_NAME = 'com.agiliway.custompermission'; - const CLASS_PREFIX = 'CRM_Custompermission'; /** @@ -23,7 +20,6 @@ class CRM_Custompermission_ExtensionUtil { * @param string $text * Canonical message text (generally en_US). * @param array $params - * * @return string * Translated text. * @see ts @@ -41,15 +37,13 @@ public static function ts($text, $params = []) { * @param string|NULL $file * Ex: NULL. * Ex: 'css/foo.css'. - * * @return string * Ex: 'http://example.org/sites/default/ext/org.example.foo'. * Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'. */ public static function url($file = NULL) { if ($file === NULL) { - return rtrim(CRM_Core_Resources::singleton() - ->getUrl(self::LONG_NAME), '/'); + return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/'); } return CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME, $file); } @@ -60,7 +54,6 @@ public static function url($file = NULL) { * @param string|NULL $file * Ex: NULL. * Ex: 'css/foo.css'. - * * @return string * Ex: '/var/www/example.org/sites/default/ext/org.example.foo'. * Ex: '/var/www/example.org/sites/default/ext/org.example.foo/css/foo.css'. @@ -75,7 +68,6 @@ public static function path($file = NULL) { * * @param string $suffix * Ex: 'Page_HelloWorld' or 'Page\\HelloWorld'. - * * @return string * Ex: 'CRM_Foo_Page_HelloWorld'. */ @@ -90,7 +82,7 @@ public static function findClass($suffix) { /** * (Delegated) Implements hook_civicrm_config(). * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config */ function _custompermission_civix_civicrm_config(&$config = NULL) { static $configured = FALSE; @@ -99,9 +91,9 @@ function _custompermission_civix_civicrm_config(&$config = NULL) { } $configured = TRUE; - $template =& CRM_Core_Smarty::singleton(); + $template = CRM_Core_Smarty::singleton(); - $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR; + $extRoot = __DIR__ . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; if (is_array($template->template_dir)) { @@ -113,8 +105,6 @@ function _custompermission_civix_civicrm_config(&$config = NULL) { $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); - - CRM_Core_Resources::singleton()->addStyleFile('com.agiliway.custompermission', 'css/custompermission.css', 200, 'html-header'); } /** @@ -122,7 +112,7 @@ function _custompermission_civix_civicrm_config(&$config = NULL) { * * @param $files array(string) * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu */ function _custompermission_civix_civicrm_xmlMenu(&$files) { foreach (_custompermission_civix_glob(__DIR__ . '/xml/Menu/*.xml') as $file) { @@ -133,7 +123,7 @@ function _custompermission_civix_civicrm_xmlMenu(&$files) { /** * Implements hook_civicrm_install(). * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install */ function _custompermission_civix_civicrm_install() { _custompermission_civix_civicrm_config(); @@ -145,7 +135,7 @@ function _custompermission_civix_civicrm_install() { /** * Implements hook_civicrm_postInstall(). * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_postInstall + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall */ function _custompermission_civix_civicrm_postInstall() { _custompermission_civix_civicrm_config(); @@ -159,7 +149,7 @@ function _custompermission_civix_civicrm_postInstall() { /** * Implements hook_civicrm_uninstall(). * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall */ function _custompermission_civix_civicrm_uninstall() { _custompermission_civix_civicrm_config(); @@ -171,7 +161,7 @@ function _custompermission_civix_civicrm_uninstall() { /** * (Delegated) Implements hook_civicrm_enable(). * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable */ function _custompermission_civix_civicrm_enable() { _custompermission_civix_civicrm_config(); @@ -185,7 +175,7 @@ function _custompermission_civix_civicrm_enable() { /** * (Delegated) Implements hook_civicrm_disable(). * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable * @return mixed */ function _custompermission_civix_civicrm_disable() { @@ -200,15 +190,14 @@ function _custompermission_civix_civicrm_disable() { /** * (Delegated) Implements hook_civicrm_upgrade(). * - * @param $op string, the type of operation being performed; 'check' or - * 'enqueue' - * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of - * pending up upgrade tasks + * @param $op string, the type of operation being performed; 'check' or 'enqueue' + * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks * - * @return mixed based on op. for 'check', returns array(boolean) (TRUE if - * upgrades are pending) for 'enqueue', returns void + * @return mixed + * based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending) + * for 'enqueue', returns void * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade */ function _custompermission_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { if ($upgrader = _custompermission_civix_upgrader()) { @@ -217,7 +206,7 @@ function _custompermission_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = N } /** - * @return CRM_custompermission_Upgrader + * @return CRM_Custompermission_Upgrader */ function _custompermission_civix_upgrader() { if (!file_exists(__DIR__ . '/CRM/Custompermission/Upgrader.php')) { @@ -229,43 +218,19 @@ function _custompermission_civix_upgrader() { } /** - * Search directory tree for files which match a glob pattern + * Search directory tree for files which match a glob pattern. * * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored. - * Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles() + * Note: Delegate to CRM_Utils_File::findFiles(), this function kept only + * for backward compatibility of extension code that uses it. * - * @param $dir string, base dir - * @param $pattern string, glob pattern, eg "*.txt" + * @param string $dir base dir + * @param string $pattern , glob pattern, eg "*.txt" * - * @return array(string) + * @return array */ function _custompermission_civix_find_files($dir, $pattern) { - if (is_callable(['CRM_Utils_File', 'findFiles'])) { - return CRM_Utils_File::findFiles($dir, $pattern); - } - - $todos = [$dir]; - $result = []; - while (!empty($todos)) { - $subdir = array_shift($todos); - foreach (_custompermission_civix_glob("$subdir/$pattern") as $match) { - if (!is_dir($match)) { - $result[] = $match; - } - } - if ($dh = opendir($subdir)) { - while (FALSE !== ($entry = readdir($dh))) { - $path = $subdir . DIRECTORY_SEPARATOR . $entry; - if ($entry{0} == '.') { - } - elseif (is_dir($path)) { - $todos[] = $path; - } - } - closedir($dh); - } - } - return $result; + return CRM_Utils_File::findFiles($dir, $pattern); } /** @@ -273,20 +238,21 @@ function _custompermission_civix_find_files($dir, $pattern) { * * Find any *.mgd.php files, merge their content, and return. * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed */ function _custompermission_civix_civicrm_managed(&$entities) { $mgdFiles = _custompermission_civix_find_files(__DIR__, '*.mgd.php'); + sort($mgdFiles); foreach ($mgdFiles as $file) { $es = include $file; foreach ($es as $e) { if (empty($e['module'])) { $e['module'] = E::LONG_NAME; } - $entities[] = $e; if (empty($e['params']['version'])) { $e['params']['version'] = '3'; } + $entities[] = $e; } } } @@ -298,7 +264,7 @@ function _custompermission_civix_civicrm_managed(&$entities) { * * Note: This hook only runs in CiviCRM 4.4+. * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_caseTypes */ function _custompermission_civix_civicrm_caseTypes(&$caseTypes) { if (!is_dir(__DIR__ . '/xml/case')) { @@ -308,8 +274,8 @@ function _custompermission_civix_civicrm_caseTypes(&$caseTypes) { foreach (_custompermission_civix_glob(__DIR__ . '/xml/case/*.xml') as $file) { $name = preg_replace('/\.xml$/', '', basename($file)); if ($name != CRM_Case_XMLProcessor::mungeCaseType($name)) { - $errorMessage = sprintf('Case-type file name is malformed (%s vs %s)', $name, CRM_Case_XMLProcessor::mungeCaseType($name)); - CRM_Core_Error::fatal($errorMessage); + $errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor::mungeCaseType($name)); + throw new CRM_Core_Exception($errorMessage); } $caseTypes[$name] = [ 'module' => E::LONG_NAME, @@ -326,7 +292,7 @@ function _custompermission_civix_civicrm_caseTypes(&$caseTypes) { * * Note: This hook only runs in CiviCRM 4.5+. * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules */ function _custompermission_civix_civicrm_angularModules(&$angularModules) { if (!is_dir(__DIR__ . '/ang')) { @@ -344,6 +310,25 @@ function _custompermission_civix_civicrm_angularModules(&$angularModules) { } } +/** + * (Delegated) Implements hook_civicrm_themes(). + * + * Find any and return any files matching "*.theme.php" + */ +function _custompermission_civix_civicrm_themes(&$themes) { + $files = _custompermission_civix_glob(__DIR__ . '/*.theme.php'); + foreach ($files as $file) { + $themeMeta = include $file; + if (empty($themeMeta['name'])) { + $themeMeta['name'] = preg_replace(':\.theme\.php$:', '', basename($file)); + } + if (empty($themeMeta['ext'])) { + $themeMeta['ext'] = E::LONG_NAME; + } + $themes[$themeMeta['name']] = $themeMeta; + } +} + /** * Glob wrapper which is guaranteed to return an array. * @@ -353,10 +338,9 @@ function _custompermission_civix_civicrm_angularModules(&$angularModules) { * This wrapper provides consistency. * * @link http://php.net/glob - * * @param string $pattern * - * @return array, possibly empty + * @return array */ function _custompermission_civix_glob($pattern) { $result = glob($pattern); @@ -367,18 +351,20 @@ function _custompermission_civix_glob($pattern) { * Inserts a navigation menu item at a given place in the hierarchy. * * @param array $menu - menu hierarchy - * @param string $path - path where insertion should happen (ie. - * Administer/System Settings) - * @param array $item - menu you need to insert (parent/child attributes will - * be filled for you) + * @param string $path - path to parent of this item, e.g. 'my_extension/submenu' + * 'Mailing', or 'Administer/System Settings' + * @param array $item - the item to insert (parent/child attributes will be + * filled for you) + * + * @return bool */ function _custompermission_civix_insert_navigation_menu(&$menu, $path, $item) { // If we are done going down the path, insert menu if (empty($path)) { $menu[] = [ 'attributes' => array_merge([ - 'label' => CRM_Utils_Array::value('name', $item), - 'active' => 1, + 'label' => CRM_Utils_Array::value('name', $item), + 'active' => 1, ], $item), ]; return TRUE; @@ -393,7 +379,7 @@ function _custompermission_civix_insert_navigation_menu(&$menu, $path, $item) { if (!isset($entry['child'])) { $entry['child'] = []; } - $found = _custompermission_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item, $key); + $found = _custompermission_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item); } } return $found; @@ -415,7 +401,7 @@ function _custompermission_civix_navigationMenu(&$nodes) { */ function _custompermission_civix_fixNavigationMenu(&$nodes) { $maxNavID = 1; - array_walk_recursive($nodes, function ($item, $key) use (&$maxNavID) { + array_walk_recursive($nodes, function($item, $key) use (&$maxNavID) { if ($key === 'navID') { $maxNavID = max($maxNavID, $item); } @@ -423,11 +409,6 @@ function _custompermission_civix_fixNavigationMenu(&$nodes) { _custompermission_civix_fixNavigationMenuItems($nodes, $maxNavID, NULL); } -/** - * @param $nodes - * @param $maxNavID - * @param $parentID - */ function _custompermission_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $parentID) { $origKeys = array_keys($nodes); foreach ($origKeys as $origKey) { @@ -451,17 +432,22 @@ function _custompermission_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $pa /** * (Delegated) Implements hook_civicrm_alterSettingsFolders(). * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders */ function _custompermission_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) { - static $configured = FALSE; - if ($configured) { - return; - } - $configured = TRUE; - $settingsDir = __DIR__ . DIRECTORY_SEPARATOR . 'settings'; - if (is_dir($settingsDir) && !in_array($settingsDir, $metaDataFolders)) { + if (!in_array($settingsDir, $metaDataFolders) && is_dir($settingsDir)) { $metaDataFolders[] = $settingsDir; } } + +/** + * (Delegated) Implements hook_civicrm_entityTypes(). + * + * Find any *.entityType.php files, merge their content, and return. + * + * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes + */ +function _custompermission_civix_civicrm_entityTypes(&$entityTypes) { + $entityTypes = array_merge($entityTypes, []); +}