Example #1
0
	/**
	 * Returns timestamp of next execution.
	 * 
	 * @param	integer		$timeBase
	 * @return	integer
	 */
	public function getNextExec($timeBase = null) {
		if ($timeBase === null) {
			if ($this->lastExec) {
				$timeBase = $this->lastExec + 120;
				if ($timeBase < TIME_NOW) {
					$timeBase = TIME_NOW + 120;
				}
			}
			else {
				// first time setup
				$timeBase = TIME_NOW;
			}
		}
		
		$nextExec = CronjobUtil::calculateNextExec(
			$this->startMinute,
			$this->startHour,
			$this->startDom,
			$this->startMonth,
			$this->startDow,
			$timeBase
		);
		
		return $nextExec;
	}
 /**
  * @see	wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::validateImport()
  */
 protected function validateImport(array $data)
 {
     CronjobUtil::validate($data['startMinute'], $data['startHour'], $data['startDom'], $data['startMonth'], $data['startDow']);
 }
Example #3
0
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate class name
     if (empty($this->className)) {
         throw new UserInputException('className');
     }
     if (!class_exists($this->className)) {
         throw new UserInputException('className', 'doesNotExist');
     }
     // validate description
     if (!I18nHandler::getInstance()->validateValue('description')) {
         if (I18nHandler::getInstance()->isPlainValue('description')) {
             throw new UserInputException('description');
         } else {
             throw new UserInputException('description', 'multilingual');
         }
     }
     try {
         CronjobUtil::validate($this->startMinute, $this->startHour, $this->startDom, $this->startMonth, $this->startDow);
     } catch (SystemException $e) {
         // extract field name
         $fieldName = '';
         if (preg_match("/cronjob attribute '(.*)'/", $e->getMessage(), $match)) {
             $fieldName = $match[1];
         }
         throw new UserInputException($fieldName, 'notValid');
     }
 }
Example #4
0
 /**
  * @see wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate class name
     if (empty($this->className)) {
         throw new UserInputException('className');
     }
     if (!class_exists($this->className)) {
         throw new UserInputException('className', 'doesNotExist');
     }
     try {
         CronjobUtil::validate($this->startMinute, $this->startHour, $this->startDom, $this->startMonth, $this->startDow);
     } catch (SystemException $e) {
         // extract field name
         $fieldName = '';
         if (preg_match("/cronjob attribute '(.*)'/", $e->getMessage(), $match)) {
             $fieldName = $match[1];
         }
         throw new UserInputException($fieldName, 'notValid');
     }
 }