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
10 function _memberdashboard_civix_civicrm_config(&$config = NULL) {
11 static $configured = FALSE;
12 if ($configured) return;
15 $template =& CRM_Core_Smarty
::singleton();
17 $extRoot = dirname( __FILE__
) . DIRECTORY_SEPARATOR
;
18 $extDir = $extRoot . 'templates';
20 if ( is_array( $template->template_dir
) ) {
21 array_unshift( $template->template_dir
, $extDir );
23 $template->template_dir
= array( $extDir, $template->template_dir
);
26 $include_path = $extRoot . PATH_SEPARATOR
. get_include_path( );
27 set_include_path( $include_path );
31 * (Delegated) Implementation of hook_civicrm_xmlMenu
33 * @param $files array(string)
34 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
36 function _memberdashboard_civix_civicrm_xmlMenu(&$files) {
37 foreach (_memberdashboard_civix_glob(__DIR__
. '/xml/Menu/*.xml') as $file) {
43 * Implementation of hook_civicrm_install
45 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
47 function _memberdashboard_civix_civicrm_install() {
48 _memberdashboard_civix_civicrm_config();
49 if ($upgrader = _memberdashboard_civix_upgrader()) {
50 $upgrader->onInstall();
55 * Implementation of hook_civicrm_uninstall
57 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
59 function _memberdashboard_civix_civicrm_uninstall() {
60 _memberdashboard_civix_civicrm_config();
61 if ($upgrader = _memberdashboard_civix_upgrader()) {
62 $upgrader->onUninstall();
67 * (Delegated) Implementation of hook_civicrm_enable
69 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
71 function _memberdashboard_civix_civicrm_enable() {
72 _memberdashboard_civix_civicrm_config();
73 if ($upgrader = _memberdashboard_civix_upgrader()) {
74 if (is_callable(array($upgrader, 'onEnable'))) {
75 $upgrader->onEnable();
81 * (Delegated) Implementation of hook_civicrm_disable
83 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
86 function _memberdashboard_civix_civicrm_disable() {
87 _memberdashboard_civix_civicrm_config();
88 if ($upgrader = _memberdashboard_civix_upgrader()) {
89 if (is_callable(array($upgrader, 'onDisable'))) {
90 $upgrader->onDisable();
96 * (Delegated) Implementation of hook_civicrm_upgrade
98 * @param $op string, the type of operation being performed; 'check' or 'enqueue'
99 * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
101 * @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
102 * for 'enqueue', returns void
104 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
106 function _memberdashboard_civix_civicrm_upgrade($op, CRM_Queue_Queue
$queue = NULL) {
107 if ($upgrader = _memberdashboard_civix_upgrader()) {
108 return $upgrader->onUpgrade($op, $queue);
113 * @return CRM_Memberdashboard_Upgrader
115 function _memberdashboard_civix_upgrader() {
116 if (!file_exists(__DIR__
.'/CRM/Memberdashboard/Upgrader.php')) {
119 return CRM_Memberdashboard_Upgrader_Base
::instance();
124 * Search directory tree for files which match a glob pattern
126 * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
127 * Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles()
129 * @param $dir string, base dir
130 * @param $pattern string, glob pattern, eg "*.txt"
131 * @return array(string)
133 function _memberdashboard_civix_find_files($dir, $pattern) {
134 if (is_callable(array('CRM_Utils_File', 'findFiles'))) {
135 return CRM_Utils_File
::findFiles($dir, $pattern);
138 $todos = array($dir);
140 while (!empty($todos)) {
141 $subdir = array_shift($todos);
142 foreach (_memberdashboard_civix_glob("$subdir/$pattern") as $match) {
143 if (!is_dir($match)) {
147 if ($dh = opendir($subdir)) {
148 while (FALSE !== ($entry = readdir($dh))) {
149 $path = $subdir . DIRECTORY_SEPARATOR
. $entry;
150 if ($entry{0} == '.') {
151 } elseif (is_dir($path)) {
161 * (Delegated) Implementation of hook_civicrm_managed
163 * Find any *.mgd.php files, merge their content, and return.
165 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
167 function _memberdashboard_civix_civicrm_managed(&$entities) {
168 $mgdFiles = _memberdashboard_civix_find_files(__DIR__
, '*.mgd.php');
169 foreach ($mgdFiles as $file) {
171 foreach ($es as $e) {
172 if (empty($e['module'])) {
173 $e['module'] = 'org.fsf.memberdashboard';
181 * (Delegated) Implementation of hook_civicrm_caseTypes
183 * Find any and return any files matching "xml/case/*.xml"
185 * Note: This hook only runs in CiviCRM 4.4+.
187 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
189 function _memberdashboard_civix_civicrm_caseTypes(&$caseTypes) {
190 if (!is_dir(__DIR__
. '/xml/case')) {
194 foreach (_memberdashboard_civix_glob(__DIR__
. '/xml/case/*.xml') as $file) {
195 $name = preg_replace('/\.xml$/', '', basename($file));
196 if ($name != CRM_Case_XMLProcessor
::mungeCaseType($name)) {
197 $errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor
::mungeCaseType($name));
198 CRM_Core_Error
::fatal($errorMessage);
199 // throw new CRM_Core_Exception($errorMessage);
201 $caseTypes[$name] = array(
202 'module' => 'org.fsf.memberdashboard',
210 * Glob wrapper which is guaranteed to return an array.
212 * The documentation for glob() says, "On some systems it is impossible to
213 * distinguish between empty match and an error." Anecdotally, the return
214 * result for an empty match is sometimes array() and sometimes FALSE.
215 * This wrapper provides consistency.
217 * @link http://php.net/glob
218 * @param string $pattern
219 * @return array, possibly empty
221 function _memberdashboard_civix_glob($pattern) {
222 $result = glob($pattern);
223 return is_array($result) ?
$result : array();
227 * Inserts a navigation menu item at a given place in the hierarchy
229 * $menu - menu hierarchy
230 * $path - path where insertion should happen (ie. Administer/System Settings)
231 * $item - menu you need to insert (parent/child attributes will be filled for you)
232 * $parentId - used internally to recurse in the menu structure
234 function _memberdashboard_civix_insert_navigation_menu(&$menu, $path, $item, $parentId = NULL) {
237 // If we are done going down the path, insert menu
239 if (!$navId) $navId = CRM_Core_DAO
::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
241 $menu[$navId] = array (
242 'attributes' => array_merge($item, array(
243 'label' => CRM_Utils_Array
::value('name', $item),
245 'parentID' => $parentId,
251 // Find an recurse into the next level down
253 $path = explode('/', $path);
254 $first = array_shift($path);
255 foreach ($menu as $key => &$entry) {
256 if ($entry['attributes']['name'] == $first) {
257 if (!$entry['child']) $entry['child'] = array();
258 $found = _memberdashboard_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item, $key);
266 * (Delegated) Implementation of hook_civicrm_alterSettingsFolders
268 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
270 function _memberdashboard_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
271 static $configured = FALSE;
272 if ($configured) return;
275 $settingsDir = __DIR__
. DIRECTORY_SEPARATOR
. 'settings';
276 if(is_dir($settingsDir) && !in_array($settingsDir, $metaDataFolders)) {
277 $metaDataFolders[] = $settingsDir;