}
$getFieldsParams = array('action' => $apiRequest['action']);
$entity = $apiRequest['entity'];
- if ($entity == 'profile' && array_key_exists('profile_id', $apiRequest['params'])) {
+ if ($entity == 'Profile' && array_key_exists('profile_id', $apiRequest['params'])) {
$getFieldsParams['profile_id'] = $apiRequest['params']['profile_id'];
}
$fields = civicrm_api3($entity, 'getfields', $getFieldsParams);
*
* @return string
* Entity name in underscore separated format.
- *
- * @fixme Why isn't this called first thing in civicrm_api wrapper?
*/
function _civicrm_api_get_entity_name_from_camel($entity) {
- if ($entity == strtolower($entity)) {
+ if (!$entity || $entity === strtolower($entity)) {
return $entity;
}
else {
}
if ($deprecated) {
// Metadata-level deprecations or wholesale entity deprecations.
- if ($entity == 'entity' || $action == 'getactions' || is_string($deprecated)) {
+ if ($entity == 'Entity' || $action == 'getactions' || is_string($deprecated)) {
$result['deprecated'] = $deprecated;
}
// Action-specific deprecations
$name = substr($name, 13, $last - 13);
}
- $name = _civicrm_api_get_camel_name($name, 3);
+ $name = _civicrm_api_get_camel_name($name);
if ($name == 'Individual' || $name == 'Household' || $name == 'Organization') {
$name = 'Contact';
* options extracted from params
*/
function _civicrm_api3_get_options_from_params(&$params, $queryObject = FALSE, $entity = '', $action = '') {
+ // Entity should be l-case so it can be concatenated into field names
+ $entity = _civicrm_api_get_entity_name_from_camel($entity);
$is_count = FALSE;
$sort = CRM_Utils_Array::value('sort', $params, 0);
$sort = CRM_Utils_Array::value('option.sort', $params, $sort);
$config = CRM_Core_Config::singleton();
$config->userPermissionClass->permissions = array('access CiviCRM');
$result = $this->callAPIFailure('contact', 'create', $params);
- $this->assertEquals('API permission check failed for contact/create call; insufficient permission: require access CiviCRM and add contacts', $result['error_message'], 'lacking permissions should not be enough to create a contact');
+ $this->assertEquals('API permission check failed for Contact/create call; insufficient permission: require access CiviCRM and add contacts', $result['error_message'], 'lacking permissions should not be enough to create a contact');
$config->userPermissionClass->permissions = array('access CiviCRM', 'add contacts', 'import contacts');
$this->callAPISuccess('contact', 'create', $params, NULL, 'overfluous permissions should be enough to create a contact');
$config->userPermissionClass->permissions = array('access CiviCRM');
$result = $this->callAPIFailure('contact', 'update', $params);
- $this->assertEquals('API permission check failed for contact/update call; insufficient permission: require access CiviCRM and edit all contacts', $result['error_message'], 'lacking permissions should not be enough to update a contact');
+ $this->assertEquals('API permission check failed for Contact/update call; insufficient permission: require access CiviCRM and edit all contacts', $result['error_message'], 'lacking permissions should not be enough to update a contact');
$config->userPermissionClass->permissions = array(
'access CiviCRM',
$config = &CRM_Core_Config::singleton();
$config->userPermissionClass->permissions = array('access CiviCRM');
$result = $this->callAPIFailure('event', 'create', $params);
- $this->assertEquals('API permission check failed for event/create call; insufficient permission: require access CiviCRM and access CiviEvent and edit all events', $result['error_message'], 'lacking permissions should not be enough to create an event');
+ $this->assertEquals('API permission check failed for Event/create call; insufficient permission: require access CiviCRM and access CiviEvent and edit all events', $result['error_message'], 'lacking permissions should not be enough to create an event');
$config->userPermissionClass->permissions = array(
'access CiviEvent',
catch (Exception $e) {
$message = $e->getMessage();
}
- $this->assertEquals($message, 'API permission check failed for contact/create call; insufficient permission: require access CiviCRM and add contacts', 'lacking permissions should throw an exception');
+ $this->assertEquals($message, 'API permission check failed for Contact/create call; insufficient permission: require access CiviCRM and add contacts', 'lacking permissions should throw an exception');
$config->userPermissionClass->permissions = array('access CiviCRM', 'add contacts', 'import contacts');
$this->assertTrue($this->runPermissionCheck('contact', 'create', $check), 'overfluous permissions should return true');