CRM-20144 move special handling to API layer from BAO
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 21 Feb 2017 21:17:17 +0000 (08:17 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 21 Feb 2017 21:21:10 +0000 (08:21 +1100)
remove accidentally generated files

CRM/Contact/BAO/Query.php
api/v3/Contact.php

index fe4a03b77bcf9679de974c4f08a8520da647a819..e4c08ed9b71e6f409f5965926f8ec1ffe5e8ab41 100644 (file)
@@ -2942,18 +2942,6 @@ class CRM_Contact_BAO_Query {
 
     $regularGroupIDs = $smartGroupIDs = array();
     foreach ((array) $value as $id) {
-      if (!is_numeric($id)) {
-        $check = civicrm_api3('group', 'get', array('name' => $id, 'options' => array('limit' => 1), 'sequential' => 1));
-        if (!empty($check['values'])) {
-          $id = $check['values'][0]['id'];
-        }
-        else {
-          $check = civicrm_api3('group', 'get', array('title' => $id, 'options' => array('limit' => 1), 'sequential' => 1));
-          if (!empty($check['values'])) {
-            $id = $check['values'][0]['id'];
-          }
-        }
-      }
       if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $id, 'saved_search_id')) {
         $smartGroupIDs[] = $id;
       }
index af3028d59c1e66dff29d88138dd2efe34a9373ec..7dacabf067dac711e60fb91c808fd721242d776a 100644 (file)
@@ -376,6 +376,29 @@ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) {
     unset($params['filter.group_id']);
     $options['input_params']['group'] = $groups;
   }
+  if (isset($params['group'])) {
+    $groups = $params['group'];
+    $allGroups = CRM_Core_PseudoConstant::group();
+    if (is_array($groups) && in_array(key($groups), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+      $groupsArray = $groups[key($groups)];
+      foreach ($groupsArray as $group => &$ignore) {
+        if (!is_numeric($group) && array_search($group, $allGroups)) {
+          $group = array_search($group, $allGroups);
+        }
+      }
+    }
+    elseif (is_array($groups)) {
+      foreach ($groups as $k => &$group) {
+        if (array_search($group, $allGroups)) {
+          $group = array_search($group, $allGroups);
+        }
+      }
+    }
+    elseif (!is_numeric($groups) &&  array_search($groups, $allGroups)) {
+      $groups = array_search($groups, $allGroups);
+    }
+    $params['group'] = $groups;
+  }
 }
 
 /**