Merge pull request #3602 from yashodha/CRM-14629
[civicrm-core.git] / CRM / Core / JobManager.php
index 15e7429e14f7bd27ae1721630a9e551f973e9ef9..d41b66cf57465b8ad7e419ff04ebde1ad07a413a 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -30,7 +30,7 @@
  * by every scheduled job (cron task) in CiviCRM.
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -53,10 +53,13 @@ class CRM_Core_JobManager {
 
   /*
    * Class constructor
-   * 
+   *
    * @param void
    * @access public
-   * 
+   *
+   */
+  /**
+   *
    */
   public function __construct() {
     $config = CRM_Core_Config::singleton();
@@ -66,10 +69,13 @@ class CRM_Core_JobManager {
   }
 
   /*
-   * 
+   *
    * @param void
    * @access private
-   * 
+   *
+   */
+  /**
+   * @param bool $auth
    */
   public function execute($auth = TRUE) {
 
@@ -94,18 +100,25 @@ class CRM_Core_JobManager {
 
   /*
    * Class destructor
-   * 
+   *
    * @param void
    * @access public
-   * 
+   *
    */
   public function __destruct() {}
 
+  /**
+   * @param $entity
+   * @param $action
+   */
   public function executeJobByAction($entity, $action) {
     $job = $this->_getJob(NULL, $entity, $action);
     $this->executeJob($job);
   }
 
+  /**
+   * @param $id
+   */
   public function executeJobById($id) {
     $job = $this->_getJob($id);
     $this->executeJob($job);
@@ -141,16 +154,20 @@ class CRM_Core_JobManager {
   /*
    * Retrieves the list of jobs from the database,
    * populates class param.
-   * 
+   *
    * @param void
    * @return array ($id => CRM_Core_ScheduledJob)
    * @access private
-   * 
+   *
+   */
+  /**
+   * @return array
    */
   private function _getJobs() {
     $jobs = array();
     $dao = new CRM_Core_DAO_Job();
     $dao->orderBy('name');
+    $dao->domain_id = CRM_Core_Config::domainID();
     $dao->find();
     while ($dao->fetch()) {
       $temp = array();
@@ -163,10 +180,18 @@ class CRM_Core_JobManager {
   /*
    * Retrieves specific job from the database by id
    * and creates ScheduledJob object.
-   * 
+   *
    * @param void
    * @access private
-   * 
+   *
+   */
+  /**
+   * @param null $id
+   * @param null $entity
+   * @param null $action
+   *
+   * @return CRM_Core_ScheduledJob
+   * @throws Exception
    */
   private function _getJob($id = NULL, $entity = NULL, $action = NULL) {
     if (is_null($id) && is_null($action)) {
@@ -184,19 +209,28 @@ class CRM_Core_JobManager {
     return $job;
   }
 
+  /**
+   * @param $entity
+   * @param $job
+   * @param $params
+   * @param null $source
+   */
   public function setSingleRunParams($entity, $job, $params, $source = NULL) {
     $this->_source = $source;
     $key = strtolower($entity . '_' . $job);
     $this->singleRunParams[$key] = $params;
     $this->singleRunParams[$key]['version'] = 3;
   }
-  
+
   /*
    *
    * @return array|null collection of permissions, null if none
    * @access public
    *
    */
+  /**
+   * @param $message
+   */
   public function logEntry($message) {
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_JobLog();
@@ -230,6 +264,11 @@ class CRM_Core_JobManager {
     $dao->save();
   }
 
+  /**
+   * @param $apiResult
+   *
+   * @return string
+   */
   private function _apiResultToMessage($apiResult) {
     $status = $apiResult['is_error'] ? ts('Failure') : ts('Success');
     $msg    = CRM_Utils_Array::value('error_message', $apiResult, 'empty error_message!');
@@ -245,6 +284,11 @@ class CRM_Core_JobManager {
   }
 }
 
+/**
+ * @param $message
+ *
+ * @throws Exception
+ */
 function CRM_Core_JobManager_scheduledJobFatalErrorHandler($message) {
   throw new Exception("{$message['message']}: {$message['code']}");
 }