public function getManager() { if (!is_object($this->manager)) { $this->manager = rex_cronjob_manager::factory(); } return $this->manager; }
function save() { $return = parent::save(); $manager = rex_cronjob_manager::factory(); $manager->saveNextTime(); return $return; }
function rex_a630_extension($params) { global $REX; if (!$REX['REDAXO'] || !in_array($REX['PAGE'], array('setup', 'login', 'cronjob'))) { $manager = rex_cronjob_manager::factory(); $manager->check(); } }
function save() { if ($this->isEditMode()) { $nexttime =& $this->getElement($this->mainFieldset, 'nexttime'); if ($nexttime->getValue() != 0) { $interval =& $this->getElement($this->mainFieldset, 'interval'); $nexttime->setValue(rex_cronjob_manager_sql::calculateNextTime($interval->getValue())); } } $return = parent::save(); $manager = rex_cronjob_manager::factory(); $manager->saveNextTime(); return $return; }
} $field = $form->addSelectField('status'); $field->setLabel($this->i18n('status')); $select = $field->getSelect(); $select->setSize(1); $select->addOption($this->i18n('status_activated'), 1); $select->addOption($this->i18n('status_deactivated'), 0); if ($func == 'add') { $select->setSelected(1); } $field = $form->addSelectField('type'); $field->setLabel($this->i18n('type')); $select = $field->getSelect(); $select->setSize(1); $typeFieldId = $field->getAttribute('id'); $types = rex_cronjob_manager::getTypes(); $cronjobs = []; foreach ($types as $class) { $cronjob = rex_cronjob::factory($class); if ($cronjob instanceof rex_cronjob) { $cronjobs[$class] = $cronjob; $select->addOption($cronjob->getTypeName(), $class); } } if ($func == 'add') { $select->setSelected('rex_cronjob_phpcode'); } $activeType = $field->getValue(); if ($func != 'add' && !in_array($activeType, $types)) { if (!$activeType && !$field->getValue()) { $warning = rex_i18n::rawMsg('cronjob_not_found');
<?php if (rex_addon::get('cronjob')->isAvailable()) { rex_cronjob_manager::registerType('rex_cronjob_export'); }
function rex_cronjob_manager_sql($manager = null) { $this->sql = rex_sql::factory(); // $this->sql->debugsql = true; if (is_a($manager, 'rex_cronjob_manager')) { $this->manager = $manager; } else { $this->manager = rex_cronjob_manager::factory(); } }
<?php /** * Cronjob Addon. * * @author gharlan[at]web[dot]de Gregor Harlan * * @package redaxo5 * * @var rex_addon $this */ define('REX_CRONJOB_LOG_FOLDER', $this->getDataPath()); define('REX_CRONJOB_TABLE', rex::getTable('cronjob')); rex_extension::register('PACKAGES_INCLUDED', function () { foreach ($this->getAvailablePlugins() as $plugin) { if (($type = $plugin->getProperty('cronjob_type')) != '') { rex_cronjob_manager::registerType($type); } } }); $nexttime = $this->getConfig('nexttime', 0); if ($nexttime != 0 && time() >= $nexttime) { $EP = rex::isBackend() ? 'PAGE_CHECKED' : 'PACKAGES_INCLUDED'; rex_extension::register($EP, function () { if (!rex::isBackend() || !in_array(rex_be_controller::getCurrentPagePart(1), ['setup', 'login', 'cronjob'])) { rex_cronjob_manager_sql::factory()->check(); } }); }
<?php /** * Cronjob Addon. * * @author gharlan[at]web[dot]de Gregor Harlan * * @package redaxo5 * * @var rex_addon $this */ define('REX_CRONJOB_LOG_FOLDER', $this->getDataPath()); define('REX_CRONJOB_TABLE', rex::getTable('cronjob')); rex_extension::register('PACKAGES_INCLUDED', function () { foreach ($this->getAvailablePlugins() as $plugin) { if (($type = $plugin->getProperty('cronjob_type')) != '') { rex_cronjob_manager::registerType($type); } } }); $nexttime = $this->getConfig('nexttime', 0); if ($nexttime != 0 && time() >= $nexttime) { $env = rex_cronjob_manager::getCurrentEnvironment(); $EP = 'backend' === $env ? 'PAGE_CHECKED' : 'PACKAGES_INCLUDED'; rex_extension::register($EP, function () use($env) { if ('backend' !== $env || !in_array(rex_be_controller::getCurrentPagePart(1), ['setup', 'login', 'cronjob'])) { rex_cronjob_manager_sql::factory()->check(); } }); }
public function tryExecute($id, $log = true) { $sql = rex_sql::factory(); $jobs = $sql->getArray(' SELECT id, name, type, parameters, `interval` FROM ' . REX_CRONJOB_TABLE . ' WHERE id = ? AND environment LIKE ? LIMIT 1 ', [$id, '%|' . rex_cronjob_manager::getCurrentEnvironment() . '|%']); if (!$jobs) { $this->getManager()->setMessage('Cronjob not found in database'); $this->saveNextTime(); return false; } return $this->tryExecuteJob($jobs[0], $log); }