<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
* This interface defines methods that need to be implemented
var $_source = NULL;
- /*
- * Class constructor
- *
- * @param void
- * @access public
- *
- */
/**
+ * Class constructor.
*
+ * @return void
*/
public function __construct() {
$config = CRM_Core_Config::singleton();
$this->jobs = $this->_getJobs();
}
- /*
- *
- * @param void
- * @access private
- *
- */
/**
* @param bool $auth
*/
$this->logEntry('Finishing scheduled jobs execution.');
}
- /*
- * Class destructor
- *
- * @param void
- * @access public
- *
+ /**
+ * Class destructor.
*/
- public function __destruct() {}
+ public function __destruct() {
+ }
/**
* @param $entity
}
/**
- * @param $id
+ * @param int $id
*/
public function executeJobById($id) {
$job = $this->_getJob($id);
try {
$result = civicrm_api($job->api_entity, $job->api_action, $params);
}
- catch(Exception$e) {
+ catch (Exception$e) {
$this->logEntry('Error while executing ' . $job->name . ': ' . $e->getMessage());
}
$this->logEntry('Finished execution of ' . $job->name . ' with result: ' . $this->_apiResultToMessage($result));
$this->currentJob = FALSE;
}
- /*
+ /**
* Retrieves the list of jobs from the database,
* populates class param.
*
- * @param void
- * @return array ($id => CRM_Core_ScheduledJob)
- * @access private
- *
- */
- /**
* @return array
+ * ($id => CRM_Core_ScheduledJob)
*/
private function _getJobs() {
$jobs = array();
return $jobs;
}
- /*
- * Retrieves specific job from the database by id
+ /**
+ * Retrieves specific job from the database by id.
* and creates ScheduledJob object.
*
- * @param void
- * @access private
- *
- */
- /**
- * @param null $id
+ * @param int $id
* @param null $entity
* @param null $action
*
if (is_null($id) && is_null($action)) {
CRM_Core_Error::fatal('You need to provide either id or name to use this method');
}
- $dao = new CRM_Core_DAO_Job();
- $dao->id = $id;
+ $dao = new CRM_Core_DAO_Job();
+ $dao->id = $id;
$dao->api_entity = $entity;
$dao->api_action = $action;
$dao->find();
$this->singleRunParams[$key]['version'] = 3;
}
- /*
- *
- * @return array|null collection of permissions, null if none
- * @access public
- *
- */
/**
- * @param $message
+ * @param string $message
+ *
+ * @return void
+ * collection of permissions, null if none
*/
public function logEntry($message) {
$domainID = CRM_Core_Config::domainID();
$dao->description .= " (...)";
}
if ($this->currentJob) {
- $dao->job_id = $this->currentJob->id;
- $dao->name = $this->currentJob->name;
- $dao->command = ts("Entity:") . " " + $this->currentJob->api_entity + " " . ts("Action:") . " " + $this->currentJob->api_action;
- $data = "";
+ $dao->job_id = $this->currentJob->id;
+ $dao->name = $this->currentJob->name;
+ $dao->command = ts("Entity:") . " " . $this->currentJob->api_entity . " " . ts("Action:") . " " . $this->currentJob->api_action;
+ $data = "";
if (!empty($this->currentJob->parameters)) {
$data .= "\n\nParameters raw (from db settings): \n" . $this->currentJob->parameters;
}
*/
private function _apiResultToMessage($apiResult) {
$status = $apiResult['is_error'] ? ts('Failure') : ts('Success');
- $msg = CRM_Utils_Array::value('error_message', $apiResult, 'empty error_message!');
- $vals = CRM_Utils_Array::value('values', $apiResult, 'empty values!');
+ $msg = CRM_Utils_Array::value('error_message', $apiResult, 'empty error_message!');
+ $vals = CRM_Utils_Array::value('values', $apiResult, 'empty values!');
if (is_array($msg)) {
$msg = serialize($msg);
}
$message = $apiResult['is_error'] ? ', Error message: ' . $msg : " (" . $vals . ")";
return $status . $message;
}
+
}
/**
function CRM_Core_JobManager_scheduledJobFatalErrorHandler($message) {
throw new Exception("{$message['message']}: {$message['code']}");
}
-