Fix CRM-19447: "Improve Activity Subject/Details text search to be similiar to Notes...
authorAllen Shaw <allen@JoineryHQ.com>
Wed, 14 Dec 2016 02:50:20 +0000 (20:50 -0600)
committerdeb.monish <monish.deb@webaccessglobal.com>
Thu, 29 Dec 2016 09:22:51 +0000 (14:52 +0530)
CRM/Activity/BAO/Query.php
CRM/Activity/Form/Search.php
CRM/Contact/BAO/Query.php
templates/CRM/Activity/Form/Search/Common.tpl

index 8dc44b30edc6af9c7a2bac99fcebf40cb864d2ae..f863c96157523c53202d696493103d5c25e790a1 100644 (file)
@@ -212,10 +212,8 @@ class CRM_Activity_BAO_Query {
         $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
         break;
 
-      case 'activity':
-      case 'activity_details':
-      case 'activity_subject':
-        self::activity($values, $query);
+      case 'activity_text':
+        self::whereClauseSingleActivityText($values, $query);
         break;
 
       case 'activity_type':
@@ -431,7 +429,7 @@ class CRM_Activity_BAO_Query {
       array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
     );
     $form->setDefaults(array('status_id' => array($activityStatus['Completed'], $activityStatus['Scheduled'])));
-    $form->addElement('text', 'activity', ts('Activity Text'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
+    $form->addElement('text', 'activity_text', ts('Activity Text'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $activity_options = array(
       2 => ts('Details Only'),
       3 => ts('Subject Only'),
@@ -576,27 +574,20 @@ class CRM_Activity_BAO_Query {
    *
    * @param array $values
    */
-  public static function activity(&$values, &$query) {
+  public static function whereClauseSingleActivityText(&$values, &$query) {
     list($name, $op, $value, $grouping, $wildcard) = $values;
-
     $activityOptionValues = $query->getWhereValues('activity_option', $grouping);
     $activityOption = CRM_Utils_Array::value('2', $activityOptionValues, '6');
-    $activityOption = ($name == 'activity_details') ? 2 : (($name == 'activity_subject') ? 3 : $activityOption);
 
     $query->_useDistinct = TRUE;
 
     $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
     $n = trim($value);
     $value = $strtolower(CRM_Core_DAO::escapeString($n));
-    if ($wildcard) {
-      if (strpos($value, '%') === FALSE) {
-        $value = "%$value%";
-      }
-      $op = 'LIKE';
-    }
-    elseif ($op == 'IS NULL' || $op == 'IS NOT NULL') {
-      $value = NULL;
+    if (strpos($value, '%') === FALSE) {
+      $value = "%$value%";
     }
+    $op = 'LIKE';
 
     $label = NULL;
     $clauses = array();
index 25cb120f8c7ac80630e70a9704bfa6bf55056f21..11be078fe148641d7f11979fa8dc27335596e7e1 100644 (file)
@@ -195,8 +195,6 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search {
       $specialParams = array(
         'activity_type_id',
         'status_id',
-        'activity_subject',
-        'activity_details',
       );
       $changeNames = array('status_id' => 'activity_status_id');
       CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams, $changeNames);
index b87ffbfaf21de03b6c287f962b15819037980756..67f9e997fd11b7321d877cfbc62a745e461e5abf 100644 (file)
@@ -1886,10 +1886,8 @@ class CRM_Contact_BAO_Query {
       case 'followup_parent_id':
       case 'parent_id':
       case 'source_contact_id':
-      case 'activity':
+      case 'activity_text':
       case 'activity_option':
-      case 'activity_details':
-      case 'activity_subject':
       case 'test_activities':
       case 'activity_type_id':
       case 'activity_type':
index 70bacb3df4cce43d354d4eb4ede8ce7ffa43e4b3..48fceda25df6263f79fcdcd0cd4fcf3d93ead57e 100644 (file)
@@ -96,8 +96,8 @@
 </tr>
 <tr>
   <td>
-    {$form.activity.label}<br/>
-    {$form.activity.html|crmAddClass:big}<br/>
+    {$form.activity_text.label}<br/>
+    {$form.activity_text.html|crmAddClass:big}<br/>
     {$form.activity_option.html}<br/>
   </td>
   <td colspan="2">