X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FJob.php;h=1c07ac65158f94724a257b639d7e4802dbfc019d;hb=25314c391fa95bf3af18c0060a51f3e8d5213489;hp=4cd5a444d9489308f51d4164bdb19d216b02ec7c;hpb=ba2d3c9306844ae3c3b70973810f72da4e79bec6;p=civicrm-core.git diff --git a/api/v3/Job.php b/api/v3/Job.php index 4cd5a444d9..1c07ac6515 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -3,7 +3,7 @@ /* +--------------------------------------------------------------------+ - | CiviCRM version 4.3 | + | CiviCRM version 4.4 | +--------------------------------------------------------------------+ | Copyright CiviCRM LLC (c) 2004-2013 | +--------------------------------------------------------------------+ @@ -71,17 +71,7 @@ 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'); - } - - $dao = CRM_Core_BAO_Job::create($params); - - $result = array(); - _civicrm_api3_object_to_array($dao, $result[$dao->id]); - return civicrm_api3_create_success($result, $params, 'job', 'create', $dao); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); } /** @@ -106,7 +96,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 +120,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 +149,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); @@ -181,9 +167,9 @@ function civicrm_api3_job_geocode($params) { function _civicrm_api3_job_geocode_spec(&$params) { $params['start'] = array('title' => 'Start Date'); $params['end'] = array('title' => 'End Date'); - $params['geocoding'] = array('title' => 'Is this for GeoCoding? (I think this is a 1,0 field?)'); - $params['parse'] = array('title' => 'Is this for parsing? (I think this is a 1,0 field?)'); - $params['throttle'] = array('title' => 'Throttle? (no idea what you enter in this field)'); + $params['geocoding'] = array('title' => 'Geocode address?'); + $params['parse'] = array('title' => 'Parse street address?'); + $params['throttle'] = array('title' => 'Throttle? if enabled, geocodes at a slow rate'); } /** @@ -199,14 +185,12 @@ 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)); + $result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params), $params); $lock->release(); if ($result['is_error'] == 0) { @@ -216,7 +200,20 @@ function civicrm_api3_job_send_reminder($params) { return civicrm_api3_create_error($result['messages']); } } - +/** + * Adjust metadata for "send_reminder" action + * + * The metadata is used for setting defaults, documentation & validation + * @param array $params array or parameters determined by getfields + */ +function _civicrm_api3_job_send_reminder(&$params) { + //@todo this function will now take all fields in action_schedule as params + // as it is calling the api fn to set the filters - update getfields to reflect + $params['id'] = array( + 'type' => CRM_Utils_Type::T_INT, + 'title' => 'Action Schedule ID' + ); +} /** * Execute a specific report instance and send the output via email * @@ -366,8 +363,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 +382,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 +407,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 +432,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 +458,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 +492,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 +514,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 +547,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 +555,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 +592,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');