commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / drupal / modules / views / components / civicrm.campaign.inc
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | This file is a part of CiviCRM. |
7 | |
8 | CiviCRM is free software; you can copy, modify, and distribute it |
9 | under the terms of the GNU Affero General Public License |
10 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
11 | |
12 | CiviCRM is distributed in the hope that it will be useful, but |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 | See the GNU Affero General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Affero General Public |
18 | License and the CiviCRM Licensing Exception along |
19 | with this program; if not, contact CiviCRM LLC |
20 | at info[AT]civicrm[DOT]org. If you have questions about the |
21 | GNU Affero General Public License or the licensing of CiviCRM, |
22 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
23 +--------------------------------------------------------------------+
24 */
25
26 /**
27 * Build the $data array for CiviCampaign related tables
28 * Includes the following tables
29 * civicrm_campaign
30 */
31 require_once 'CRM/Campaign/PseudoConstant.php';
32 function _civicrm_campaign_data(&$data, $enabled) {
33
34 /**
35 *CiviCRM Campaign Base Table
36 */
37
38 $data['civicrm_campaign']['table']['group'] = t('CiviCRM Campaigns');
39
40 $data['civicrm_campaign']['table']['base'] = array(
41 // Governs the whole mozilla
42 'field' => 'id',
43 'title' => t('CiviCRM Campaigns'),
44 'help' => t("View displays CiviCRM Campaigns Data"),
45 );
46 // Campaign ID
47 $data['civicrm_campaign']['id'] = array(
48 'title' => t('Campaign ID'),
49 'help' => t('The numeric ID of the campaign'),
50 'field' => array(
51 'handler' => 'views_handler_field_numeric',
52 'click sortable' => TRUE,
53 ),
54 'argument' => array(
55 'handler' => 'views_handler_argument_numeric',
56 'numeric' => TRUE,
57 ),
58 'filter' => array(
59 'handler' => 'views_handler_filter_numeric',
60 'allow empty' => TRUE,
61 ),
62 'sort' => array(
63 'handler' => 'views_handler_sort',
64 ),
65 );
66 // Campaign's Name
67 $data['civicrm_campaign']['name'] = array(
68 'title' => t('Name'),
69 'help' => t('Campaign\'s name'),
70 'field' => array(
71 'handler' => 'views_handler_field',
72 'click sortable' => TRUE,
73 ),
74 'argument' => array(
75 'handler' => 'views_handler_argument_string',
76 ),
77 'filter' => array(
78 'handler' => 'views_handler_filter_string',
79 ),
80 'sort' => array(
81 'handler' => 'views_handler_sort',
82 ),
83 );
84
85 // Campaign Title
86 $data['civicrm_campaign']['title'] = array(
87 'title' => t('Title'),
88 'help' => t('Campaing\'s title'),
89 'field' => array(
90 'handler' => 'views_handler_field',
91 'click sortable' => TRUE,
92 ),
93 'argument' => array(
94 'handler' => 'views_handler_argument_string',
95 ),
96 'filter' => array(
97 'handler' => 'views_handler_filter_string',
98 'allow empty' => TRUE,
99 ),
100 'sort' => array(
101 'handler' => 'views_handler_sort',
102 ),
103 );
104 //Campaign Description
105 $data['civicrm_campaign']['description'] = array(
106 'title' => t('Description'),
107 'help' => t('Campaing\'s description'),
108 'field' => array(
109 'handler' => 'views_handler_field',
110 'click sortable' => TRUE,
111 ),
112 );
113 //Mailing finish date
114 $data['civicrm_campaign']['start_date'] = array(
115 'title' => t('Start Date'),
116 'help' => t('The Campaign\'s Start Date'),
117 'field' => array(
118 'handler' => 'civicrm_handler_field_datetime',
119 'click sortable' => TRUE,
120 ),
121 'argument' => array(
122 'handler' => 'views_handler_argument_date',
123 ),
124 'filter' => array(
125 'handler' => 'civicrm_handler_filter_datetime',
126 'is date' => TRUE,
127 ),
128 'sort' => array(
129 'handler' => 'civicrm_handler_sort_date',
130 ),
131 );
132
133 civicrm_views_add_date_arguments($data['civicrm_campaign'], array(
134 'title' => 'Campaign Start Date',
135 'name' => 'start_date',
136 ));
137
138 //Mailing finish date
139 $data['civicrm_campaign']['end_date'] = array(
140 'title' => t('End Date'),
141 'help' => t('The Campaign\'s End Date'),
142 'field' => array(
143 'handler' => 'civicrm_handler_field_datetime',
144 'click sortable' => TRUE,
145 ),
146 'argument' => array(
147 'handler' => 'views_handler_argument_date',
148 ),
149 'filter' => array(
150 'handler' => 'civicrm_handler_filter_datetime',
151 'is date' => TRUE,
152 ),
153 'sort' => array(
154 'handler' => 'civicrm_handler_sort_date',
155 ),
156 );
157
158 civicrm_views_add_date_arguments($data['civicrm_campaign'], array(
159 'title' => 'Campaign End Date',
160 'name' => 'end_date',
161 ));
162
163 //Campaign Type
164 $data['civicrm_campaign']['campaign_type'] = array(
165 'title' => t('Campaign Type'),
166 'real field' => 'campaign_type_id',
167 'help' => t('The Type of Campaign, ie Direct Mail, Constituent Engagement etc'),
168 'field' => array(
169 'handler' => 'civicrm_handler_field_pseudo_constant',
170 'click sortable' => TRUE,
171 'pseudo class' => 'CRM_Campaign_PseudoConstant',
172 'pseudo method' => 'campaignType',
173 ),
174 'argument' => array(
175 'handler' => 'views_handler_argument',
176 ),
177 'filter' => array(
178 'handler' => 'civicrm_handler_filter_pseudo_constant',
179 'allow empty' => TRUE,
180 'pseudo class' => 'CRM_Campaign_PseudoConstant',
181 'pseudo method' => 'campaignType',
182 ),
183 'sort' => array(
184 'handler' => 'views_handler_sort',
185 ),
186 );
187 //Campaign Type
188 $data['civicrm_campaign']['campaign_status'] = array(
189 'title' => t('Campaign Status'),
190 'real field' => 'status_id',
191 'help' => t('The Status of the Campaign, ie Completed, Cancelled etc'),
192 'field' => array(
193 'handler' => 'civicrm_handler_field_pseudo_constant',
194 'click sortable' => TRUE,
195 'pseudo class' => 'CRM_Campaign_PseudoConstant',
196 'pseudo method' => 'campaignStatus',
197 ),
198 'argument' => array(
199 'handler' => 'views_handler_argument',
200 ),
201 'filter' => array(
202 'handler' => 'civicrm_handler_filter_pseudo_constant',
203 'allow empty' => TRUE,
204 'pseudo class' => 'CRM_Campaign_PseudoConstant',
205 'pseudo method' => 'campaignStatus',
206 ),
207 'sort' => array(
208 'handler' => 'views_handler_sort',
209 ),
210 );
211 // Parent Campaign ID
212 $data['civicrm_campaign']['parent_id'] = array(
213 'title' => t('Parent Campaign ID'),
214 'help' => t('The ID of the campaign\'s parent campaign'),
215 'field' => array(
216 'handler' => 'views_handler_field_numeric',
217 'click sortable' => TRUE,
218 ),
219 'argument' => array(
220 'handler' => 'views_handler_argument_numeric',
221 'numeric' => TRUE,
222 ),
223 'filter' => array(
224 'handler' => 'views_handler_filter_numeric',
225 'allow empty' => TRUE,
226 ),
227 'sort' => array(
228 'handler' => 'views_handler_sort',
229 ),
230 );
231 //BOOLEAN : IS Active
232 $data['civicrm_campaign']['is_active'] = array(
233 'title' => t('Is Active'),
234 'help' => t('Is the campaign active ?'),
235 'field' => array(
236 'handler' => 'views_handler_field_boolean',
237 'click sortable' => TRUE,
238 ),
239 'argument' => array(
240 'handler' => 'views_handler_argument',
241 ),
242 'filter' => array(
243 'handler' => 'views_handler_filter_boolean_operator',
244 ),
245 'sort' => array(
246 'handler' => 'views_handler_sort',
247 ),
248 );
249 // Campaign's General Goal
250 $data['civicrm_campaign']['goal_general'] = array(
251 'title' => t('General Goal'),
252 'help' => t('Campaing\'s general goal'),
253 'field' => array(
254 'handler' => 'views_handler_field',
255 'click sortable' => TRUE,
256 ),
257 'argument' => array(
258 'handler' => 'views_handler_argument_string',
259 ),
260 'filter' => array(
261 'handler' => 'views_handler_filter_string',
262 'allow empty' => TRUE,
263 ),
264 'sort' => array(
265 'handler' => 'views_handler_sort',
266 ),
267 );
268 // Campaign ID
269 $data['civicrm_campaign']['goal_revenue'] = array(
270 'title' => t('Campaign Monetary Goal'),
271 'help' => t('The Monetary goal of the campaign'),
272 'field' => array(
273 'handler' => 'civicrm_handler_field_money',
274 'click sortable' => TRUE,
275 ),
276 'argument' => array(
277 'handler' => 'views_handler_argument_numeric',
278 'numeric' => TRUE,
279 ),
280 'filter' => array(
281 'handler' => 'views_handler_filter_numeric',
282 'allow empty' => TRUE,
283 ),
284 'sort' => array(
285 'handler' => 'views_handler_sort',
286 ),
287 );
288
289 // Add Support of Survey Fields.
290 $data['civicrm_survey']['table']['group'] = t('CiviCRM Surveys');
291
292
293 $data['civicrm_survey']['table']['base'] = array(
294 // Governs the whole mozilla
295 'field' => 'id',
296 'title' => t('CiviCRM Surveys'),
297 'help' => t("View displays CiviCRM Survey Data"),
298 );
299 // Link to activites table for Results
300 $data['civicrm_activity']['table']['join']['civicrm_survey'] = array(
301 // Directly links to tag table
302 'left_field' => 'id',
303 'field' => 'source_record_id',
304 'extra' => array(
305 array(
306 'field' => 'activity_type_id',
307 'value' => CRM_Campaign_PseudoConstant::activityType('value'),
308 'numeric' => FALSE,
309 ),
310 ),
311 );
312 // Survey ID
313 $data['civicrm_survey']['id'] = array(
314 'title' => t('Survey ID'),
315 'help' => t('The numeric ID of the survey'),
316 'field' => array(
317 'handler' => 'views_handler_field_numeric',
318 'click sortable' => TRUE,
319 ),
320 'argument' => array(
321 'handler' => 'views_handler_argument_numeric',
322 'numeric' => TRUE,
323 ),
324 'filter' => array(
325 'handler' => 'views_handler_filter_numeric',
326 'allow empty' => TRUE,
327 ),
328 'sort' => array(
329 'handler' => 'views_handler_sort',
330 ),
331 );
332 // Campaign ID
333 $data['civicrm_survey']['campaign_id'] = array(
334 'title' => t('Campaign'),
335 'help' => t('Event -> Campaign'),
336 'relationship' => array(
337 'base' => 'civicrm_campaign',
338 'field' => 'id',
339 'handler' => 'views_handler_relationship',
340 'label' => t('Survey -> Campaign'),
341 ),
342 );
343
344
345
346 //Activity Type
347 $data['civicrm_survey']['activity_type'] = array(
348 'title' => t('Activity Type'),
349 'real field' => 'activity_type_id',
350 'help' => t('The Type of activity, ie Survey, Canvass, Phone Bank etc'),
351 'field' => array(
352 'handler' => 'civicrm_handler_field_pseudo_constant',
353 'click sortable' => TRUE,
354 'pseudo class' => 'CRM_Campaign_PseudoConstant',
355 'pseudo method' => 'activityType',
356 ),
357 'argument' => array(
358 'handler' => 'views_handler_argument',
359 ),
360 'filter' => array(
361 'handler' => 'civicrm_handler_filter_pseudo_constant',
362 'allow empty' => TRUE,
363 'pseudo class' => 'CRM_Campaign_PseudoConstant',
364 'pseudo method' => 'activityType',
365 ),
366 'sort' => array(
367 'handler' => 'views_handler_sort',
368 ),
369 );
370 //BOOLEAN : IS Active
371 $data['civicrm_survey']['is_active'] = array(
372 'title' => t('Is Active'),
373 'help' => t('Is the survey active?'),
374 'field' => array(
375 'handler' => 'views_handler_field_boolean',
376 'click sortable' => TRUE,
377 ),
378 'argument' => array(
379 'handler' => 'views_handler_argument',
380 ),
381 'filter' => array(
382 'handler' => 'views_handler_filter_boolean_operator',
383 ),
384 'sort' => array(
385 'handler' => 'views_handler_sort',
386 ),
387 );
388 //BOOLEAN : IS Default
389 $data['civicrm_survey']['is_default'] = array(
390 'title' => t('Is Default'),
391 'help' => t('Is the survey the default?'),
392 'field' => array(
393 'handler' => 'views_handler_field_boolean',
394 'click sortable' => TRUE,
395 ),
396 'argument' => array(
397 'handler' => 'views_handler_argument',
398 ),
399 'filter' => array(
400 'handler' => 'views_handler_filter_boolean_operator',
401 ),
402 'sort' => array(
403 'handler' => 'views_handler_sort',
404 ),
405 );
406 require_once 'CRM/Campaign/DAO/Survey.php';
407 $fields = CRM_Campaign_DAO_Survey::fields();
408 //$skipFields = array( );
409 civicrm_views_add_fields($fields, $data['civicrm_survey'], 'civicrm_survey');
410 }
411