De-hack additional operators being added for report class only
[civicrm-core.git] / CRM / Event / BAO / Query.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2013
33 * $Id$
34 *
35 */
36 class CRM_Event_BAO_Query {
37
38 static function &getFields() {
39 $fields = array();
40 $fields = array_merge($fields, CRM_Event_DAO_Event::import());
41 $fields = array_merge($fields, self::getParticipantFields());
42 $fields = array_merge($fields, CRM_Core_DAO_Discount::export());
43
44 return $fields;
45 }
46
47 static function &getParticipantFields() {
48 $fields = CRM_Event_BAO_Participant::importableFields('Individual', TRUE, TRUE);
49 return $fields;
50 }
51
52 /**
53 * build select for CiviEvent
54 *
55 * @return void
56 * @access public
57 */
58 static function select(&$query) {
59 if (($query->_mode & CRM_Contact_BAO_Query::MODE_EVENT) ||
60 CRM_Contact_BAO_Query::componentPresent($query->_returnProperties, 'participant_')
61 ) {
62 $query->_select['participant_id'] = "civicrm_participant.id as participant_id";
63 $query->_element['participant_id'] = 1;
64 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
65
66 //add fee level
67 if (CRM_Utils_Array::value('participant_fee_level', $query->_returnProperties)) {
68 $query->_select['participant_fee_level'] = "civicrm_participant.fee_level as participant_fee_level";
69 $query->_element['participant_fee_level'] = 1;
70 }
71
72 //add fee amount
73 if (CRM_Utils_Array::value('participant_fee_amount', $query->_returnProperties)) {
74 $query->_select['participant_fee_amount'] = "civicrm_participant.fee_amount as participant_fee_amount";
75 $query->_element['participant_fee_amount'] = 1;
76 }
77
78 //add fee currency
79 if (CRM_Utils_Array::value('participant_fee_currency', $query->_returnProperties)) {
80 $query->_select['participant_fee_currency'] = "civicrm_participant.fee_currency as participant_fee_currency";
81 $query->_element['participant_fee_currency'] = 1;
82 }
83
84 //add event title also if event id is select
85 if (CRM_Utils_Array::value('event_id', $query->_returnProperties) ||
86 CRM_Utils_Array::value('event_title', $query->_returnProperties)
87 ) {
88 $query->_select['event_id'] = "civicrm_event.id as event_id";
89 $query->_select['event_title'] = "civicrm_event.title as event_title";
90 $query->_element['event_id'] = 1;
91 $query->_element['event_title'] = 1;
92 $query->_tables['civicrm_event'] = 1;
93 $query->_whereTables['civicrm_event'] = 1;
94 }
95
96 //add start date / end date
97 if (CRM_Utils_Array::value('event_start_date', $query->_returnProperties)) {
98 $query->_select['event_start_date'] = "civicrm_event.start_date as event_start_date";
99 $query->_element['event_start_date'] = 1;
100 }
101
102 if (CRM_Utils_Array::value('event_end_date', $query->_returnProperties)) {
103 $query->_select['event_end_date'] = "civicrm_event.end_date as event_end_date";
104 $query->_element['event_end_date'] = 1;
105 }
106
107 //event type
108 if (CRM_Utils_Array::value('event_type', $query->_returnProperties)) {
109 $query->_select['event_type'] = "event_type.label as event_type";
110 $query->_element['event_type'] = 1;
111 $query->_tables['event_type'] = 1;
112 $query->_whereTables['event_type'] = 1;
113 }
114
115 if (CRM_Utils_Array::value('event_type_id', $query->_returnProperties)) {
116 $query->_select['event_type_id'] = "event_type.id as event_type_id";
117 $query->_element['event_type_id'] = 1;
118 $query->_tables['event_type'] = 1;
119 $query->_whereTables['event_type'] = 1;
120 }
121
122 //add status and status_id
123 if (CRM_Utils_Array::value('participant_status', $query->_returnProperties) ||
124 CRM_Utils_Array::value('participant_status_id', $query->_returnProperties)
125 ) {
126 $query->_select['participant_status'] = "participant_status.label as participant_status";
127 $query->_select['participant_status_id'] = "participant_status.id as participant_status_id";
128 $query->_element['participant_status_id'] = 1;
129 $query->_element['participant_status'] = 1;
130 $query->_tables['civicrm_participant'] = 1;
131 $query->_tables['participant_status'] = 1;
132 $query->_whereTables['civicrm_participant'] = 1;
133 $query->_whereTables['participant_status'] = 1;
134 }
135
136 //add role
137 if (CRM_Utils_Array::value('participant_role', $query->_returnProperties)) {
138 $query->_select['participant_role'] = "participant_role.label as participant_role";
139 $query->_element['participant_role'] = 1;
140 $query->_tables['civicrm_participant'] = 1;
141 $query->_tables['participant_role'] = 1;
142 $query->_whereTables['civicrm_participant'] = 1;
143 $query->_whereTables['participant_role'] = 1;
144 }
145
146 if (CRM_Utils_Array::value('participant_role_id', $query->_returnProperties)) {
147 $query->_select['participant_role_id'] = "civicrm_participant.role_id as participant_role_id";
148 $query->_element['participant_role_id'] = 1;
149 $query->_tables['civicrm_participant'] = 1;
150 $query->_tables['participant_role'] = 1;
151 $query->_whereTables['civicrm_participant'] = 1;
152 $query->_whereTables['participant_role'] = 1;
153 }
154
155 //add register date
156 if (CRM_Utils_Array::value('participant_register_date', $query->_returnProperties)) {
157 $query->_select['participant_register_date'] = "civicrm_participant.register_date as participant_register_date";
158 $query->_element['participant_register_date'] = 1;
159 }
160
161 //add source
162 if (CRM_Utils_Array::value('participant_source', $query->_returnProperties)) {
163 $query->_select['participant_source'] = "civicrm_participant.source as participant_source";
164 $query->_element['participant_source'] = 1;
165 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
166 }
167
168 //participant note
169 if (CRM_Utils_Array::value('participant_note', $query->_returnProperties)) {
170 $query->_select['participant_note'] = "civicrm_note.note as participant_note";
171 $query->_element['participant_note'] = 1;
172 $query->_tables['participant_note'] = 1;
173 $query->_whereTables['civicrm_note'] = 1;
174 }
175
176 if (CRM_Utils_Array::value('participant_is_pay_later', $query->_returnProperties)) {
177 $query->_select['participant_is_pay_later'] = "civicrm_participant.is_pay_later as participant_is_pay_later";
178 $query->_element['participant_is_pay_later'] = 1;
179 }
180
181 if (CRM_Utils_Array::value('participant_is_test', $query->_returnProperties)) {
182 $query->_select['participant_is_test'] = "civicrm_participant.is_test as participant_is_test";
183 $query->_element['participant_is_test'] = 1;
184 }
185
186 if (CRM_Utils_Array::value('participant_registered_by_id', $query->_returnProperties)) {
187 $query->_select['participant_registered_by_id'] = "civicrm_participant.registered_by_id as participant_registered_by_id";
188 $query->_element['participant_registered_by_id'] = 1;
189 }
190
191 // get discount name
192 if (CRM_Utils_Array::value('participant_discount_name', $query->_returnProperties)) {
193 $query->_select['participant_discount_name'] = "discount_name.title as participant_discount_name";
194 $query->_element['participant_discount_name'] = 1;
195 $query->_tables['civicrm_discount'] = 1;
196 $query->_tables['participant_discount_name'] = 1;
197 $query->_whereTables['civicrm_discount'] = 1;
198 $query->_whereTables['participant_discount_name'] = 1;
199 }
200
201 //carry campaign id to selectors.
202 if (CRM_Utils_Array::value('participant_campaign_id', $query->_returnProperties)) {
203 $query->_select['participant_campaign_id'] = 'civicrm_participant.campaign_id as participant_campaign_id';
204 $query->_element['participant_campaign_id'] = 1;
205 }
206 }
207 }
208
209 static function where(&$query) {
210 $testCondition = $grouping = NULL;
211 foreach (array_keys($query->_params) as $id) {
212 if (!CRM_Utils_Array::value(0, $query->_params[$id])) {
213 continue;
214 }
215 if (substr($query->_params[$id][0], 0, 6) == 'event_' ||
216 substr($query->_params[$id][0], 0, 12) == 'participant_'
217 ) {
218 if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) {
219 $query->_useDistinct = TRUE;
220 }
221 if ($query->_params[$id][0] == 'participant_test') {
222 $testCondition = $id;
223 continue;
224 }
225 $grouping = $query->_params[$id][3];
226 self::whereClauseSingle($query->_params[$id], $query);
227 }
228 }
229 // Only add test condition if other fields are selected
230 if ($grouping !== NULL && $testCondition &&
231 // we dont want to include all tests for sql OR CRM-7827
232 $query->getOperator() != 'OR'
233 ) {
234 self::whereClauseSingle($query->_params[$testCondition], $query);
235 }
236 }
237
238 static function whereClauseSingle(&$values, &$query) {
239 list($name, $op, $value, $grouping, $wildcard) = $values;
240 switch ($name) {
241 case 'event_start_date_low':
242 case 'event_start_date_high':
243 $query->dateQueryBuilder($values,
244 'civicrm_event', 'event_start_date', 'start_date', 'Start Date'
245 );
246 return;
247
248 case 'event_end_date_low':
249 case 'event_end_date_high':
250 $query->dateQueryBuilder($values,
251 'civicrm_event', 'event_end_date', 'end_date', 'End Date'
252 );
253 return;
254
255 case 'event_id':
256 $query->_where[$grouping][] = "civicrm_event.id $op {$value}";
257 $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $value, 'title');
258 $query->_qill[$grouping][] = ts('Event') . " $op {$eventTitle}";
259 $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
260 return;
261
262 case 'event_type_id':
263
264 $eventTypes = CRM_Core_OptionGroup::values("event_type");
265 $query->_where[$grouping][] = "civicrm_participant.event_id = civicrm_event.id and civicrm_event.event_type_id = '{$value}'";
266 $query->_qill[$grouping][] = ts('Event Type - %1', array(1 => $eventTypes[$value]));
267 $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
268 return;
269
270 case 'participant_test':
271 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.is_test",
272 $op,
273 $value,
274 "Boolean"
275 );
276 if ($value) {
277 $query->_qill[$grouping][] = ts("Participant is a Test");
278 }
279 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
280 return;
281
282 case 'participant_fee_id':
283 $feeLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_FieldValue', $value, 'label');
284 $feeLabel = CRM_Core_DAO::escapeString(trim($feeLabel));
285 if ($value) {
286 $query->_where[$grouping][] = "civicrm_participant.fee_level $op '$feeLabel'";
287 $query->_qill[$grouping][] = ts("Fee level") . " $op $feeLabel";
288 }
289 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
290 return;
291
292 case 'participant_fee_amount':
293 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.fee_amount",
294 $op,
295 $value,
296 "Money"
297 );
298 if ($value) {
299 $query->_qill[$grouping][] = ts("Fee Amount") . " $op $value";
300 }
301 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
302 return;
303
304 case 'participant_fee_amount_high':
305 case 'participant_fee_amount_low':
306 $query->numberRangeBuilder($values,
307 'civicrm_participant', 'participant_fee_amount', 'fee_amount', 'Fee Amount'
308 );
309 return;
310
311 case 'participant_pay_later':
312 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.is_pay_later",
313 $op,
314 $value,
315 "Boolean"
316 );
317 $query->_qill[$grouping][] = $value ? ts("Participant is Pay Later") : ts("Participant is not Pay Later");
318 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
319 return;
320
321 case 'participant_status':
322 case 'participant_status_id':
323 $val = array();
324 if (is_array($value)) {
325 foreach ($value as $k => $v) {
326 if ($v) {
327 $val[$k] = $k;
328 }
329 }
330 $status = implode(',', $val);
331 }
332 else {
333 $status = $value;
334 }
335
336 if (count($val) > 1) {
337 $op = 'IN';
338 $status = "({$status})";
339 }
340
341 $statusTypes = CRM_Event_PseudoConstant::participantStatus();
342 $names = array();
343
344 if (!empty($val)) {
345 foreach ($val as $id => $dontCare) {
346 $names[] = $statusTypes[$id];
347 }
348 }
349 else {
350 $names[] = $statusTypes[$value];
351 }
352
353 $query->_qill[$grouping][] = ts('Participant Status %1', array(1 => $op)) . ' ' . implode(' ' . ts('or') . ' ', $names);
354
355 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.status_id",
356 $op,
357 $status,
358 "Integer"
359 );
360 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
361 return;
362
363 case 'participant_role_id':
364 $val = array();
365 if (is_array($value)) {
366 foreach ($value as $k => $v) {
367 if ($v) {
368 $val[$k] = $k;
369 }
370 }
371 }
372 else {
373 $val = array($value => 1);
374 }
375
376 $roleTypes = CRM_Event_PseudoConstant::participantRole();
377
378 $names = array();
379 foreach ($val as $id => $dontCare) {
380 $names[] = $roleTypes[$id];
381 }
382
383 if (!empty($names)) {
384 $query->_qill[$grouping][] =
385 ts('Participant Role %1', array(1 => $op)) .
386 ' ' .
387 implode(' ' . ts('or') . ' ', $names);
388 $query->_where[$grouping][] =
389 " civicrm_participant.role_id REGEXP '[[:<:]]" .
390 implode('[[:>:]]|[[:<:]]', array_keys($val)) .
391 "[[:>:]]' ";
392
393 $query->_tables['civicrm_participant'] =
394 $query->_whereTables['civicrm_participant'] = 1;
395 }
396 return;
397
398 case 'participant_source':
399 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.source",
400 $op,
401 $value,
402 "String"
403 );
404 $query->_qill[$grouping][] = ts("Participant Source") . " $op $value";
405 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
406 return;
407
408 case 'participant_register_date':
409 $query->dateQueryBuilder($values,
410 'civicrm_participant', 'participant_register_date', 'register_date', 'Register Date'
411 );
412 return;
413
414 case 'participant_id':
415 $query->_where[$grouping][] = "civicrm_participant.id $op $value";
416 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
417 return;
418
419 case 'event_id':
420 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_event.id",
421 $op,
422 $value,
423 "Integer"
424 );
425 $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
426 $title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $value, "title");
427 $query->_qill[$grouping][] = ts('Event') . " $op $value";
428 return;
429
430 case 'participant_contact_id':
431 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.contact_id",
432 $op,
433 $value,
434 "Integer"
435 );
436 $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
437 return;
438
439 case 'event_is_public':
440 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_event.is_public",
441 $op,
442 $value,
443 "Integer"
444 );
445 $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
446 return;
447
448 case 'participant_campaign_id':
449 $campParams = array(
450 'op' => $op,
451 'campaign' => $value,
452 'grouping' => $grouping,
453 'tableName' => 'civicrm_participant',
454 );
455 CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
456 return;
457 }
458 }
459
460 static function from($name, $mode, $side) {
461 $from = NULL;
462 switch ($name) {
463 case 'civicrm_participant':
464 $from = " LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id ";
465 break;
466
467 case 'civicrm_event':
468 $from = " INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id ";
469 break;
470
471 case 'event_type':
472 $from = " $side JOIN civicrm_option_group option_group_event_type ON (option_group_event_type.name = 'event_type')";
473 $from .= " $side JOIN civicrm_option_value event_type ON (civicrm_event.event_type_id = event_type.value AND option_group_event_type.id = event_type.option_group_id ) ";
474 break;
475
476 case 'participant_note':
477 $from .= " $side JOIN civicrm_note ON ( civicrm_note.entity_table = 'civicrm_participant' AND
478 civicrm_participant.id = civicrm_note.entity_id )";
479 break;
480
481 case 'participant_status':
482 $from .= " $side JOIN civicrm_participant_status_type participant_status ON (civicrm_participant.status_id = participant_status.id) ";
483 break;
484
485 case 'participant_role':
486 $from = " $side JOIN civicrm_option_group option_group_participant_role ON (option_group_participant_role.name = 'participant_role')";
487 $from .= " $side JOIN civicrm_option_value participant_role ON (civicrm_participant.role_id = participant_role.value
488 AND option_group_participant_role.id = participant_role.option_group_id ) ";
489 break;
490
491 case 'participant_discount_name':
492 $from = " $side JOIN civicrm_discount discount ON ( civicrm_participant.discount_id = discount.id )";
493 $from .= " $side JOIN civicrm_option_group discount_name ON ( discount_name.id = discount.price_set_id ) ";
494 break;
495 }
496 return $from;
497 }
498
499 /**
500 * getter for the qill object
501 *
502 * @return string
503 * @access public
504 */
505 function qill() {
506 return (isset($this->_qill)) ? $this->_qill : "";
507 }
508
509 static function defaultReturnProperties($mode,
510 $includeCustomFields = TRUE
511 ) {
512 $properties = NULL;
513 if ($mode & CRM_Contact_BAO_Query::MODE_EVENT) {
514 $properties = array(
515 'contact_type' => 1,
516 'contact_sub_type' => 1,
517 'sort_name' => 1,
518 'display_name' => 1,
519 'event_id' => 1,
520 'event_title' => 1,
521 'event_start_date' => 1,
522 'event_end_date' => 1,
523 'event_type' => 1,
524 'participant_id' => 1,
525 'participant_status' => 1,
526 'participant_role_id' => 1,
527 'participant_note' => 1,
528 'participant_register_date' => 1,
529 'participant_source' => 1,
530 'participant_fee_level' => 1,
531 'participant_is_test' => 1,
532 'participant_is_pay_later' => 1,
533 'participant_fee_amount' => 1,
534 'participant_discount_name' => 1,
535 'participant_fee_currency' => 1,
536 'participant_registered_by_id' => 1,
537 'participant_campaign_id' => 1,
538 );
539
540 if ($includeCustomFields) {
541 // also get all the custom participant properties
542 $fields = CRM_Core_BAO_CustomField::getFieldsForImport('Participant');
543 if (!empty($fields)) {
544 foreach ($fields as $name => $dontCare) {
545 $properties[$name] = 1;
546 }
547 }
548 }
549 }
550
551 return $properties;
552 }
553
554 static function buildSearchForm(&$form) {
555 $dataURLEvent = CRM_Utils_System::url('civicrm/ajax/event',
556 "reset=1",
557 FALSE, NULL, FALSE
558 );
559 $dataURLEventType = CRM_Utils_System::url('civicrm/ajax/eventType',
560 "reset=1",
561 FALSE, NULL, FALSE
562 );
563 $dataURLEventFee = CRM_Utils_System::url('civicrm/ajax/eventFee',
564 "reset=1",
565 FALSE, NULL, FALSE
566 );
567
568 $form->assign('dataURLEvent', $dataURLEvent);
569 $form->assign('dataURLEventType', $dataURLEventType);
570 $form->assign('dataURLEventFee', $dataURLEventFee);
571
572 $eventId = &$form->add('text', 'event_name', ts('Event Name'));
573 $eventType = &$form->add('text', 'event_type', ts('Event Type'));
574 $participantFee = &$form->add('text', 'participant_fee_level', ts('Fee Level'));
575
576 //elements for assigning value operation
577 $eventNameId = &$form->add('hidden', 'event_id', '', array('id' => 'event_id'));
578 $eventTypeId = &$form->add('hidden', 'event_type_id', '', array('id' => 'event_type_id'));
579 $participantFeeId = &$form->add('hidden', 'participant_fee_id', '', array('id' => 'participant_fee_id'));
580
581 CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);
582
583 $status = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
584 asort($status);
585 foreach ($status as $id => $Name) {
586 $form->_participantStatus = &$form->addElement('checkbox', "participant_status_id[$id]", NULL, $Name);
587 }
588
589 foreach (CRM_Event_PseudoConstant::participantRole() as $rId => $rName) {
590 $form->_participantRole = &$form->addElement('checkbox', "participant_role_id[$rId]", NULL, $rName);
591 }
592
593 $form->addYesNo('participant_test', ts('Participant is a Test?'));
594 $form->addYesNo('participant_pay_later', ts('Participant is Pay Later?'));
595 $form->addElement('text', 'participant_fee_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
596 $form->addElement('text', 'participant_fee_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
597
598 $form->addRule('participant_fee_amount_low', ts('Please enter a valid money value.'), 'money');
599 $form->addRule('participant_fee_amount_high', ts('Please enter a valid money value.'), 'money');
600 // add all the custom searchable fields
601 $extends = array('Participant');
602 $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
603 if ($groupDetails) {
604 $form->assign('participantGroupTree', $groupDetails);
605 foreach ($groupDetails as $group) {
606 foreach ($group['fields'] as $field) {
607 $fieldId = $field['id'];
608 $elementName = 'custom_' . $fieldId;
609 CRM_Core_BAO_CustomField::addQuickFormElement($form,
610 $elementName,
611 $fieldId,
612 FALSE, FALSE, TRUE
613 );
614 }
615 }
616 }
617
618 CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'participant_campaign_id');
619
620 $form->assign('validCiviEvent', TRUE);
621 $form->setDefaults(array('participant_test' => 0));
622 }
623
624 static function searchAction(&$row, $id) {}
625
626 static function tableNames(&$tables) {
627 //add participant table
628 if (CRM_Utils_Array::value('civicrm_event', $tables)) {
629 $tables = array_merge(array('civicrm_participant' => 1), $tables);
630 }
631 }
632 }
633