* Initialize CiviCRM - should be run at the start of each API function
*/
function _civicrm_api3_initialize() {
- require_once 'CRM/Core/Config.php';
- $config = CRM_Core_Config::singleton();
- }
+ require_once 'CRM/Core/ClassLoader.php';
+ CRM_Core_ClassLoader::singleton()->register();
+ CRM_Core_Config::singleton();
+}
/**
* Wrapper Function for civicrm_verify_mandatory to make it simple to pass either / or fields for checking
}
//if ( array_key_exists ('debug',$params) && is_object ($dao)) {
if (is_array($params) && array_key_exists('debug', $params)) {
- if (!is_object($dao)) {
- $d = _civicrm_api3_get_DAO(CRM_Utils_Array::value('entity', $params));
- if (!empty($d)) {
- $file = str_replace('_', '/', $d) . ".php";
- require_once ($file);
- $dao = new $d();
- }
- }
if (is_string($action) && $action != 'getfields') {
$apiFields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => $action) + $params);
}
if (empty($dao)) {
return FALSE;
}
- $file = str_replace('_', '/', $dao) . ".php";
- require_once ($file);
$d = new $dao();
return $d;
}
if(strtolower($name) == 'im'){
return 'CRM_Core_BAO_IM';
}
- if(strtolower($name) == 'group'){
- // CRM-12628
- //@todo we have to do this because the naming convention of MailingGroup is
- // wrong & it clobbers group
- return 'CRM_Contact_BAO_Group';
- }
-
- if(strtolower($name) == 'mailing_group' || $name == 'MailingGroup'){
- // CRM-12628
- return 'CRM_Mailing_BAO_Group';
- }
return CRM_Core_DAO_AllCoreTables::getFullName(_civicrm_api_get_camel_name($name, 3));
}
return TRUE;
}
- require_once 'CRM/Core/Permission.php';
-
require_once 'CRM/Core/DAO/permissions.php';
$permissions = _civicrm_api3_permissions($entity, $action, $params);
*
*/
function _civicrm_api3_custom_data_get(&$returnArray, $entity, $entity_id, $groupID = NULL, $subType = NULL, $subName = NULL) {
- require_once 'CRM/Core/BAO/CustomGroup.php';
- require_once 'CRM/Core/BAO/CustomField.php';
$groupTree = &CRM_Core_BAO_CustomGroup::getTree($entity,
CRM_Core_DAO::$_nullObject,
$entity_id,
//field is of type date or datetime
_civicrm_api3_validate_date($params, $fieldname, $fieldInfo);
break;
- case 32://blob
+
+ case 32://blob
_civicrm_api3_validate_html($params, $fieldname, $fieldInfo);
break;
- case CRM_Utils_Type::T_STRING:
+ case CRM_Utils_Type::T_STRING:
_civicrm_api3_validate_string($params, $fieldname, $fieldInfo);
break;
* @param array $fieldinfo array of fields from getfields function
*/
function _civicrm_api3_validate_constraint(&$params, &$fieldname, &$fieldInfo) {
- $file = str_replace('_', '/', $fieldInfo['FKClassName']) . ".php";
- require_once ($file);
$dao = new $fieldInfo['FKClassName'];
$dao->id = $params[$fieldname];
$dao->selectAdd();
*/
function _civicrm_api3_generic_replace($entity, $params) {
- require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
try {
if (!is_array($params['values'])) {
if (empty($dao)) {
return array();
}
- $file = str_replace('_', '/', $dao) . ".php";
- require_once ($file);
$d = new $dao();
$fields = $d->fields();
// replace uniqueNames by the normal names as the key
* fields are prefixed with 'custom_' to represent api params
*/
function _civicrm_api_get_custom_fields($entity, &$params) {
- require_once 'CRM/Core/BAO/CustomField.php';
$customfields = array();
$entity = _civicrm_api_get_camel_name($entity);
if (strtolower($entity) == 'contact') {
$session = &CRM_Core_Session::singleton();
$params[$fieldname] = $session->get('userID');
}
- if (CRM_Utils_Array::value('pseudoconstant', $fieldInfo) ) {
+ if (!empty($fieldInfo['options'])) {
$constant = CRM_Utils_Array::value('options', $fieldInfo);
if (is_numeric($params[$fieldname]) && !CRM_Utils_Array::value('FKClassName',$fieldInfo) && !array_key_exists($params[$fieldname], $fieldInfo['options'])) {
throw new API_Exception("$fieldname is not valid", 2001, array('error_field' => $fieldname,"type"=>"integer"));