コード例 #1
0
	/**
	 * ResumeJob
	 * Handles the "resume 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 resume.
	 *
	 * @uses Jobs_API::ResumeJob()
	 * @see InterspireEventData::preventDefault
	 * @see ManageSchedules
	 *
	 * @uses EventData_IEM_SCHEDULE_RESUMEJOB
	 */
	function ResumeJob($jobid=0)
	{
		$jobapi = $this->GetApi('Jobs');
                $jobinfo = $jobapi->LoadJob($jobid);
                $queueid = $jobapi->GetJobQueue($jobid);
                if($queueid !== false){
                    $statapi = $this->GetApi('Stats');
                    $subapi = $this->GetApi('Subscribers');
                    $user = GetUser();
                    $original_queuesize = $jobinfo['jobdetails']['SendSize'];
                    $real_queuesize = $subapi->QueueSize($queueid, 'send');
                    $check_stats = $statapi->ReCheckUserStats($user, $original_queuesize, $real_queuesize, AdjustTime());
                    list($ok_to_send, $not_ok_to_send_reason) = $check_stats;
                    if (!$ok_to_send) {
                            trigger_error(__CLASS__ . '::' . __METHOD__ . " -- ".GetLang($not_ok_to_send_reason),E_USER_WARNING);
                            $jobapi->PauseJob($jobid);
                            $jobapi->UnapproveJob($jobid);
                            $this->ManageSchedules();
                            return;
                    }
                }

		/**
		 * Trigger event
		 */
			$tempEventData = new EventData_IEM_SCHEDULE_RESUMEJOB();
			$tempEventData->jobrecord = &$jobinfo;

			if (!$tempEventData->trigger()) {
				$this->ManageSchedules();
				return;
			}

			unset($tempEventData);
		/**
		 * -----
		 */

		$result = $jobapi->ResumeJob($jobid);
		if ($result) {
			$GLOBALS['Message'] = $this->PrintSuccess('JobResumedSuccess');
		} else {
			$GLOBALS['Error'] = GetLang('JobResumedFail');
			$GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);
		}
		$this->ManageSchedules();
	}
コード例 #2
0
ファイル: splittest.php プロジェクト: hungnv0789/vhtm
 /**
  * ResumeSchedule
  * If a scheduled job is a "splittest" type, then this will resume 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_RESUMEJOB $data The data array contains the jobtype and the jobid to process.
  *
  * @uses InterspireEventData::preventDefault()
  * @uses Splittest_Send_API::ResumeJob()
  */
 public static function ResumeSchedule(EventData_IEM_SCHEDULE_RESUMEJOB $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();
     $resumed = $send_api->ResumeJob($jobinfo['jobid']);
     if ($resumed) {
         FlashMessage(GetLang('Addon_splittest_Send_Resumed_Success'), SS_FLASH_MSG_SUCCESS);
     } else {
         FlashMessage(GetLang('Addon_splittest_Send_Resumed_Failure'), SS_FLASH_MSG_ERROR);
     }
     $GLOBALS['Message'] = GetFlashMessages();
 }