commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / tools / extensions / org.civicrm.multisite / multisite.civix.php
1 <?php
2
3 // AUTO-GENERATED FILE -- Civix may overwrite any changes made to this file
4
5 /**
6 * (Delegated) Implementation of hook_civicrm_config
7 * @param null $config
8 */
9 function _multisite_civix_civicrm_config(&$config = NULL) {
10 static $configured = FALSE;
11 if ($configured) return;
12 $configured = TRUE;
13
14 $template =& CRM_Core_Smarty::singleton();
15
16 $extRoot = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
17 $extDir = $extRoot . 'templates';
18
19 if ( is_array( $template->template_dir ) ) {
20 array_unshift( $template->template_dir, $extDir );
21 } else {
22 $template->template_dir = array( $extDir, $template->template_dir );
23 }
24
25 $include_path = $extRoot . PATH_SEPARATOR . get_include_path( );
26 set_include_path( $include_path );
27 }
28
29 /**
30 * (Delegated) Implementation of hook_civicrm_alterSettingsMetaData
31 * @param null $metaDataFolders
32 */
33 function _multisite_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
34 static $configured = FALSE;
35 if ($configured) return;
36 $configured = TRUE;
37
38 $extRoot = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
39 $extDir = $extRoot . 'settings';
40 if(!in_array($extDir, $metaDataFolders)){
41 $metaDataFolders[] = $extDir;
42 }
43 }
44
45 /**
46 * (Delegated) Implementation of hook_civicrm_xmlMenu
47 *
48 * @param $files array(string)
49 */
50 function _multisite_civix_civicrm_xmlMenu(&$files) {
51 foreach (glob(__DIR__ . '/xml/Menu/*.xml') as $file) {
52 $files[] = $file;
53 }
54 }
55
56 /**
57 * Implementation of hook_civicrm_install
58 */
59 function _multisite_civix_civicrm_install() {
60 _multisite_civix_civicrm_config();
61 civicrm_api('system', 'flush', array('version' => 3));
62 civicrm_api('settings', 'fill', array('version' => 3));
63 if ($upgrader = _multisite_civix_upgrader()) {
64 return $upgrader->onInstall();
65 }
66 }
67
68 /**
69 * Implementation of hook_civicrm_uninstall
70 */
71 function _multisite_civix_civicrm_uninstall() {
72 _multisite_civix_civicrm_config();
73 if ($upgrader = _multisite_civix_upgrader()) {
74 return $upgrader->onUninstall();
75 }
76 }
77
78 /**
79 * (Delegated) Implementation of hook_civicrm_enable
80 */
81 function _multisite_civix_civicrm_enable() {
82 _multisite_civix_civicrm_config();
83 if ($upgrader = _multisite_civix_upgrader()) {
84 if (is_callable(array($upgrader, 'onEnable'))) {
85 return $upgrader->onEnable();
86 }
87 }
88 }
89
90 /**
91 * (Delegated) Implementation of hook_civicrm_disable
92 */
93 function _multisite_civix_civicrm_disable() {
94 _multisite_civix_civicrm_config();
95 if ($upgrader = _multisite_civix_upgrader()) {
96 if (is_callable(array($upgrader, 'onDisable'))) {
97 return $upgrader->onDisable();
98 }
99 }
100 }
101
102 /**
103 * (Delegated) Implementation of hook_civicrm_upgrade
104 *
105 * @param $op string, the type of operation being performed; 'check' or 'enqueue'
106 * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
107 *
108 * @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
109 * for 'enqueue', returns void
110 */
111 function _multisite_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
112 if ($upgrader = _multisite_civix_upgrader()) {
113 return $upgrader->onUpgrade($op, $queue);
114 }
115 }
116
117 /**
118 * @return null
119 */
120 function _multisite_civix_upgrader() {
121 if (!file_exists(__DIR__.'/CRM/Multisite/Upgrader.php')) {
122 return NULL;
123 } else {
124 return CRM_Multisite_Upgrader_Base::instance();
125 }
126 }
127
128 /**
129 * Search directory tree for files which match a glob pattern
130 *
131 * @param $dir string, base dir
132 * @param $pattern string, glob pattern, eg "*.txt"
133 * @return array(string)
134 */
135 function _multisite_civix_find_files($dir, $pattern) {
136 $todos = array($dir);
137 $result = array();
138 while (!empty($todos)) {
139 $subdir = array_shift($todos);
140 foreach (glob("$subdir/$pattern") as $match) {
141 if (!is_dir($match)) {
142 $result[] = $match;
143 }
144 }
145 if ($dh = opendir($subdir)) {
146 while (FALSE !== ($entry = readdir($dh))) {
147 $path = $subdir . DIRECTORY_SEPARATOR . $entry;
148 if ($entry == '.' || $entry == '..') {
149 } elseif (is_dir($path)) {
150 $todos[] = $path;
151 }
152 }
153 closedir($dh);
154 }
155 }
156 return $result;
157 }
158
159 /**
160 * (Delegated) Implementation of hook_civicrm_managed
161 *
162 * Find any *.mgd.php files, merge their content, and return.
163 * @param $entities
164 */
165 function _multisite_civix_civicrm_managed(&$entities) {
166 $mgdFiles = _multisite_civix_find_files(__DIR__, '*.mgd.php');
167 foreach ($mgdFiles as $file) {
168 $es = include $file;
169 foreach ($es as $e) {
170 if (empty($e['module'])) {
171 $e['module'] = 'nz.co.fuzion.multisite';
172 }
173 $entities[] = $e;
174 }
175 }
176 }