Merge pull request #5209 from davecivicrm/CRM-15958
[civicrm-core.git] / api / v3 / utils.php
index 6f5f3782b03229872a4e67e71b5583eb385125ca..988016a1f38fec78f83d9bdab1c2ecf257c2e5c5 100644 (file)
  */
 
 /**
- * File for CiviCRM APIv3 utilitity functions
+ * CiviCRM APIv3 utility functions.
  *
  * @package CiviCRM_APIv3
- * @subpackage API_utils
- *
- * @copyright CiviCRM LLC (c) 2004-2014
- * @version $Id: utils.php 30879 2010-11-22 15:45:55Z shot $
  */
 
 /**
@@ -527,6 +523,10 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti
     $returnProperties = NULL;
   }
 
+  if (substr($sort, 0, 2) == 'id') {
+    $sort = $entity . "_" . $sort;
+  }
+
   $newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
   foreach ($newParams as &$newParam) {
     if ($newParam[1] == '='  && is_array($newParam[2])) {
@@ -538,7 +538,6 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti
         $newParam[2] = $sqlFilter;
       }
     }
-
   }
 
   $skipPermissions = !empty($params['check_permissions']) ? 0 : 1;
@@ -1634,7 +1633,7 @@ function _civicrm_api3_validate_unique_key(&$params, &$fieldName) {
  * Replace the old set of entities (matching some given keys) with a new set of
  * entities (matching the same keys).
  *
- * Note: This will verify that 'values' is present, but it does not directly verify
+ * @note This will verify that 'values' is present, but it does not directly verify
  * any other parameters.
  *
  * @param string $entity