forked from kylejaster/CiviMobile
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcivimobile.module
211 lines (180 loc) · 7.36 KB
/
civimobile.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
// $Id$
/**
* @file
* Main file for the Design review module
*/
/**
* Implementation of hook_menu().
*/
function civimobile_menu() {
$items = array();
// CiviMobile Homepage
$items['civimobile'] = array(
'title' => 'CiviMobile',
'description' => 'A small but very effective mobile interface to your CiviCRM installation.',
'page callback' => '_civimobile_home_page',
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
// Events page listing all events
$items['civimobile/events'] = array(
'title' => 'CiviMobile',
'description' => 'A small but very effective mobile interface to your CiviCRM installation.',
'page callback' => '_civimobile_events_page',
'page arguments' => array('events'),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
// Events page listing all events
$items['civimobile/participants'] = array(
'title' => 'CiviMobile',
'description' => 'Event Participants',
'page callback' => '_civimobile_participants_page',
'page arguments' => array('events'),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
// Events page listing all events
$items['civimobile/status'] = array(
'title' => 'CiviMobile',
'description' => 'Participant Status',
'page callback' => '_civimobile_participant_status_page',
'page arguments' => array('events'),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/contact'] = array(
'title' => 'Contacts',
'page callback' => '_civimobile_page',
'page arguments' => array('contact_list',null),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/contactsearch'] = array(
'title' => 'Contacts Location Search',
'page callback' => '_civimobile_page',
'page arguments' => array('contact.search'),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/contact/%'] = array(
'title' => 'Contact',
'page callback' => '_civimobile_page',
'page arguments' => array('contact',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/contribution/%'] = array(
'title' => 'Contribution',
'page callback' => '_civimobile_page',
'page arguments' => array('contribution',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/membership/%'] = array(
'title' => 'Membership',
'page callback' => '_civimobile_page',
'page arguments' => array('membership',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/participant/%'] = array(
'title' => 'Participant',
'page callback' => '_civimobile_page',
'page arguments' => array('participant',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/activity/%'] = array(
'title' => 'Activity',
'page callback' => '_civimobile_page',
'page arguments' => array('activity',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/relationship/%'] = array(
'title' => 'Relationship',
'page callback' => '_civimobile_page',
'page arguments' => array('relationship',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/case/%'] = array(
'title' => 'Case',
'page callback' => '_civimobile_page',
'page arguments' => array('case',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/survey'] = array(
'title' => 'Case',
'page callback' => '_civimobile_page',
'page arguments' => array('survey_list',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
$items['civimobile/survey/%'] = array(
'title' => 'Case',
'page callback' => '_civimobile_page',
'page arguments' => array('survey',2),
'access arguments' => array('access CiviCRM'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function _civimobile_page($page,$param= null ) {
$civimobile_page_settings = _civimobile_vars_setup();
$additional_args = func_get_args();
// FIXME: Dirty hack to add the additional params to the get path
// ISSUE: menu item 'civimobile/contact/%' was picked up instead of 'civimobile/contact/%/activities'
if (array_key_exists(2, $additional_args)) {
if ($additional_args[2]) $page .= '.'.$additional_args[2];
}
$pagepath = drupal_get_path('module','civimobile')."/templates/civimobile.$page.tpl.php";
include_once($pagepath);
return NULL;
}
/**
* Callback for menu item civimobile
*/
function _civimobile_home_page() {
$civimobile_page_settings = _civimobile_vars_setup();
include_once(drupal_get_path('module','civimobile').'/templates/civimobile.home.tpl.php');
return NULL;
}
function _civimobile_events_page() {
$civimobile_page_settings = _civimobile_vars_setup();
include_once(drupal_get_path('module','civimobile').'/templates/civimobile.events.tpl.php');
return NULL;
}
function _civimobile_participants_page() {
$civimobile_page_settings = _civimobile_vars_setup();
include_once(drupal_get_path('module','civimobile').'/templates/civimobile.participants.tpl.php');
return NULL;
}
function _civimobile_participant_status_page() {
$civimobile_page_settings = _civimobile_vars_setup();
include_once(drupal_get_path('module','civimobile').'/templates/civimobile.participant_status.tpl.php');
return NULL;
}
function _civimobile_vars_setup() {
// Left to somebody more knowledgeable than me to figure out
// can't figure out how to load civicrm's Config.php file from here
//
civicrm_initialize();
require_once 'api/api.php';
if ( CRM_Utils_Array::value( 'locale', $GLOBALS ) ) {
$civimobile_vars['language'] = $GLOBALS['locale'];
} else {
$civimobile_vars['language'] = 'en_US';
}
$civimobile_vars['title'] = 'CiviMobile';
$civimobile_vars['head'] = drupal_get_html_head();
$civimobile_vars['favicon'] = theme_get_setting("toggle_favicon") ? "<link rel=\"shortcut icon\" href=\"". theme_get_setting("favicon") ."\" type=\"image/x-icon\"/>\n" : "";
$civimobile_vars['styles'] = drupal_get_css();
$civimobile_vars['scripts'] = drupal_get_js();
$civimobile_vars['civimobile_assets'] = base_path().drupal_get_path('module','civimobile');
$civimobile_vars['civicrm_base'] = base_path().drupal_get_path('module','civicrm');
return $civimobile_vars;
}