tools - add missing comment blocks
[civicrm-core.git] / tools / extensions / org.civicrm.sms.clickatell / clickatell.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 */
8 function _clickatell_civix_civicrm_config(&$config = NULL) {
9 static $configured = FALSE;
10 if ($configured) return;
11 $configured = TRUE;
12
13 $template =& CRM_Core_Smarty::singleton();
14
15 $extRoot = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
16 $extDir = $extRoot . 'templates';
17
18 if ( is_array( $template->template_dir ) ) {
19 array_unshift( $template->template_dir, $extDir );
20 } else {
21 $template->template_dir = array( $extDir, $template->template_dir );
22 }
23
24 $include_path = $extRoot . PATH_SEPARATOR . get_include_path( );
25 set_include_path( $include_path );
26 }
27
28 /**
29 * (Delegated) Implementation of hook_civicrm_xmlMenu
30 *
31 * @param $files array(string)
32 */
33 function _clickatell_civix_civicrm_xmlMenu(&$files) {
34 foreach (glob(__DIR__ . '/xml/Menu/*.xml') as $file) {
35 $files[] = $file;
36 }
37 }
38
39 /**
40 * Implementation of hook_civicrm_install
41 */
42 function _clickatell_civix_civicrm_install() {
43 _clickatell_civix_civicrm_config();
44 if ($upgrader = _clickatell_civix_upgrader()) {
45 return $upgrader->onInstall();
46 }
47 }
48
49 /**
50 * Implementation of hook_civicrm_uninstall
51 */
52 function _clickatell_civix_civicrm_uninstall() {
53 _clickatell_civix_civicrm_config();
54 if ($upgrader = _clickatell_civix_upgrader()) {
55 return $upgrader->onUninstall();
56 }
57 }
58
59 /**
60 * (Delegated) Implementation of hook_civicrm_enable
61 */
62 function _clickatell_civix_civicrm_enable() {
63 _clickatell_civix_civicrm_config();
64 if ($upgrader = _clickatell_civix_upgrader()) {
65 if (is_callable(array($upgrader, 'onEnable'))) {
66 return $upgrader->onEnable();
67 }
68 }
69 }
70
71 /**
72 * (Delegated) Implementation of hook_civicrm_disable
73 */
74 function _clickatell_civix_civicrm_disable() {
75 _clickatell_civix_civicrm_config();
76 if ($upgrader = _clickatell_civix_upgrader()) {
77 if (is_callable(array($upgrader, 'onDisable'))) {
78 return $upgrader->onDisable();
79 }
80 }
81 }
82
83 /**
84 * (Delegated) Implementation of hook_civicrm_upgrade
85 *
86 * @param $op string, the type of operation being performed; 'check' or 'enqueue'
87 * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
88 *
89 * @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
90 * for 'enqueue', returns void
91 */
92 function _clickatell_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
93 if ($upgrader = _clickatell_civix_upgrader()) {
94 return $upgrader->onUpgrade($op, $queue);
95 }
96 }
97
98 /**
99 * @return null
100 */
101 function _clickatell_civix_upgrader() {
102 if (!file_exists(__DIR__.'/CRM/Clickatell/Upgrader.php')) {
103 return NULL;
104 } else {
105 return CRM_Clickatell_Upgrader_Base::instance();
106 }
107 }
108
109 /**
110 * Search directory tree for files which match a glob pattern
111 *
112 * @param $dir string, base dir
113 * @param $pattern string, glob pattern, eg "*.txt"
114 * @return array(string)
115 */
116 function _clickatell_civix_find_files($dir, $pattern) {
117 $todos = array($dir);
118 $result = array();
119 while (!empty($todos)) {
120 $subdir = array_shift($todos);
121 foreach (glob("$subdir/$pattern") as $match) {
122 if (!is_dir($match)) {
123 $result[] = $match;
124 }
125 }
126 if ($dh = opendir($subdir)) {
127 while (FALSE !== ($entry = readdir($dh))) {
128 $path = $subdir . DIRECTORY_SEPARATOR . $entry;
129 if ($entry == '.' || $entry == '..') {
130 } elseif (is_dir($path)) {
131 $todos[] = $path;
132 }
133 }
134 closedir($dh);
135 }
136 }
137 return $result;
138 }
139 /**
140 * (Delegated) Implementation of hook_civicrm_managed
141 *
142 * Find any *.mgd.php files, merge their content, and return.
143 */
144 function _clickatell_civix_civicrm_managed(&$entities) {
145 $mgdFiles = _clickatell_civix_find_files(__DIR__, '*.mgd.php');
146 foreach ($mgdFiles as $file) {
147 $es = include $file;
148 foreach ($es as $e) {
149 if (empty($e['module'])) {
150 $e['module'] = 'org.civicrm.sms.clickatell';
151 }
152 $entities[] = $e;
153 }
154 }
155 }