*/
/**
- * new version of civicrm apis. See blog post at
+ * new version of civicrm APIs. See blog post at
* http://civicrm.org/node/131
- * @todo Write sth
*
* @package CiviCRM_APIv3
* @subpackage API_Job
* @return array
* API Result Array
*/
-function civicrm_api3_job_execute($params) {
+function civicrm_api3_job_execute(/** @noinspection PhpUnusedParameterInspection */
+ $params) {
$facility = new CRM_Core_JobManager();
$facility->execute(FALSE);
$params['end'] = array('title' => 'End Date');
$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');
+ $params['throttle'] = array('title' => 'Throttle? if enabled, geo-codes at a slow rate');
}
/**
*
* @param array $params
*
- * @return boolean
- * true if success, else false
+ * @return array
*/
function civicrm_api3_job_update_greeting($params) {
-
if (isset($params['ct']) && isset($params['gt'])) {
- $ct = $gt = array();
$ct = explode(',', $params['ct']);
$gt = explode(',', $params['gt']);
foreach ($ct as $ctKey => $ctValue) {
foreach ($gt as $gtKey => $gtValue) {
$params['ct'] = trim($ctValue);
$params['gt'] = trim($gtValue);
- $result[] = CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
+ CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
}
}
}
else {
- $result = CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
- }
-
- foreach ($result as $resultKey => $resultValue) {
- if ($resultValue['is_error'] == 0) {
- //really we should rely on the exception mechanism here - but we need to test that before removing this line
- return civicrm_api3_create_success();
- }
- else {
- return civicrm_api3_create_error($resultValue['messages']);
- }
+ CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
}
+ return civicrm_api3_create_success();
}
/**
}
/**
- * Job to get mail responses from civimailing
+ * Job to get mail responses from civiMailing
*
* @param array $params
*
* @return boolean
* true if success, else false
*/
-function civicrm_api3_job_process_membership($params) {
+function civicrm_api3_job_process_membership(/** @noinspection PhpUnusedParameterInspection */
+ $params) {
$lock = new CRM_Core_Lock('civimail.job.updateMembership');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another Membership Processing process is running');
}
/**
- * This api checks and updates the status of all survey respondants.
+ * This api checks and updates the status of all survey respondents.
*
* @param array $params
* (reference ) input parameters.
* @param array $params
* Input parameters.
*
- * Allowed @params array keys are:
- * {int $rgid rule group id}
- * {int $gid group id}
- * {string mode helps decide how to behave when there are conflicts.
- * A 'safe' value skips the merge if there are no conflicts. Does a force merge otherwise.}
- * {boolean auto_flip wether to let api decide which contact to retain and which to delete.}
- *
* @return array
* API Result Array
*
}
}
+/**
+ * @param $params
+ */
+function _civicrm_api3_job_process_batch_merge_spec(&$params) {
+ $params['rgid'] = array(
+ 'title' => 'rule group id',
+ 'type' => CRM_Utils_Type::T_INT,
+ );
+ $params['gid'] = array(
+ 'title' => 'group id',
+ 'type' => CRM_Utils_Type::T_INT,
+ );
+ $params['mode'] = array(
+ 'title' => 'Mode',
+ 'description' => 'helps decide how to behave when there are conflicts.
+ A \'safe\' value skips the merge if there are no conflicts.
+ Does a force merge otherwise.',
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
+ $params['auto_flip'] = array(
+ 'title' => 'Auto Flip',
+ 'description' => 'let the api decide which contact to retain and which to delete?',
+ 'type' => CRM_Utils_Type::T_BOOLEAN,
+ );
+}
+
/**
* Runs handlePaymentCron method in the specified payment processor
*
/**
* Set expired relationships to disabled.
- *
- * @param array $params
- *
+ * @param $params
* @return array
+ * @throws \API_Exception
*/
-function civicrm_api3_job_disable_expired_relationships($params) {
+function civicrm_api3_job_disable_expired_relationships(/** @noinspection PhpUnusedParameterInspection */
+ $params) {
$result = CRM_Contact_BAO_Relationship::disableExpiredRelationships();
- if ($result) {
- return civicrm_api3_create_success();
- }
- else {
- return civicrm_api3_create_error('Failed to disable all expired relationships.');
+ if (!$result) {
+ throw new API_Exception('Failed to disable all expired relationships.');
}
+ return civicrm_api3_create_success();
}
/**
* and use the cache
*
* @param array $params
- *
* @return array
+ * @throws \API_Exception
*/
function civicrm_api3_job_group_rebuild($params) {
$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');
+ throw new API_Exception('Could not acquire lock, another EmailProcessor process is running');
}
$limit = CRM_Utils_Array::value('limit', $params, 0);