CRM-16019 - Expose date/time format preferences to clientside
[civicrm-core.git] / api / v3 / Generic.php
index 635ad69b4048722f59a23d39c460d9e5cd4e9415..cef725e0850aea36088db56d168fa94c52dc2348 100644 (file)
@@ -71,10 +71,10 @@ function civicrm_api3_generic_getfields($apiRequest) {
       }
     }
   }
-  $entity       = _civicrm_api_get_camel_name($apiRequest['entity']);
-  $lcase_entity = _civicrm_api_get_entity_name_from_camel($entity);
+  $entity = $apiRequest['entity'];
+  $lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
   $subentity    = CRM_Utils_Array::value('contact_type', $apiRequest['params']);
-  $action       = strtolower(CRM_Utils_Array::value('action', $apiRequest['params']));
+  $action = CRM_Utils_Array::value('action', $apiRequest['params']);
   $sequential = empty($apiRequest['params']) ? 0 : 1;
   $apiOptions = CRM_Utils_Array::value('options', $apiRequest['params'], array());
   if (!$action || $action == 'getvalue' || $action == 'getcount') {
@@ -99,13 +99,14 @@ function civicrm_api3_generic_getfields($apiRequest) {
     case 'get':
     case 'getsingle':
     case 'getcount':
+    case 'getstat':
       $metadata = _civicrm_api_get_fields($apiRequest['entity'], $unique, $apiRequest['params']);
       if (empty($metadata['id'])) {
         // if id is not set we will set it eg. 'id' from 'case_id', case_id will be an alias
         if (!empty($metadata[strtolower($apiRequest['entity']) . '_id'])) {
-          $metadata['id'] = $metadata[$lcase_entity . '_id'];
-          unset($metadata[$lcase_entity . '_id']);
-          $metadata['id']['api.aliases'] = array($lcase_entity . '_id');
+          $metadata['id'] = $metadata[$lowercase_entity . '_id'];
+          unset($metadata[$lowercase_entity . '_id']);
+          $metadata['id']['api.aliases'] = array($lowercase_entity . '_id');
         }
       }
       else {
@@ -114,7 +115,7 @@ function civicrm_api3_generic_getfields($apiRequest) {
         // (note) or setting for all api where fields is returning 'id' & we want to accept 'note_id' @ the api layer
         // nb we don't officially accept note_id anyway - rationale here is more about centralising a now-tested
         // inconsistency
-        $metadata['id']['api.aliases'] = array($lcase_entity . '_id');
+        $metadata['id']['api.aliases'] = array($lowercase_entity . '_id');
       }
       break;
 
@@ -124,7 +125,7 @@ function civicrm_api3_generic_getfields($apiRequest) {
           'title' => $entity . ' ID',
           'name' => 'id',
           'api.required' => 1,
-          'api.aliases' => array($lcase_entity . '_id'),
+          'api.aliases' => array($lowercase_entity . '_id'),
           'type' => CRM_Utils_Type::T_INT,
         ));
       break;