/** * PauseJob * Handles the "pause job" process. * An addon can override this functionality to do it's own work. * If it does, it must call * * InterspireEventData::preventDefault * * to stop the default action from happening. * * The job is loaded (based on the id) before it is passed to the InterspireEvent::trigger method. * * Once either the addon does it's processing work, or the default action happens, the user is taken back to the "ManageSchedules" page. * * @param Int $jobid The job we are going to pause. * * @uses Jobs_API::PauseJob * @uses InterspireEvent::trigger * @see InterspireEventData::preventDefault * @see ManageSchedules * * @uses EventData_IEM_SCHEDULE_PAUSEJOB */ function PauseJob($jobid=0) { $jobapi = $this->GetApi('Jobs'); $jobinfo = $jobapi->LoadJob($jobid); /** * Trigger event */ $tempEventData = new EventData_IEM_SCHEDULE_PAUSEJOB(); $tempEventData->jobrecord = &$jobinfo; if (!$tempEventData->trigger()) { $this->ManageSchedules(); return; } unset($tempEventData); /** * ----- */ $result = $jobapi->PauseJob($jobid); if ($result) { $GLOBALS['Message'] = $this->PrintSuccess('JobPausedSuccess'); } else { $GLOBALS['Error'] = GetLang('JobPausedFail'); $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); } $this->ManageSchedules(); }
/** * PauseSchedule * If a scheduled job is a "splittest" type, then this will pause the schedule * and set an appropriate message in the "GLOBALS[Message]" field. * * If it's not a splittest job, then this will just return. * * @param EventData_IEM_SCHEDULE_PAUSEJOB $data The data array contains the jobtype and the jobid to process. * * @uses InterspireEventData::preventDefault() * @uses Splittest_Send_API::PauseJob() */ public static function PauseSchedule(EventData_IEM_SCHEDULE_PAUSEJOB $data) { $jobinfo =& $data->jobrecord; if ($jobinfo['jobtype'] != 'splittest') { return; } $data->preventDefault(); require_once dirname(__FILE__) . '/api/splittest_send.php'; $send_api = new Splittest_Send_API(); $paused = $send_api->PauseJob($jobinfo['jobid']); if ($paused) { FlashMessage(GetLang('Addon_splittest_Send_Paused_Success'), SS_FLASH_MSG_SUCCESS); } else { FlashMessage(GetLang('Addon_splittest_Send_Paused_Failure'), SS_FLASH_MSG_ERROR); } $GLOBALS['Message'] = GetFlashMessages(); }