Merge remote-tracking branch 'origin/4.5' into 4.5-master-2015-02-24-17-24-05
[civicrm-core.git] / api / v3 / Generic.php
index 4dc53d259df4d052f2f43748cfaefb7cd075d257..7344f1b2d1c9430130bfa6873c087598d17da042 100644 (file)
@@ -1,4 +1,33 @@
 <?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * @package CiviCRM_APIv3
+ */
 
 /**
  * Get information about fields for a given api request.
@@ -42,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') {
@@ -74,9 +103,9 @@ function civicrm_api3_generic_getfields($apiRequest) {
       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 {
@@ -85,7 +114,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;
 
@@ -95,7 +124,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;