Merge pull request #22 from Jagadees-zyxware/master
[com.zyxware.civiwci.git] / wci.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM Widget Creation Interface (WCI) Version 1.0 |
5 +--------------------------------------------------------------------+
6 | Copyright Zyxware Technologies (c) 2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM WCI. |
9 | |
10 | CiviCRM WCI is free software; you can copy, modify, and distribute |
11 | it under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007. |
13 | |
14 | CiviCRM WCI is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact Zyxware |
21 | Technologies at info[AT]zyxware[DOT]com. |
22 +--------------------------------------------------------------------+
23 */
24 require_once 'wci.civix.php';
25
26 /**
27 * Implementation of hook_civicrm_config
28 *
29 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
30 */
31 function wci_civicrm_config(&$config) {
32 _wci_civix_civicrm_config($config);
33 }
34
35 /**
36 * Implementation of hook_civicrm_xmlMenu
37 *
38 * @param $files array(string)
39 *
40 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
41 */
42 function wci_civicrm_xmlMenu(&$files) {
43 _wci_civix_civicrm_xmlMenu($files);
44 }
45
46 /**
47 * Implementation of hook_civicrm_install
48 *
49 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
50 */
51 function wci_civicrm_install() {
52 return _wci_civix_civicrm_install();
53 }
54
55 /**
56 * Implementation of hook_civicrm_uninstall
57 *
58 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
59 */
60 function wci_civicrm_uninstall() {
61 return _wci_civix_civicrm_uninstall();
62 }
63
64 /**
65 * Implementation of hook_civicrm_enable
66 *
67 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
68 */
69 function wci_civicrm_enable() {
70 return _wci_civix_civicrm_enable();
71 }
72
73 /**
74 * Implementation of hook_civicrm_disable
75 *
76 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
77 */
78 function wci_civicrm_disable() {
79 return _wci_civix_civicrm_disable();
80 }
81
82 /**
83 * Implementation of hook_civicrm_upgrade
84 *
85 * @param $op string, the type of operation being performed; 'check' or 'enqueue'
86 * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
87 *
88 * @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
89 * for 'enqueue', returns void
90 *
91 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
92 */
93 function wci_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
94 return _wci_civix_civicrm_upgrade($op, $queue);
95 }
96
97 /**
98 * Implementation of hook_civicrm_managed
99 *
100 * Generate a list of entities to create/deactivate/delete when this module
101 * is installed, disabled, uninstalled.
102 *
103 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
104 */
105 function wci_civicrm_managed(&$entities) {
106 return _wci_civix_civicrm_managed($entities);
107 }
108
109 /**
110 * Implementation of hook_civicrm_caseTypes
111 *
112 * Generate a list of case-types
113 *
114 * Note: This hook only runs in CiviCRM 4.4+.
115 *
116 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
117 */
118 function wci_civicrm_caseTypes(&$caseTypes) {
119 _wci_civix_civicrm_caseTypes($caseTypes);
120 }
121
122 /**
123 * Implementation of hook_civicrm_alterSettingsFolders
124 *
125 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
126 */
127 function wci_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
128 _wci_civix_civicrm_alterSettingsFolders($metaDataFolders);
129 }
130
131 function _getMenuKeyMax($menuArray) {
132 $max = array(max(array_keys($menuArray)));
133 foreach($menuArray as $v) {
134 if (!empty($v['child'])) {
135 $max[] = _getMenuKeyMax($v['child']);
136 }
137 }
138 return max($max);
139 }
140
141 function wci_civicrm_permission(&$permissions) {
142 $prefix = ts('CiviWCI') . ': '; // name of extension or module
143 $permissions += array(
144 'access CiviWCI Widget' => $prefix . ts('Access CiviWCI Widget'),
145 'administer CiviWCI' => $prefix . ts('Administer CiviWCI'),
146 );
147 }
148
149 function wci_civicrm_navigationMenu( &$params ) {
150
151 $maxKey = _getMenuKeyMax($params);
152 // Find the Help menu
153 $helpID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Help', 'id', 'name');
154 $params[$maxKey] = $params[$helpID];
155 // inserting WCI menu at the place of old help location
156 $params[$helpID] = array (
157 'attributes' => array (
158 'label' => ts('Widgets and Progress Bars'),
159 'name' => 'WCI',
160 'url' => null,
161 'permission' => 'access CiviReport,access CiviContribute',
162 'operator' => 'OR',
163 'separator' => 0,
164 'parentID' => 0,
165 'navID' => $maxKey,
166 'active' => 1),
167 'child' => array (
168 '1' => array (
169 'attributes' => array (
170 'label' => ts('New Widget'),
171 'name' => 'new_widget',
172 'url' => 'civicrm/wci/widget/add',
173 'permission' => 'administer CiviWCI',
174 'operator' => 'OR',
175 'separator' => 1,
176 'parentID' => $maxKey,
177 'navID' => $maxKey+1,
178 'active' => 1)),
179
180 '2' => array (
181 'attributes' => array (
182 'label' => ts('Manage Widgets'),
183 'name' => 'manage_widget',
184 'url' => 'civicrm/wci/widget?reset=1',
185 'permission' => 'administer CiviWCI',
186 'operator' => 'OR',
187 'separator' => 1,
188 'parentID' => $maxKey,
189 'navID' => $maxKey+2,
190 'active' => 1)),
191
192 '3' => array (
193 'attributes' => array (
194 'label' => ts('New Progress Bar'),
195 'name' => 'new_progress_bar',
196 'url' => 'civicrm/wci/progress-bar/add',
197 'permission' => 'administer CiviWCI',
198 'operator' => 'OR',
199 'separator' => 1,
200 'parentID' => $maxKey,
201 'navID' => $maxKey+3,
202 'active' => 1)),
203
204 '4' => array (
205 'attributes' => array (
206 'label' => ts('Manage Progress Bars'),
207 'name' => 'manage_progress_bar',
208 'url' => 'civicrm/wci/progress-bar?reset=1',
209 'permission' => 'administer CiviWCI',
210 'operator' => 'OR',
211 'separator' => 1,
212 'parentID' => $maxKey,
213 'navID' => $maxKey+4,
214 'active' => 1)),
215
216 '5' => array (
217 'attributes' => array (
218 'label' => ts('New Embed Code'),
219 'name' => 'new_embed-code',
220 'url' => 'civicrm/wci/embed-code/add',
221 'permission' => 'administer CiviWCI',
222 'operator' => 'OR',
223 'separator' => 1,
224 'parentID' => $maxKey,
225 'navID' => $maxKey+5,
226 'active' => 1)),
227
228 '6' => array (
229 'attributes' => array (
230 'label' => ts('Manage Embed Code'),
231 'name' => 'manage-emebed-code',
232 'url' => 'civicrm/wci/embed-code?reset=1',
233 'permission' => 'administer CiviWCI',
234 'operator' => 'OR',
235 'separator' => 1,
236 'parentID' => $maxKey,
237 'navID' => $maxKey+6,
238 'active' => 1)),
239
240 '7' => array (
241 'attributes' => array (
242 'label' => ts('Widget Settings'),
243 'name' => 'widget-settings',
244 'url' => 'civicrm/wci/settings?reset=1',
245 'permission' => 'administer CiviWCI',
246 'operator' => 'OR',
247 'separator' => 1,
248 'parentID' => $maxKey,
249 'navID' => $maxKey+7,
250 'active' => 1)),
251 ),
252 );
253 }