Skip to content
Snippets Groups Projects
Commit 718b280e authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #761 from adamwight/api_autoloaded

Register and use the autoloader during API calls
parents 1da3936a 22fd1690
Branches
Tags
No related merge requests found
Showing with 3 additions and 104 deletions
......@@ -205,7 +205,6 @@ function _civicrm_api_resolve($apiRequest) {
'api/v' . $apiRequest['version'] . '/' . $camelName . '/' . $actionCamelName . '.php',
);
foreach ($stdFiles as $stdFile) {
require_once 'CRM/Utils/File.php';
if (CRM_Utils_File::isIncludable($stdFile)) {
require_once $stdFile;
if (function_exists($stdFunction)) {
......@@ -225,7 +224,6 @@ function _civicrm_api_resolve($apiRequest) {
'api/v' . $apiRequest['version'] . '/Generic/' . $actionCamelName . '.php',
);
foreach ($genericFiles as $genericFile) {
require_once 'CRM/Utils/File.php';
if (CRM_Utils_File::isIncludable($genericFile)) {
require_once $genericFile;
if (function_exists($genericFunction)) {
......@@ -261,7 +259,6 @@ function _civicrm_api_loadEntity($entity, $version = 3) {
$camelName = _civicrm_api_get_camel_name($entity, $version);
// Check for master entity file; to match _civicrm_api_resolve(), only load the first one
require_once 'CRM/Utils/File.php';
$stdFile = 'api/v' . $version . '/' . $camelName . '.php';
if (CRM_Utils_File::isIncludable($stdFile)) {
require_once $stdFile;
......
......@@ -92,9 +92,10 @@ class civicrm_api3 {
if (isset($config) && isset($config['conf_path'])) {
define('CIVICRM_SETTINGS_PATH', $config['conf_path'] . '/civicrm.settings.php');
require_once CIVICRM_SETTINGS_PATH;
require_once 'CRM/Core/Config.php';
require_once 'CRM/Core/Classloader.php';
require_once 'api/api.php';
require_once "api/v3/utils.php";
CRM_Core_Classloader::singleton()->register();
$this->cfg = CRM_Core_Config::singleton();
$this->init();
}
......
......@@ -41,11 +41,6 @@
*
*/
/**
* Include common API util functions
*/
require_once 'CRM/Core/OptionGroup.php';
/**
* Function to retrieve activity types
*
......@@ -87,7 +82,6 @@ function civicrm_api3_activity_type_create($params) {
$action = 2;
}
require_once 'CRM/Core/OptionValue.php';
$activityObject = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $action, $optionValueID);
$activityType = array();
_civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id]);
......@@ -122,7 +116,6 @@ function civicrm_api3_activity_type_delete($params) {
civicrm_api3_verify_mandatory($params, NULL, array('activity_type_id'));
$activityTypeId = $params['activity_type_id'];
require_once 'CRM/Core/BAO/OptionValue.php';
return CRM_Core_BAO_OptionValue::del($activityTypeId);
}
......
......@@ -37,8 +37,6 @@
* @version $Id: Address.php 2011-02-16 ErikHommel $
*/
require_once 'CRM/Core/BAO/Address.php';
/**
* Add an Address for a contact
*
......
......@@ -35,8 +35,6 @@
* @copyright CiviCRM LLC (c) 2004-2013
*/
require_once 'CRM/Campaign/BAO/Campaign.php';
/**
* create/update campaign
*
......
......@@ -35,7 +35,6 @@
* @copyright CiviCRM LLC (c) 2004-2013
*/
//require_once 'CRM/Campaign/BAO/ContactType.php';
require_once 'api/v3/utils.php';
/**
......@@ -53,7 +52,6 @@ require_once 'api/v3/utils.php';
* @access public
*/
function civicrm_api3_contact_type_create($params) {
require_once 'CRM/Utils/String.php';
civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name', 'parent_id'));
if (!array_key_exists('label', $params)) {
$params['label'] = $params['name'];
......
......@@ -175,8 +175,6 @@ function civicrm_api3_contribution_get($params) {
$smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params);
$inputParams = CRM_Utils_Array::value('input_params', $options, array());
$returnProperties = CRM_Utils_Array::value('return', $options, NULL);
require_once 'CRM/Contribute/BAO/Query.php';
require_once 'CRM/Contact/BAO/Query.php';
if (empty($returnProperties)) {
$returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
}
......@@ -327,13 +325,11 @@ function civicrm_api3_contribution_transact($params) {
$params['invoiceID'] = $params['invoice_id'];
}
require_once 'CRM/Financial/BAO/PaymentProcessor.php';
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($params['payment_processor_id'], $params['payment_processor_mode']);
if (civicrm_error($paymentProcessor)) {
return $paymentProcessor;
}
require_once 'CRM/Core/Payment.php';
$payment = &CRM_Core_Payment::singleton($params['payment_processor_mode'], $paymentProcessor);
if (civicrm_error($payment)) {
return $payment;
......
......@@ -33,8 +33,6 @@
* @copyright CiviCRM LLC (c) 2004-2013
*/
require_once 'CRM/Contribute/BAO/ContributionRecur.php';
/**
* Create or update a contribution_recur
*
......
......@@ -37,11 +37,6 @@
* @version $Id: CustomField.php 30879 2010-11-22 15:45:55Z shot $
*/
/**
* Files required for this package
*/
require_once 'CRM/Core/BAO/CustomField.php';
/**
* Most API functions take in associative arrays ( name => value pairs
* as parameters. Some of the most commonly used parameters are
......@@ -255,7 +250,6 @@ SELECT count(*)
'Select', 'Multi-Select', 'CheckBox', 'Radio', 'AdvMulti-Select')) &&
!isset($errors[$fieldName])
) {
require_once 'CRM/Core/OptionGroup.php';
$options = CRM_Core_OptionGroup::valuesByID($fieldDetails['option_group_id']);
if (!is_array($value)) {
$value = array($value);
......
......@@ -112,7 +112,6 @@ function civicrm_api3_custom_group_delete($params) {
$values->id = $params['id'];
$values->find(TRUE);
require_once 'CRM/Core/BAO/CustomGroup.php';
$result = CRM_Core_BAO_CustomGroup::deleteGroup($values, TRUE);
return $result ? civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting custom group');
}
......
......@@ -37,8 +37,6 @@
* @version $Id: Email.php 2011-02-16 ErikHommel $
*/
require_once 'CRM/Core/BAO/Email.php';
/**
* Add an Email for a contact
*
......
......@@ -41,12 +41,6 @@
*
*/
/**
* Files required for this package
*/
require_once 'CRM/Core/DAO/File.php';
require_once 'CRM/Core/BAO/File.php';
/**
* Create a file
*
......@@ -65,8 +59,6 @@ function civicrm_api3_file_create($params) {
$params['upload_date'] = date("Ymd");
}
require_once 'CRM/Core/DAO/File.php';
$fileDAO = new CRM_Core_DAO_File();
$properties = array('id', 'file_type_id', 'mime_type', 'uri', 'document', 'description', 'upload_date');
......@@ -117,7 +109,6 @@ function &civicrm_api3_file_update($params) {
return civicrm_api3_create_error('Required parameter missing');
}
require_once 'CRM/Core/DAO/File.php';
$fileDAO = new CRM_Core_DAO_File();
$fileDAO->id = $params['id'];
if ($fileDAO->find(TRUE)) {
......@@ -150,14 +141,12 @@ function civicrm_api3_file_delete($params) {
$check = FALSE;
require_once 'CRM/Core/DAO/EntityFile.php';
$entityFileDAO = new CRM_Core_DAO_EntityFile();
$entityFileDAO->file_id = $params['id'];
if ($entityFileDAO->find()) {
$check = $entityFileDAO->delete();
}
require_once 'CRM/Core/DAO/File.php';
$fileDAO = new CRM_Core_DAO_File();
$fileDAO->id = $params['id'];
if ($fileDAO->find(TRUE)) {
......@@ -165,4 +154,4 @@ function civicrm_api3_file_delete($params) {
}
return $check ? NULL : civicrm_api3_create_error('Error while deleting a file.');
}
\ No newline at end of file
}
......@@ -39,7 +39,6 @@ function civicrm_api3_generic_setValue($apiRequest) {
case 2:
//string
require_once ("CRM/Utils/Rule.php");
if (!CRM_Utils_Rule::xssString($value)) {
return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), array('error_code' => 'XSS'));
}
......
......@@ -35,8 +35,6 @@
* @copyright CiviCRM LLC (c) 2004-2013
*/
require_once 'CRM/Grant/BAO/Grant.php';
/**
* create/update grant
*
......
......@@ -36,11 +36,6 @@
* @version $Id: Group.php 30171 2010-10-14 09:11:27Z mover $
*/
/**
* Include utility functions
*/
require_once 'CRM/Contact/BAO/Group.php';
/**
* create/update group
*
......
......@@ -38,8 +38,6 @@
*
*/
require_once 'CRM/Contact/BAO/GroupNesting.php';
/**
* Provides group nesting record(s) given parent and/or child id.
*
......
......@@ -39,8 +39,6 @@
*/
require_once 'CRM/Contact/BAO/GroupOrganization.php';
/**
* This API will give list of the groups for particular contact
* Particualr status can be sent in params array
......
......@@ -71,8 +71,6 @@ function _civicrm_api3_job_create_spec(&$params) {
* {@schema Core/Job.xml}
*/
function civicrm_api3_job_create($params) {
require_once 'CRM/Utils/Rule.php';
if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) {
return civicrm_api3_create_error('Invalid value for job ID');
}
......@@ -106,7 +104,6 @@ function civicrm_api3_job_get($params) {
* @access public
*/
function civicrm_api3_job_delete($params) {
require_once 'CRM/Utils/Rule.php';
if ($params['id'] != NULL && !CRM_Utils_Rule::integer($params['id'])) {
return civicrm_api3_create_error('Invalid value for job ID');
}
......@@ -131,7 +128,6 @@ function civicrm_api3_job_delete($params) {
*
*/
function civicrm_api3_job_execute($params) {
require_once 'CRM/Core/JobManager.php';
$facility = new CRM_Core_JobManager();
$facility->execute(FALSE);
......@@ -161,8 +157,6 @@ function _civicrm_api3_job_execute_spec(&$params) {
*
*/
function civicrm_api3_job_geocode($params) {
require_once 'CRM/Utils/Address/BatchUpdate.php';
$gc = new CRM_Utils_Address_BatchUpdate($params);
......@@ -199,13 +193,11 @@ function _civicrm_api3_job_geocode_spec(&$params) {
*
*/
function civicrm_api3_job_send_reminder($params) {
require_once 'CRM/Core/Lock.php';
$lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
require_once 'CRM/Core/BAO/ActionSchedule.php';
$result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params));
$lock->release();
......@@ -366,8 +358,6 @@ function civicrm_api3_job_process_sms($params) {
* Job to get mail responses from civimailing
*/
function civicrm_api3_job_fetch_bounces($params) {
require_once 'CRM/Utils/Mail/EmailProcessor.php';
require_once 'CRM/Core/Lock.php';
$lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
......@@ -387,8 +377,6 @@ function civicrm_api3_job_fetch_bounces($params) {
* Job to get mail and create activities
*/
function civicrm_api3_job_fetch_activities($params) {
require_once 'CRM/Utils/Mail/EmailProcessor.php';
require_once 'CRM/Core/Lock.php';
$lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
......@@ -414,7 +402,6 @@ function civicrm_api3_job_fetch_activities($params) {
* @access public
*/
function civicrm_api3_job_process_participant($params) {
require_once 'CRM/Event/BAO/ParticipantStatusType.php';
$result = CRM_Event_BAO_ParticipantStatusType::process($params);
if (!$result['is_error']) {
......@@ -440,13 +427,11 @@ function civicrm_api3_job_process_participant($params) {
* @access public
*/
function civicrm_api3_job_process_membership($params) {
require_once 'CRM/Core/Lock.php';
$lock = new CRM_Core_Lock('civimail.job.updateMembership');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
require_once 'CRM/Member/BAO/Membership.php';
$result = CRM_Member_BAO_Membership::updateAllMembershipStatus();
$lock->release();
......@@ -468,7 +453,6 @@ function civicrm_api3_job_process_membership($params) {
* @access public
*/
function civicrm_api3_job_process_respondent($params) {
require_once 'CRM/Campaign/BAO/Survey.php';
$result = CRM_Campaign_BAO_Survey::releaseRespondent($params);
if ($result['is_error'] == 0) {
......@@ -503,7 +487,6 @@ function civicrm_api3_job_process_batch_merge($params) {
$mode = CRM_Utils_Array::value('mode', $params, 'safe');
$autoFlip = CRM_Utils_Array::value('auto_flip', $params, TRUE);
require_once 'CRM/Dedupe/Merger.php';
$result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, $mode, $autoFlip);
if ($result['is_error'] == 0) {
......@@ -526,8 +509,6 @@ function civicrm_api3_job_process_batch_merge($params) {
*/
function civicrm_api3_job_run_payment_cron($params) {
require_once 'CRM/Core/Payment.php';
// live mode
CRM_Core_Payment::handlePaymentMethod(
'PaymentCron',
......@@ -561,8 +542,6 @@ function civicrm_api3_job_run_payment_cron($params) {
* @access public
*/
function civicrm_api3_job_cleanup( $params ) {
require_once 'CRM/Utils/Array.php';
$session = CRM_Utils_Array::value( 'session' , $params, true );
$tempTable = CRM_Utils_Array::value( 'tempTables', $params, true );
$jobLog = CRM_Utils_Array::value( 'jobLog' , $params, true );
......@@ -571,7 +550,6 @@ function civicrm_api3_job_cleanup( $params ) {
$memCache = CRM_Utils_Array::value( 'memCache' , $params, false );
if ( $session || $tempTable || $prevNext ) {
require_once 'CRM/Core/BAO/Cache.php';
CRM_Core_BAO_Cache::cleanup( $session, $tempTable, $prevNext );
}
......@@ -609,7 +587,6 @@ function civicrm_api3_job_disable_expired_relationships($params) {
* and use the cache
*/
function civicrm_api3_job_group_rebuild( $params ) {
require_once 'CRM/Core/Lock.php';
$lock = new CRM_Core_Lock('civimail.job.groupRebuild');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
......
......@@ -38,19 +38,6 @@
*
*/
/**
* Files required for this package
*/
require_once 'CRM/Contact/BAO/Group.php';
require_once 'CRM/Mailing/Event/BAO/Queue.php';
require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
require_once 'CRM/Mailing/Event/BAO/Unsubscribe.php';
require_once 'CRM/Mailing/Event/BAO/Resubscribe.php';
require_once 'CRM/Mailing/Event/BAO/TrackableURLOpen.php';
/**
* Handle an unsubscribe event
* @deprecated
......@@ -101,15 +88,11 @@ function civicrm_api3_mailing_group_event_subscribe($params) {
function civicrm_api3_mailing_group_getfields($params) {
$dao = _civicrm_api3_get_DAO('Subscribe');
$file = str_replace('_', '/', $dao) . ".php";
require_once ($file);
$d = new $dao();
$fields = $d->fields();
$d->free();
$dao = _civicrm_api3_get_DAO('Unsubscribe');
$file = str_replace('_', '/', $dao) . ".php";
require_once ($file);
$d = new $dao();
$fields = $fields + $d->fields();
$d->free();
......
......@@ -38,13 +38,6 @@
* @version $Id: MembershipContact.php 30171 2010-10-14 09:11:27Z mover $
*/
/**
* Files required for this package
*/
require_once 'CRM/Utils/Rule.php';
require_once 'CRM/Utils/Array.php';
/**
* Deletes an existing contact membership
*
......@@ -331,7 +324,6 @@ function _civicrm_api3_membership_format_params($params, &$values, $create = FAL
*/
function _civicrm_api3_membership_get_customv2behaviour(&$params, $contactID, $membershipTypeId, $activeOnly ){
// get the membership for the given contact ID
require_once 'CRM/Member/BAO/Membership.php';
$membershipParams = array( 'contact_id' => $contactID );
if ( $membershipTypeId ) {
$membershipParams['membership_type_id'] = $membershipTypeId;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment