Merge pull request #9960 from colemanw/CRM-20029
[civicrm-core.git] / api / v3 / utils.php
index 5275ee9ce2b2064faee68472b99d2fff7f2ad048..1e78f7b80ee39c53b87c933e21ce0932841c7ca0 100644 (file)
@@ -825,8 +825,11 @@ function _civicrm_api3_get_options_from_params(&$params, $queryObject = FALSE, $
   $finalSort = array();
   $options['sort'] = NULL;
   if (!empty($sort)) {
-    foreach ((array) $sort as $s) {
-      if (CRM_Utils_Rule::mysqlOrderBy($s)) {
+    if (!is_array($sort)) {
+      $sort = array_map('trim', explode(',', $sort));
+    }
+    foreach ($sort as $s) {
+      if ($s == '(1)' || CRM_Utils_Rule::mysqlOrderBy($s)) {
         if ($entity && $action == 'get') {
           switch (trim(strtolower($s))) {
             case 'id':
@@ -1401,6 +1404,7 @@ function _civicrm_api3_basic_delete($bao_name, &$params) {
  *
  * @param array $returnArray
  *   Array to append custom data too - generally $result[4] where 4 is the entity id.
+ * @param $checkPermission
  * @param string $entity
  *   E.g membership, event.
  * @param int $entity_id
@@ -1497,12 +1501,15 @@ function _civicrm_api3_validate($entity, $action, $params) {
 
   return array($errors);
 }
+
 /**
  * Used by the Validate API.
+ * @param $fieldName
  * @param array $fieldInfo
  * @param string $entity
  * @param array $params
  *
+ * @throws API_Exception
  * @throws Exception
  */
 function _civicrm_api3_validate_switch_cases($fieldName, $fieldInfo, $entity, $params) {
@@ -1883,8 +1890,10 @@ function _civicrm_api_get_fields($entity, $unique = FALSE, &$params = array()) {
   $d = new $dao();
   $fields = $d->fields();
 
-  // Set html attributes for text fields
   foreach ($fields as $name => &$field) {
+    // Denote as core field
+    $field['is_core_field'] = TRUE;
+    // Set html attributes for text fields
     if (isset($field['html'])) {
       $field['html'] += (array) $d::makeAttribute($field);
     }
@@ -2058,7 +2067,7 @@ function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) {
  *
  * @throws API_Exception
  */
-function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $entity) {
+function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $entity) {
   list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
   if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
     return;