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