Esempio n. 1
0
 /**
  * Function  to delete scheduled job.
  *
  * @param $jobID
  *   ID of the job to be deleted.
  *
  * @return bool|null
  */
 public static function del($jobID)
 {
     if (!$jobID) {
         CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
     }
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $jobID;
     if (!$dao->find(TRUE)) {
         return NULL;
     }
     if ($dao->delete()) {
         return TRUE;
     }
 }
 /**
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = array();
     if (!$this->_id) {
         $defaults['is_active'] = $defaults['is_default'] = 1;
         return $defaults;
     }
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $this->_id;
     $dao->domain_id = $domainID;
     if (!$dao->find(TRUE)) {
         return $defaults;
     }
     CRM_Core_DAO::storeValues($dao, $defaults);
     /************************************
      * begin com.klangsoft.flexiblejobs *
      ************************************/
     if ($ts = CRM_Core_BAO_Setting::getItem('com.klangsoft.flexiblejobs', 'job_' . $this->_id)) {
         $defaults['schedule_at'] = date('r', $ts);
     }
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
     // CRM-10708
     // job entity thats shipped with core is all lower case.
     // this makes sure camel casing is followed for proper working of default population.
     if (!empty($defaults['api_entity'])) {
         $defaults['api_entity'] = ucfirst($defaults['api_entity']);
     }
     return $defaults;
 }
Esempio n. 3
0
 /**
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = array();
     if (!$this->_id) {
         $defaults['is_active'] = $defaults['is_default'] = 1;
         return $defaults;
     }
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $this->_id;
     $dao->domain_id = $domainID;
     if (!$dao->find(TRUE)) {
         return $defaults;
     }
     CRM_Core_DAO::storeValues($dao, $defaults);
     // CRM-17686
     if (!empty($dao->scheduled_run_date)) {
         $ts = strtotime($dao->scheduled_run_date);
         $defaults['scheduled_run_date'] = date("Y-m-d H:i:s", $ts);
     }
     // CRM-10708
     // job entity thats shipped with core is all lower case.
     // this makes sure camel casing is followed for proper working of default population.
     if (!empty($defaults['api_entity'])) {
         $defaults['api_entity'] = ucfirst($defaults['api_entity']);
     }
     return $defaults;
 }
Esempio n. 4
0
 /**
  * Retrieves specific job from the database by id.
  * and creates ScheduledJob object.
  *
  * @param int $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)) {
         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->api_entity = $entity;
     $dao->api_action = $action;
     $dao->find();
     while ($dao->fetch()) {
         CRM_Core_DAO::storeValues($dao, $temp);
         $job = new CRM_Core_ScheduledJob($temp);
     }
     return $job;
 }
Esempio n. 5
0
 function setDefaultValues()
 {
     $defaults = array();
     if (!$this->_id) {
         $defaults['is_active'] = $defaults['is_default'] = 1;
         return $defaults;
     }
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $this->_id;
     $dao->domain_id = $domainID;
     if (!$dao->find(TRUE)) {
         return $defaults;
     }
     CRM_Core_DAO::storeValues($dao, $defaults);
     // CRM-10708
     // job entity thats shipped with core is all lower case.
     // this makes sure camel casing is followed for proper working of default population.
     if (CRM_Utils_Array::value('api_entity', $defaults)) {
         $defaults['api_entity'] = ucfirst($defaults['api_entity']);
     }
     return $defaults;
 }