Merge pull request #22 from Jagadees-zyxware/master
[com.zyxware.civiwci.git] / wci.php
CommitLineData
60488185 1<?php
bccdda02
J
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*/
60488185
M
24require_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 */
31function 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 */
42function 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 */
51function 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 */
60function 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 */
69function 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 */
78function 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 */
93function 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 */
105function 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 */
118function 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 */
127function wci_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
128 _wci_civix_civicrm_alterSettingsFolders($metaDataFolders);
129}
51fa85d7 130
d2d4567c
J
131function _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
141function 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
51fa85d7 149function wci_civicrm_navigationMenu( &$params ) {
bccdda02 150
d2d4567c 151 $maxKey = _getMenuKeyMax($params);
51fa85d7
J
152 // Find the Help menu
153 $helpID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Help', 'id', 'name');
d2d4567c 154 $params[$maxKey] = $params[$helpID];
51fa85d7
J
155 // inserting WCI menu at the place of old help location
156 $params[$helpID] = array (
cde51233 157 'attributes' => array (
09e2ab5d 158 'label' => ts('Widgets and Progress Bars'),
cde51233
J
159 'name' => 'WCI',
160 'url' => null,
161 'permission' => 'access CiviReport,access CiviContribute',
162 'operator' => 'OR',
163 'separator' => 0,
bccdda02 164 'parentID' => 0,
d2d4567c 165 'navID' => $maxKey,
cde51233
J
166 'active' => 1),
167 'child' => array (
168 '1' => array (
169 'attributes' => array (
540f6530 170 'label' => ts('New Widget'),
cde51233
J
171 'name' => 'new_widget',
172 'url' => 'civicrm/wci/widget/add',
d2d4567c 173 'permission' => 'administer CiviWCI',
cde51233
J
174 'operator' => 'OR',
175 'separator' => 1,
d2d4567c
J
176 'parentID' => $maxKey,
177 'navID' => $maxKey+1,
cde51233 178 'active' => 1)),
bccdda02 179
cde51233
J
180 '2' => array (
181 'attributes' => array (
bccdda02 182 'label' => ts('Manage Widgets'),
cde51233 183 'name' => 'manage_widget',
ca0dca6f 184 'url' => 'civicrm/wci/widget?reset=1',
d2d4567c 185 'permission' => 'administer CiviWCI',
cde51233
J
186 'operator' => 'OR',
187 'separator' => 1,
d2d4567c
J
188 'parentID' => $maxKey,
189 'navID' => $maxKey+2,
cde51233 190 'active' => 1)),
bccdda02 191
cde51233
J
192 '3' => array (
193 'attributes' => array (
540f6530 194 'label' => ts('New Progress Bar'),
cde51233
J
195 'name' => 'new_progress_bar',
196 'url' => 'civicrm/wci/progress-bar/add',
d2d4567c 197 'permission' => 'administer CiviWCI',
cde51233
J
198 'operator' => 'OR',
199 'separator' => 1,
d2d4567c
J
200 'parentID' => $maxKey,
201 'navID' => $maxKey+3,
cde51233 202 'active' => 1)),
bccdda02 203
cde51233
J
204 '4' => array (
205 'attributes' => array (
bccdda02 206 'label' => ts('Manage Progress Bars'),
cde51233 207 'name' => 'manage_progress_bar',
10119db1 208 'url' => 'civicrm/wci/progress-bar?reset=1',
d2d4567c 209 'permission' => 'administer CiviWCI',
cde51233
J
210 'operator' => 'OR',
211 'separator' => 1,
d2d4567c
J
212 'parentID' => $maxKey,
213 'navID' => $maxKey+4,
4f895956 214 'active' => 1)),
bccdda02 215
4f895956
J
216 '5' => array (
217 'attributes' => array (
13e70378
J
218 'label' => ts('New Embed Code'),
219 'name' => 'new_embed-code',
220 'url' => 'civicrm/wci/embed-code/add',
d2d4567c 221 'permission' => 'administer CiviWCI',
13e70378
J
222 'operator' => 'OR',
223 'separator' => 1,
d2d4567c
J
224 'parentID' => $maxKey,
225 'navID' => $maxKey+5,
13e70378
J
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',
d2d4567c 233 'permission' => 'administer CiviWCI',
13e70378
J
234 'operator' => 'OR',
235 'separator' => 1,
d2d4567c
J
236 'parentID' => $maxKey,
237 'navID' => $maxKey+6,
13e70378 238 'active' => 1)),
bccdda02 239
13e70378
J
240 '7' => array (
241 'attributes' => array (
68f8aff6 242 'label' => ts('Widget Settings'),
13e70378 243 'name' => 'widget-settings',
4f895956 244 'url' => 'civicrm/wci/settings?reset=1',
d2d4567c 245 'permission' => 'administer CiviWCI',
4f895956
J
246 'operator' => 'OR',
247 'separator' => 1,
d2d4567c
J
248 'parentID' => $maxKey,
249 'navID' => $maxKey+7,
4f895956 250 'active' => 1)),
cde51233 251 ),
51fa85d7
J
252 );
253}