3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Activity_BAO_Query
{
20 * Build select for Case.
22 * @param CRM_Contact_BAO_Query $query
24 public static function select(&$query) {
25 if (!empty($query->_returnProperties
['activity_id'])) {
26 $query->_select
['activity_id'] = 'civicrm_activity.id as activity_id';
27 $query->_element
['activity_id'] = 1;
28 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
31 if (!empty($query->_returnProperties
['activity_type_id'])) {
32 $query->_select
['activity_type_id'] = 'activity_type.value as activity_type_id';
33 $query->_element
['activity_type_id'] = 1;
34 $query->_tables
['civicrm_activity'] = 1;
35 $query->_tables
['activity_type'] = 1;
36 $query->_whereTables
['civicrm_activity'] = 1;
37 $query->_whereTables
['activity_type'] = 1;
40 if (!empty($query->_returnProperties
['activity_type'])) {
41 $query->_select
['activity_type'] = 'activity_type.label as activity_type';
42 $query->_element
['activity_type'] = 1;
43 $query->_tables
['civicrm_activity'] = 1;
44 $query->_tables
['activity_type'] = 1;
45 $query->_whereTables
['civicrm_activity'] = 1;
46 $query->_whereTables
['activity_type'] = 1;
49 if (!empty($query->_returnProperties
['activity_subject'])) {
50 $query->_select
['activity_subject'] = 'civicrm_activity.subject as activity_subject';
51 $query->_element
['activity_subject'] = 1;
52 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
55 if (!empty($query->_returnProperties
['activity_date_time'])) {
56 $query->_select
['activity_date_time'] = 'civicrm_activity.activity_date_time as activity_date_time';
57 $query->_element
['activity_date_time'] = 1;
58 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
61 if (!empty($query->_returnProperties
['activity_status_id'])) {
62 $query->_select
['activity_status_id'] = 'civicrm_activity.status_id as activity_status_id';
63 $query->_element
['activity_status_id'] = 1;
64 $query->_tables
['civicrm_activity'] = 1;
65 $query->_whereTables
['civicrm_activity'] = 1;
68 if (!empty($query->_returnProperties
['activity_status'])) {
69 $query->_select
['activity_status_id'] = 1;
70 $query->_element
['activity_status'] = 1;
71 $query->_tables
['civicrm_activity'] = 1;
72 $query->_whereTables
['civicrm_activity'] = 1;
75 if (!empty($query->_returnProperties
['activity_duration'])) {
76 $query->_select
['activity_duration'] = 'civicrm_activity.duration as activity_duration';
77 $query->_element
['activity_duration'] = 1;
78 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
81 if (!empty($query->_returnProperties
['activity_location'])) {
82 $query->_select
['activity_location'] = 'civicrm_activity.location as activity_location';
83 $query->_element
['activity_location'] = 1;
84 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
87 if (!empty($query->_returnProperties
['activity_details'])) {
88 $query->_select
['activity_details'] = 'civicrm_activity.details as activity_details';
89 $query->_element
['activity_details'] = 1;
90 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
93 if (!empty($query->_returnProperties
['source_record_id'])) {
94 $query->_select
['source_record_id'] = 'civicrm_activity.source_record_id as source_record_id';
95 $query->_element
['source_record_id'] = 1;
96 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
99 if (!empty($query->_returnProperties
['activity_is_test'])) {
100 $query->_select
['activity_is_test'] = 'civicrm_activity.is_test as activity_is_test';
101 $query->_element
['activity_is_test'] = 1;
102 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
105 if (!empty($query->_returnProperties
['activity_campaign_id'])) {
106 $query->_select
['activity_campaign_id'] = 'civicrm_activity.campaign_id as activity_campaign_id';
107 $query->_element
['activity_campaign_id'] = 1;
108 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
111 if (!empty($query->_returnProperties
['activity_engagement_level'])) {
112 $query->_select
['activity_engagement_level'] = 'civicrm_activity.engagement_level as activity_engagement_level';
113 $query->_element
['activity_engagement_level'] = 1;
114 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
117 if (!empty($query->_returnProperties
['source_contact'])) {
118 $query->_select
['source_contact'] = 'source_contact.sort_name as source_contact';
119 $query->_element
['source_contact'] = 1;
120 $query->_tables
['civicrm_activity'] = $query->_tables
['source_contact'] = $query->_whereTables
['source_contact'] = 1;
123 if (!empty($query->_returnProperties
['source_contact_id'])) {
124 $query->_select
['source_contact_id'] = 'source_contact.id as source_contact_id';
125 $query->_element
['source_contact_id'] = 1;
126 $query->_tables
['civicrm_activity'] = $query->_tables
['source_contact'] = $query->_whereTables
['source_contact'] = 1;
129 if (!empty($query->_returnProperties
['activity_result'])) {
130 $query->_select
['activity_result'] = 'civicrm_activity.result as activity_result';
131 $query->_element
['result'] = 1;
132 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
135 if (!empty($query->_returnProperties
['parent_id'])) {
136 $query->_tables
['parent_id'] = 1;
137 $query->_whereTables
['parent_id'] = 1;
138 $query->_element
['parent_id'] = 1;
141 if (!empty($query->_returnProperties
['activity_priority'])) {
142 $query->_select
['activity_priority'] = 'activity_priority.label as activity_priority,
143 civicrm_activity.priority_id as priority_id';
144 $query->_element
['activity_priority'] = 1;
145 $query->_tables
['activity_priority'] = 1;
146 $query->_whereTables
['activity_priority'] = 1;
147 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
152 * Given a list of conditions in query generate the required where clause.
154 * @param \CRM_Contact_BAO_Query $query
156 * @throws \CRM_Core_Exception
158 public static function where(&$query) {
159 foreach (array_keys($query->_params
) as $id) {
160 if (substr($query->_params
[$id][0], 0, 9) === 'activity_') {
161 if ($query->_mode
== CRM_Contact_BAO_Query
::MODE_CONTACTS
) {
162 $query->_useDistinct
= TRUE;
164 $query->_params
[$id][3];
165 self
::whereClauseSingle($query->_params
[$id], $query);
171 * Where clause for a single field.
173 * @param array $values
174 * @param CRM_Contact_BAO_Query $query
176 * @throws \CRM_Core_Exception
178 public static function whereClauseSingle(&$values, &$query) {
179 list($name, $op, $value, $grouping) = $values;
181 $fields = CRM_Activity_BAO_Activity
::exportableFields();
182 $fieldSpec = $query->getFieldSpec($name);
183 $query->_tables
['civicrm_activity'] = $query->_whereTables
['civicrm_activity'] = 1;
184 if ($query->_mode
& CRM_Contact_BAO_Query
::MODE_ACTIVITY
) {
185 $query->_skipDeleteClause
= TRUE;
187 // @todo we want to do this in a more metadata driven way, and also in contribute.
190 'activity_status' => 'activity_status_id',
192 $name = $namesToConvert[$name] ??
$name;
195 case 'activity_type_id':
196 case 'activity_status_id':
197 case 'activity_engagement_level':
199 case 'activity_campaign_id':
200 case 'activity_priority_id':
201 // We no longer expect "subject" as a specific criteria (as of CRM-19447),
202 // but we still use activity_subject in Activity.Get API
203 case 'activity_subject':
206 if (in_array($name, ['activity_engagement_level', 'activity_id'])) {
207 $name = $qillName = str_replace('activity_', '', $name);
209 if (in_array($name, [
211 'activity_priority_id',
213 $name = str_replace('activity_', '', $name);
214 $qillName = str_replace('_id', '', $qillName);
216 if ($name == 'activity_campaign_id') {
217 $name = 'campaign_id';
220 $dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type
::typeToString($fields[$qillName]['type']) : 'String';
222 $where = $fieldSpec['where'];
224 $where = 'civicrm_activity.' . $name;
226 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause($where, $op, $value, $dataType);
227 list($op, $value) = CRM_Contact_BAO_Query
::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op);
228 $query->_qill
[$grouping][] = ts('%1 %2 %3', [
229 1 => $fields[$qillName]['title'],
235 case 'activity_text':
236 self
::whereClauseSingleActivityText($values, $query);
239 case 'activity_type':
240 case 'activity_priority':
241 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("$name.label", $op, $value, 'String');
242 list($op, $value) = CRM_Contact_BAO_Query
::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op);
243 $query->_qill
[$grouping][] = ts('%1 %2 %3', [
244 1 => $fields[$name]['title'],
248 $query->_tables
[$name] = $query->_whereTables
[$name] = 1;
251 case 'activity_survey_id':
255 $value = CRM_Utils_Type
::escape($value, 'Integer');
256 $query->_where
[$grouping][] = " civicrm_activity.source_record_id = $value";
257 $query->_qill
[$grouping][] = ts('Survey') . ' - ' . CRM_Core_DAO
::getFieldValue('CRM_Campaign_DAO_Survey', $value, 'title');
260 case 'activity_role':
261 CRM_Contact_BAO_Query
::$_activityRole = $values[2];
262 $activityContacts = CRM_Activity_BAO_ActivityContact
::buildOptions('record_type_id', 'validate');
263 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
264 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
265 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
268 $query->_tables
['civicrm_activity_contact'] = $query->_whereTables
['civicrm_activity_contact'] = 1;
269 if ($values[2] == 1) {
270 $query->_where
[$grouping][] = " civicrm_activity_contact.record_type_id = $sourceID";
271 $query->_qill
[$grouping][] = ts('Activity created by');
273 elseif ($values[2] == 2) {
274 $query->_where
[$grouping][] = " civicrm_activity_contact.record_type_id = $assigneeID";
275 $query->_qill
[$grouping][] = ts('Activity assigned to');
277 elseif ($values[2] == 3) {
278 $query->_where
[$grouping][] = " civicrm_activity_contact.record_type_id = $targetID";
279 $query->_qill
[$grouping][] = ts('Activity targeted to');
284 case 'activity_test':
285 // We don't want to include all tests for sql OR CRM-7827
286 if (!$value ||
$query->getOperator() != 'OR') {
287 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("civicrm_activity.is_test", $op, $value, "Boolean");
289 $query->_qill
[$grouping][] = ts('Activity is a Test');
294 case 'activity_date':
295 case 'activity_date_low':
296 case 'activity_date_high':
297 case 'activity_date_time_low':
298 case 'activity_date_time_high':
299 $query->dateQueryBuilder($values,
300 'civicrm_activity', str_replace([
303 ], '', $name), 'activity_date_time', ts('Activity Date')
307 case 'activity_taglist':
310 foreach ($taglist as $val) {
312 $val = explode(',', $val);
313 foreach ($val as $tId) {
314 if (is_numeric($tId)) {
321 case 'activity_tags':
322 $activityTags = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]);
324 if (!is_array($value)) {
325 $value = explode(',', $value);
329 foreach ($value as $k => $v) {
330 $names[] = $activityTags[$v];
333 $query->_where
[$grouping][] = "civicrm_activity_tag.tag_id IN (" . implode(",", $value) . ")";
334 $query->_qill
[$grouping][] = ts('Activity Tag %1', [1 => $op]) . ' ' . implode(' ' . ts('OR') . ' ', $names);
335 $query->_tables
['civicrm_activity_tag'] = $query->_whereTables
['civicrm_activity_tag'] = 1;
338 case 'activity_result':
339 if (is_array($value)) {
341 foreach ($value as $id => $k) {
342 $safe[] = "'" . CRM_Utils_Type
::escape($k, 'String') . "'";
344 $query->_where
[$grouping][] = "civicrm_activity.result IN (" . implode(',', $safe) . ")";
345 $query->_qill
[$grouping][] = ts("Activity Result - %1", [1 => implode(' or ', $safe)]);
351 $query->_where
[$grouping][] = "civicrm_activity.parent_id IS NOT NULL";
352 $query->_qill
[$grouping][] = ts('Activities which have Followup Activities');
354 elseif ($value == 2) {
355 $query->_where
[$grouping][] = "civicrm_activity.parent_id IS NULL";
356 $query->_qill
[$grouping][] = ts('Activities without Followup Activities');
360 case 'followup_parent_id':
362 $query->_where
[$grouping][] = "civicrm_activity.parent_id IS NOT NULL";
363 $query->_qill
[$grouping][] = ts('Activities which are Followup Activities');
365 elseif ($value == 2) {
366 $query->_where
[$grouping][] = "civicrm_activity.parent_id IS NULL";
367 $query->_qill
[$grouping][] = ts('Activities which are not Followup Activities');
371 case 'source_contact':
372 case 'source_contact_id':
373 $columnName = strstr($name, '_id') ?
'id' : 'sort_name';
374 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("source_contact.{$columnName}", $op, $value, CRM_Utils_Type
::typeToString($fields[$name]['type']));
375 list($op, $value) = CRM_Contact_BAO_Query
::buildQillForFieldValue('CRM_Contact_DAO_Contact', $columnName, $value, $op);
376 $query->_qill
[$grouping][] = ts('%1 %2 %3', [
377 1 => $fields[$name]['title'],
386 * @param string $name
390 * @return null|string
392 public static function from($name, $mode, $side) {
395 case 'civicrm_activity':
396 //CRM-7480 we are going to civicrm_activity table either
397 //from civicrm_activity_target or civicrm_activity_assignment.
398 //as component specific activities does not have entry in
399 //activity target table so lets consider civicrm_activity_assignment.
400 $from .= " $side JOIN civicrm_activity_contact
401 ON ( civicrm_activity_contact.contact_id = contact_a.id ) ";
402 $from .= " $side JOIN civicrm_activity
403 ON ( civicrm_activity.id = civicrm_activity_contact.activity_id
404 AND civicrm_activity.is_deleted = 0 AND civicrm_activity.is_current_revision = 1 )";
405 // Do not show deleted contact's activity
406 $from .= " INNER JOIN civicrm_contact
407 ON ( civicrm_activity_contact.contact_id = civicrm_contact.id and civicrm_contact.is_deleted != 1 )";
410 case 'activity_type':
411 $from .= " $side JOIN civicrm_option_group option_group_activity_type ON (option_group_activity_type.name = 'activity_type')";
412 $from .= " $side JOIN civicrm_option_value activity_type ON (civicrm_activity.activity_type_id = activity_type.value
413 AND option_group_activity_type.id = activity_type.option_group_id ) ";
416 case 'activity_priority':
417 $from .= " $side JOIN civicrm_option_group option_group_activity_priority ON (option_group_activity_priority.name = 'priority')";
418 $from .= " $side JOIN civicrm_option_value activity_priority ON (civicrm_activity.priority_id = activity_priority.value
419 AND option_group_activity_priority.id = activity_priority.option_group_id ) ";
422 case 'civicrm_activity_tag':
423 $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 ) ";
426 case 'source_contact':
427 $sourceID = CRM_Core_PseudoConstant
::getKey(
428 'CRM_Activity_BAO_ActivityContact',
433 LEFT JOIN civicrm_activity_contact source_activity
434 ON (source_activity.activity_id = civicrm_activity_contact.activity_id
435 AND source_activity.record_type_id = {$sourceID})
436 LEFT JOIN civicrm_contact source_contact ON (source_activity.contact_id = source_contact.id)";
440 $from = "$side JOIN civicrm_activity AS parent_id ON civicrm_activity.id = parent_id.parent_id";
448 * Get the metadata for fields to be included on the activity search form.
450 * @throws \CiviCRM_API3_Exception
451 * @todo ideally this would be a trait included on the activity search & advanced search
452 * rather than a static function.
454 public static function getSearchFieldMetadata() {
455 $fields = ['activity_type_id', 'activity_date_time', 'priority_id', 'activity_location', 'activity_status_id'];
456 $metadata = civicrm_api3('Activity', 'getfields', [])['values'];
457 $metadata = array_intersect_key($metadata, array_flip($fields));
458 $metadata['activity_text'] = [
459 'title' => ts('Activity Text'),
460 'type' => CRM_Utils_Type
::T_STRING
,
461 'is_pseudofield' => TRUE,
470 * Add all the elements shared between case activity search and advanced search.
472 * @param CRM_Core_Form_Search $form
474 * @throws \CiviCRM_API3_Exception
475 * @throws \CRM_Core_Exception
477 public static function buildSearchForm(&$form) {
478 $form->addSearchFieldMetadata(['Activity' => self
::getSearchFieldMetadata()]);
479 $form->addFormFieldsFromMetadata();
481 $followUpActivity = [
485 $form->addRadio('parent_id', NULL, $followUpActivity, ['allowClear' => TRUE]);
486 $form->addRadio('followup_parent_id', NULL, $followUpActivity, ['allowClear' => TRUE]);
489 2 => ts('Assigned to'),
492 $form->addRadio('activity_role', NULL, $activityRoles, ['allowClear' => TRUE]);
493 $form->setDefaults(['activity_role' => 3]);
494 $activityStatus = CRM_Core_PseudoConstant
::get('CRM_Activity_DAO_Activity', 'status_id', [
496 'labelColumn' => 'name',
498 $ssID = $form->get('ssID');
499 $status = [$activityStatus['Completed'], $activityStatus['Scheduled']];
500 //If status is saved in smart group.
501 if (!empty($ssID) && !empty($form->_formValues
['activity_status_id'])) {
502 $status = $form->_formValues
['activity_status_id'];
504 $form->setDefaults(['activity_status_id' => $status]);
506 $form->addElement('text', 'activity_text', ts('Activity Text'), CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
508 $form->addRadio('activity_option', '', CRM_Core_SelectValues
::activityTextOptions());
509 $form->setDefaults(['activity_option' => 'both']);
511 $form->addYesNo('activity_test', ts('Activity is a Test?'));
512 $activity_tags = CRM_Core_BAO_Tag
::getColorTags('civicrm_activity');
514 if ($activity_tags) {
515 $form->add('select2', 'activity_tags', ts('Activity Tag(s)'),
516 $activity_tags, FALSE, [
517 'id' => 'activity_tags',
520 'class' => 'crm-select2',
521 'placeholder' => ts('- select -'),
526 $parentNames = CRM_Core_BAO_Tag
::getTagSet('civicrm_activity');
527 CRM_Core_Form_Tag
::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
529 $surveys = CRM_Campaign_BAO_Survey
::getSurveys(TRUE, FALSE, FALSE, TRUE);
531 $form->add('select', 'activity_survey_id', ts('Survey / Petition'),
532 ['' => ts('- none -')] +
$surveys, FALSE,
533 ['class' => 'crm-select2']
537 CRM_Core_BAO_Query
::addCustomFormFields($form, ['Activity']);
539 CRM_Campaign_BAO_Campaign
::addCampaignInComponentSearch($form, 'activity_campaign_id');
541 // Add engagement level CRM-7775.
542 $buildEngagementLevel = FALSE;
543 $buildSurveyResult = FALSE;
544 if (CRM_Campaign_BAO_Campaign
::isCampaignEnable() &&
545 CRM_Campaign_BAO_Campaign
::accessCampaign()
547 $buildEngagementLevel = TRUE;
548 $form->addSelect('activity_engagement_level', [
549 'entity' => 'activity',
550 'context' => 'search',
553 // Add survey result field.
554 $optionGroups = CRM_Campaign_BAO_Survey
::getResultSets('name');
556 foreach ($optionGroups as $gid => $name) {
558 $value = CRM_Core_OptionGroup
::values($name);
559 if (!empty($value)) {
560 foreach ($value as $k => $v) {
561 $resultOptions[$v] = $v;
566 // If no survey result options have been created, don't build
567 // the field to avoid clutter.
568 if (count($resultOptions) > 0) {
569 $buildSurveyResult = TRUE;
570 asort($resultOptions);
571 $form->add('select', 'activity_result', ts("Survey Result"),
572 $resultOptions, FALSE,
574 'id' => 'activity_result',
575 'multiple' => 'multiple',
576 'class' => 'crm-select2',
582 $form->assign('buildEngagementLevel', $buildEngagementLevel);
583 $form->assign('buildSurveyResult', $buildSurveyResult);
584 $form->setDefaults(['activity_test' => 0]);
589 * @param bool $includeCustomFields
593 public static function defaultReturnProperties($mode, $includeCustomFields = TRUE) {
595 if ($mode & CRM_Contact_BAO_Query
::MODE_ACTIVITY
) {
599 'contact_sub_type' => 1,
602 'activity_type' => 1,
603 'activity_type_id' => 1,
604 'activity_subject' => 1,
605 'activity_date_time' => 1,
606 'activity_duration' => 1,
607 'activity_location' => 1,
608 'activity_details' => 1,
609 'activity_status' => 1,
610 'activity_priority' => 1,
611 'source_contact' => 1,
612 'source_record_id' => 1,
613 'activity_is_test' => 1,
614 'activity_campaign_id' => 1,
616 'activity_engagement_level' => 1,
620 if ($includeCustomFields) {
621 // also get all the custom activity properties
622 $fields = CRM_Core_BAO_CustomField
::getFieldsForImport('Activity');
623 if (!empty($fields)) {
624 foreach ($fields as $name => $dontCare) {
625 $properties[$name] = 1;
635 * Get the list of fields required to populate the selector.
637 * The default return properties array returns far too many fields for 'everyday use. Every field you add to this array
638 * kills a small kitten so add carefully.
640 public static function selectorReturnProperties() {
644 'contact_sub_type' => 1,
647 'activity_type_id' => 1,
648 'activity_subject' => 1,
649 'activity_date_time' => 1,
650 'activity_status_id' => 1,
651 'source_contact' => 1,
652 'source_record_id' => 1,
653 'activity_is_test' => 1,
654 'activity_campaign_id' => 1,
655 'activity_engagement_level' => 1,
662 * Where/qill clause for notes
664 * @param array $values
665 * @param CRM_Contact_BAO_Query $query
667 * @throws \CRM_Core_Exception
669 public static function whereClauseSingleActivityText(&$values, &$query) {
670 list($name, $op, $value, $grouping, $wildcard) = $values;
671 $activityOptionValues = $query->getWhereValues('activity_option', $grouping);
672 $activityOption = CRM_Utils_Array
::value(2, $activityOptionValues, 6);
674 $query->_useDistinct
= TRUE;
676 $label = ts('Activity Text (%1)', [1 => CRM_Utils_Array
::value($activityOption, CRM_Core_SelectValues
::activityTextOptions())]);
678 if ($activityOption %
2 == 0) {
679 $clauses[] = $query->buildClause('civicrm_activity.details', $op, $value, 'String');
681 if ($activityOption %
3 == 0) {
682 $clauses[] = $query->buildClause('civicrm_activity.subject', $op, $value, 'String');
685 $query->_where
[$grouping][] = "( " . implode(' OR ', $clauses) . " )";
686 list($qillOp, $qillVal) = $query->buildQillForFieldValue(NULL, $name, $value, $op);
687 $query->_qill
[$grouping][] = ts("%1 %2 '%3'", [