bulk comment fix
[civicrm-core.git] / CRM / Activity / BAO / Query.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.5 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
33 * $Id$
34 *
35 */
36 class CRM_Activity_BAO_Query {
37
38 /**
39 * build select for Case
40 *
41 * @param $query
42 *
43 * @return void
44 * @access public
45 */
46 static function select(&$query) {
47 if (!empty($query->_returnProperties['activity_id'])) {
48 $query->_select['activity_id'] = "civicrm_activity.id as activity_id";
49 $query->_element['activity_id'] = 1;
50 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
51 }
52
53 if (!empty($query->_returnProperties['activity_type_id'])) {
54 $query->_select['activity_type_id'] = "activity_type.id as activity_type_id";
55 $query->_element['activity_type_id'] = 1;
56 $query->_tables['civicrm_activity'] = 1;
57 $query->_tables['activity_type'] = 1;
58 $query->_whereTables['civicrm_activity'] = 1;
59 $query->_whereTables['activity_type'] = 1;
60 }
61
62 if (!empty($query->_returnProperties['activity_type'])) {
63 $query->_select['activity_type'] = "activity_type.label as activity_type,
64 civicrm_activity.activity_type_id as activity_type_id";
65 $query->_element['activity_type'] = 1;
66 $query->_tables['civicrm_activity'] = 1;
67 $query->_tables['activity_type'] = 1;
68 $query->_whereTables['civicrm_activity'] = 1;
69 $query->_whereTables['activity_type'] = 1;
70 }
71
72 if (!empty($query->_returnProperties['activity_subject'])) {
73 $query->_select['activity_subject'] = "civicrm_activity.subject as activity_subject";
74 $query->_element['activity_subject'] = 1;
75 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
76 }
77
78 if (!empty($query->_returnProperties['activity_date_time'])) {
79 $query->_select['activity_date_time'] = "civicrm_activity.activity_date_time as activity_date_time";
80 $query->_element['activity_date_time'] = 1;
81 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
82 }
83
84 if (!empty($query->_returnProperties['activity_status_id'])) {
85 $query->_select['activity_status_id'] = "activity_status.value as activity_status_id";
86 $query->_element['activity_status_id'] = 1;
87 $query->_tables['civicrm_activity'] = 1;
88 $query->_tables['activity_status'] = 1;
89 $query->_whereTables['civicrm_activity'] = 1;
90 $query->_whereTables['activity_status'] = 1;
91 }
92
93 if (!empty($query->_returnProperties['activity_status'])) {
94 $query->_select['activity_status'] = "activity_status.label as activity_status";
95 $query->_element['activity_status'] = 1;
96 $query->_tables['civicrm_activity'] = 1;
97 $query->_tables['activity_status'] = 1;
98 $query->_whereTables['civicrm_activity'] = 1;
99 $query->_whereTables['activity_status'] = 1;
100 }
101
102 if (!empty($query->_returnProperties['activity_duration'])) {
103 $query->_select['activity_duration'] = "civicrm_activity.duration as activity_duration";
104 $query->_element['activity_duration'] = 1;
105 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
106 }
107
108 if (!empty($query->_returnProperties['activity_location'])) {
109 $query->_select['activity_location'] = "civicrm_activity.location as activity_location";
110 $query->_element['activity_location'] = 1;
111 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
112 }
113
114 if (!empty($query->_returnProperties['activity_details'])) {
115 $query->_select['activity_details'] = "civicrm_activity.details as activity_details";
116 $query->_element['activity_details'] = 1;
117 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
118 }
119
120 if (!empty($query->_returnProperties['source_record_id'])) {
121 $query->_select['source_record_id'] = "civicrm_activity.source_record_id as source_record_id";
122 $query->_element['source_record_id'] = 1;
123 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
124 }
125
126 if (!empty($query->_returnProperties['activity_is_test'])) {
127 $query->_select['activity_is_test'] = "civicrm_activity.is_test as activity_is_test";
128 $query->_element['activity_is_test'] = 1;
129 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
130 }
131
132 if (!empty($query->_returnProperties['activity_campaign_id'])) {
133 $query->_select['activity_campaign_id'] = 'civicrm_activity.campaign_id as activity_campaign_id';
134 $query->_element['activity_campaign_id'] = 1;
135 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
136 }
137
138 if (!empty($query->_returnProperties['activity_engagement_level'])) {
139 $query->_select['activity_engagement_level'] = 'civicrm_activity.engagement_level as activity_engagement_level';
140 $query->_element['activity_engagement_level'] = 1;
141 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
142 }
143
144 if (!empty($query->_returnProperties['source_contact'])) {
145 $query->_select['source_contact'] = 'source_contact.sort_name as source_contact';
146 $query->_element['source_contact'] = 1;
147 $query->_tables['source_contact'] = $query->_whereTables['source_contact'] = 1;
148 }
149
150 if (!empty($query->_returnProperties['activity_result'])) {
151 $query->_select['activity_result'] = 'civicrm_activity.result as activity_result';
152 $query->_element['result'] = 1;
153 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
154 }
155 }
156
157 /**
158 * Given a list of conditions in query generate the required
159 * where clause
160 *
161 * @param $query
162 *
163 * @return void
164 * @access public
165 */
166 static function where(&$query) {
167 $grouping = NULL;
168 foreach (array_keys($query->_params) as $id) {
169 if (substr($query->_params[$id][0], 0, 9) == 'activity_') {
170 if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) {
171 $query->_useDistinct = TRUE;
172 }
173 $grouping = $query->_params[$id][3];
174 self::whereClauseSingle($query->_params[$id], $query);
175 }
176 }
177 }
178
179 /**
180 * where clause for a single field
181 *
182 * @param $values
183 * @param $query
184 * @return void
185 * @access public
186 */
187 static function whereClauseSingle(&$values, &$query) {
188 list($name, $op, $value, $grouping, $wildcard) = $values;
189
190 $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
191 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
192 if ($query->_mode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
193 $query->_skipDeleteClause = TRUE;
194 }
195
196 switch ($name) {
197 case 'activity_type_id':
198 case 'activity_type':
199 $types = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
200 //get the component activity types.
201 $compActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, TRUE);
202 $activityTypeIds = self::buildWhereAndQill($query, $value, $types, $op, $grouping, array('Activity Type', 'civicrm_activity.activity_type_id'));
203
204 foreach ($activityTypeIds as $activityTypeId) {
205 if (array_key_exists($activityTypeId, $compActTypes)) {
206 CRM_Contact_BAO_Query::$_considerCompActivities = TRUE;
207 break;
208 }
209 }
210 break;
211
212 case 'activity_survey_id':
213 if (!$value) {
214 break;
215 }
216 $value = CRM_Utils_Type::escape($value, 'Integer');
217 $query->_where[$grouping][] = " source_record_id = $value";
218 $query->_qill[$grouping][] = ts('Survey') . ' - ' . CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $value, 'title');
219 break;
220
221 case 'activity_engagement_level':
222 if (!$value) {
223 break;
224 }
225
226 $value = CRM_Utils_Type::escape($value, 'Integer');
227 $query->_where[$grouping][] = " engagement_level = $value";
228 $query->_qill[$grouping][] = ts('Engagement Index') . ' - ' . CRM_Core_OptionGroup::getLabel('engagement_index', $value);
229 break;
230
231 case 'activity_role':
232 CRM_Contact_BAO_Query::$_activityRole = $values[2];
233 $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
234 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
235 $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
236 $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
237
238 if ($values[2]) {
239 $query->_tables['civicrm_activity_contact'] = $query->_whereTables['civicrm_activity_contact'] = 1;
240 if ($values[2] == 1) {
241 $query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $sourceID";
242 $query->_qill[$grouping][] = ts('Activity created by');
243 }
244 else if ($values[2] == 2) {
245 $query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $assigneeID";
246 $query->_qill[$grouping][] = ts('Activity assigned to');
247 }
248 else if ($values[2] == 3) {
249 $query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $targetID";
250 $query->_qill[$grouping][] = ts('Activity targeted to');
251 }
252 }
253 break;
254
255 case 'activity_status':
256 $status = CRM_Core_PseudoConstant::activityStatus();
257
258 $activityTypeIds = self::buildWhereAndQill($query, $value, $status, $op, $grouping, array('Activity Status', 'civicrm_activity.status_id'));
259 break;
260
261 case 'activity_subject':
262 $n = trim($value);
263 $value = strtolower(CRM_Core_DAO::escapeString($n));
264 if ($wildcard) {
265 if (strpos($value, '%') !== FALSE) {
266 // only add wild card if not there
267 $value = "'$value'";
268 }
269 else {
270 $value = "'%$value%'";
271 }
272 $op = 'LIKE';
273 }
274 else {
275 $value = "'$value'";
276 }
277 $wc = ($op != 'LIKE') ? "LOWER(civicrm_activity.subject)" : "civicrm_activity.subject";
278 $query->_where[$grouping][] = " $wc $op $value";
279 $query->_qill[$grouping][] = ts('Subject') . " $op - '$n'";
280 break;
281
282 case 'activity_test':
283 // We dont want to include all tests for sql OR CRM-7827
284 if (!$value || $query->getOperator() != 'OR') {
285 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.is_test", $op, $value, "Boolean");
286 if ($value) {
287 $query->_qill[$grouping][] = ts('Activity is a Test');
288 }
289 }
290 break;
291
292 case 'activity_date':
293 case 'activity_date_low':
294 case 'activity_date_high':
295 $query->dateQueryBuilder($values,
296 'civicrm_activity', 'activity_date', 'activity_date_time', ts('Activity Date')
297 );
298 break;
299
300 case 'activity_id':
301 if (empty($value)) {
302 break;
303 }
304
305 if (is_array($value)) {
306 foreach ($value as $k => $v) {
307 $value[$k] = CRM_Utils_Type::escape($v, 'Integer');
308 }
309 }
310 else {
311 $value = array(CRM_Utils_Type::escape($value, 'Integer'));
312 }
313 $query->_where[$grouping][] = "civicrm_activity.id IN (" . implode(",", $value) . ")";
314 $query->_qill[$grouping][] = ts('Activity Id(s) %1', array(1 => implode($value)));
315 break;
316
317 case 'activity_taglist':
318 $taglist = $value;
319 $value = array();
320 foreach ($taglist as $val) {
321 if ($val) {
322 $val = explode(',', $val);
323 foreach ($val as $tId) {
324 if (is_numeric($tId)) {
325 $value[$tId] = 1;
326 }
327 }
328 }
329 }
330
331 case 'activity_tags':
332 $value = array_keys($value);
333 $activityTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
334
335 $names = array();
336 $val = array();
337 if (is_array($value)) {
338 foreach ($value as $k => $v) {
339 $names[] = $activityTags[$v];
340 }
341 }
342 $query->_where[$grouping][] = "civicrm_activity_tag.tag_id IN (" . implode(",", $value) . ")";
343 $query->_qill[$grouping][] = ts('Activity Tag %1', array(1 => $op)) . ' ' . implode(' ' . ts('OR') . ' ', $names);
344 $query->_tables['civicrm_activity_tag'] = $query->_whereTables['civicrm_activity_tag'] = 1;
345 break;
346
347 case 'activity_campaign_id':
348 $campParams = array(
349 'op' => $op,
350 'campaign' => $value,
351 'grouping' => $grouping,
352 'tableName' => 'civicrm_activity',
353 );
354 CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
355 break;
356 case 'activity_result':
357 if(is_array($value)) {
358 $safe = NULL;
359 while(list(,$k) = each($value)) {
360 $safe[] = "'" . CRM_Utils_Type::escape($k, 'String') . "'";
361 }
362 $query->_where[$grouping][] = "civicrm_activity.result IN (" . implode(',', $safe) . ")";
363 $query->_qill[$grouping][] = ts("Activity Result - %1", array(1 => implode(' or ', $safe)));
364 }
365 break;
366 }
367 }
368
369 static function from($name, $mode, $side) {
370 $from = NULL;
371 switch ($name) {
372 case 'civicrm_activity':
373 //CRM-7480 we are going to civicrm_activity table either
374 //from civicrm_activity_target or civicrm_activity_assignment.
375 //as component specific activities does not have entry in
376 //activity target table so lets consider civicrm_activity_assignment.
377 $from .= " INNER JOIN civicrm_activity_contact
378 ON ( civicrm_activity_contact.contact_id = contact_a.id ) ";
379 $from .= " INNER JOIN civicrm_activity
380 ON ( civicrm_activity.id = civicrm_activity_contact.activity_id
381 AND civicrm_activity.is_deleted = 0 AND civicrm_activity.is_current_revision = 1 )";
382
383 $activityRole = CRM_Contact_BAO_Query::$_activityRole;
384 break;
385
386 case 'activity_status':
387 $from .= " $side JOIN civicrm_option_group option_group_activity_status ON (option_group_activity_status.name = 'activity_status')";
388 $from .= " $side JOIN civicrm_option_value activity_status ON (civicrm_activity.status_id = activity_status.value
389 AND option_group_activity_status.id = activity_status.option_group_id ) ";
390 break;
391
392 case 'activity_type':
393 $from .= " $side JOIN civicrm_option_group option_group_activity_type ON (option_group_activity_type.name = 'activity_type')";
394 $from .= " $side JOIN civicrm_option_value activity_type ON (civicrm_activity.activity_type_id = activity_type.value
395 AND option_group_activity_type.id = activity_type.option_group_id ) ";
396 break;
397
398 case 'civicrm_activity_tag':
399 $from .= " $side JOIN civicrm_entity_tag as civicrm_activity_tag ON ( civicrm_activity_tag.entity_table = 'civicrm_activity' AND civicrm_activity_tag.entity_id = civicrm_activity.id ) ";
400 break;
401
402 case 'source_contact':
403 $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
404 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
405 $from = "
406 LEFT JOIN civicrm_activity_contact ac
407 ON ( ac.activity_id = civicrm_activity_contact.activity_id AND ac.record_type_id = {$sourceID})
408 INNER JOIN civicrm_contact source_contact ON (ac.contact_id = source_contact.id)";
409 break;
410 }
411
412 return $from;
413 }
414
415 /**
416 * getter for the qill object
417 *
418 * @return string
419 * @access public
420 */
421 function qill() {
422 return (isset($this->_qill)) ? $this->_qill : "";
423 }
424
425 /**
426 * add all the elements shared between case activity search and advanaced search
427 *
428 * @access public
429 *
430 * @param $form CRM_Core_Form
431 * @return void
432 * @static
433 */
434 static function buildSearchForm(&$form) {
435 $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
436 asort($activityOptions);
437 foreach ($activityOptions as $activityID => $activity) {
438 $form->_activityElement =&
439 $form->addElement(
440 'checkbox',
441 "activity_type_id[$activityID]",
442 NULL,
443 $activity,
444 array('onClick' => 'showCustomData( this.id );')
445 );
446 }
447
448 CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
449
450 $activityRoles = array(
451 3 => ts('With'),
452 2 => ts('Assigned to'),
453 1 => ts('Added by'),
454 );
455 $form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE));
456 $form->setDefaults(array('activity_role' => 3));
457 $activityStatus = CRM_Core_PseudoConstant::activityStatus();
458 foreach ($activityStatus as $activityStatusID => $activityStatusName) {
459 $activity_status[] = $form->createElement('checkbox', $activityStatusID, NULL, $activityStatusName);
460 }
461 $form->addGroup($activity_status, 'activity_status', ts('Activity Status'), TRUE);
462 $form->setDefaults(array('activity_status[1]' => 1, 'activity_status[2]' => 1));
463 $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
464 $form->addYesNo('activity_test', ts('Activity is a Test?'));
465 $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
466 if ($activity_tags) {
467 foreach ($activity_tags as $tagID => $tagName) {
468 $form->_tagElement = &$form->addElement('checkbox', "activity_tags[$tagID]",
469 NULL, $tagName
470 );
471 }
472 }
473
474 $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
475 CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
476
477 $surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
478 if ($surveys) $form->add('select', 'activity_survey_id', ts('Survey / Petition'),
479 array('' => ts('- none -')) + $surveys, FALSE,
480 array('class' => 'crm-select2')
481 );
482
483 $extends = array('Activity');
484 $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
485 if ($groupDetails) {
486 $form->assign('activityGroupTree', $groupDetails);
487 foreach ($groupDetails as $group) {
488 foreach ($group['fields'] as $field) {
489 $fieldId = $field['id'];
490 $elementName = 'custom_' . $fieldId;
491 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
492 }
493 }
494 }
495
496 CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
497
498 //add engagement level CRM-7775
499 $buildEngagementLevel = FALSE;
500 $buildSurveyResult = FALSE;
501 if (CRM_Campaign_BAO_Campaign::isCampaignEnable() &&
502 CRM_Campaign_BAO_Campaign::accessCampaign()
503 ) {
504 $buildEngagementLevel = TRUE;
505 $form->addSelect('activity_engagement_level', array('entity' => 'activity', 'option_url' => NULL));
506
507 // Add survey result field.
508 $optionGroups = CRM_Campaign_BAO_Survey::getResultSets( 'name' );
509 $resultOptions = array();
510 foreach ( $optionGroups as $gid => $name ) {
511 if ( $name ) {
512 $value = array();
513 $value = CRM_Core_OptionGroup::values($name);
514 if (!empty($value)) {
515 while(list($k,$v) = each($value)) {
516 $resultOptions[$v] = $v;
517 }
518 }
519 }
520 }
521 // If no survey result options have been created, don't build
522 // the field to avoid clutter.
523 if(count($resultOptions) > 0) {
524 $buildSurveyResult = TRUE;
525 asort($resultOptions);
526 $form->add('select', 'activity_result', ts("Survey Result"),
527 $resultOptions, FALSE,
528 array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2')
529 );
530 }
531 }
532
533 $form->assign('buildEngagementLevel', $buildEngagementLevel);
534 $form->assign('buildSurveyResult', $buildSurveyResult);
535 $form->setDefaults(array('activity_test' => 0));
536 }
537
538 static function defaultReturnProperties($mode, $includeCustomFields = TRUE) {
539 $properties = NULL;
540 if ($mode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
541 $properties = array(
542 'activity_id' => 1,
543 'contact_type' => 1,
544 'contact_sub_type' => 1,
545 'sort_name' => 1,
546 'display_name' => 1,
547 'activity_type' => 1,
548 'activity_type_id' => 1,
549 'activity_subject' => 1,
550 'activity_date_time' => 1,
551 'activity_duration' => 1,
552 'activity_location' => 1,
553 'activity_details' => 1,
554 'activity_status' => 1,
555 'source_contact' => 1,
556 'source_record_id' => 1,
557 'activity_is_test' => 1,
558 'activity_campaign_id' => 1,
559 'result' => 1,
560 'activity_engagement_level' => 1,
561 );
562
563 if ($includeCustomFields) {
564 // also get all the custom activity properties
565 $fields = CRM_Core_BAO_CustomField::getFieldsForImport('Activity');
566 if (!empty($fields)) {
567 foreach ($fields as $name => $dontCare) {
568 $properties[$name] = 1;
569 }
570 }
571 }
572 }
573
574 return $properties;
575 }
576
577 static function buildWhereAndQill(&$query, $value, $pseudoconstantType, $op, $grouping, $params) {
578 $matches = $val = $clause = array();
579
580 if (is_array($value)) {
581 foreach ($value as $k => $v) {
582 if ($k) {
583 $val[] = $k;
584 }
585 }
586
587 if (count($val) > 0) {
588 // Overwrite $op so it works with an IN where statement.
589 $op = 'IN';
590 }
591 else {
592 // If we somehow have an empty array, just return
593 return;
594 }
595 $value = $matches[0] = $val;
596 }
597 else {
598 preg_match_all('/\d+/', $value, $matches);
599 }
600 foreach ($matches[0] as $qill) {
601 $clause[] = CRM_Utils_Array::value($qill, $pseudoconstantType);
602 }
603
604 $query->_qill[$grouping][] = ts($params[0] . ' %1 ', array(1 => $op)) . implode(' ' . ts('or') . ' ', $clause);
605 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($params[1],
606 $op, $value, "Integer"
607 );
608 return $matches[0];
609 }
610 }
611