From baa07e3c2ba239d6f73ca6e624711791e2a0bd53 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 21 Aug 2011 13:54:23 +0200 Subject: [PATCH] Implemented the possibility to execute cronjobs --- .../install/files/acp/templates/cronjobList.tpl | 2 +- .../lib/data/cronjob/CronjobAction.class.php | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/cronjobList.tpl b/wcfsetup/install/files/acp/templates/cronjobList.tpl index 86f34533b6..b9380d81f1 100644 --- a/wcfsetup/install/files/acp/templates/cronjobList.tpl +++ b/wcfsetup/install/files/acp/templates/cronjobList.tpl @@ -25,7 +25,7 @@ if (WCF.inArray($($button).data('objectID'), data.objectIDs)) { // insert feedback here - $(row).find('td.columnNextExec').html('...'); + $(row).find('td.columnNextExec').html(data.returnValues[$($button).data('objectID')].formatted); $(row).wcfHighlight(); } }); diff --git a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php index 72f5fdfe02..4816dff890 100644 --- a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php +++ b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php @@ -2,6 +2,7 @@ namespace wcf\data\cronjob; use wcf\data\AbstractDatabaseObjectAction; use wcf\system\WCF; +use wcf\util\DateUtil; /** * Executes cronjob-related actions. @@ -94,9 +95,19 @@ class CronjobAction extends AbstractDatabaseObjectAction { * Executes cronjobs. */ public function execute() { - // TODO: implement me + $return = array(); foreach ($this->objects as $cronjob) { - + $className = $cronjob->className; + $executable = new $className(); + $executable->execute(new Cronjob($cronjob->cronjobID)); + $nextExec = $cronjob->getNextExec(); + $cronjob->update(array('nextExec' => $nextExec)); + $dateTime = DateUtil::getDateTimeByTimestamp($nextExec); + $return[$cronjob->cronjobID] = array( + 'time' => $nextExec, + 'formatted' => str_replace('%time%', DateUtil::format($dateTime, DateUtil::TIME_FORMAT), str_replace('%date%', DateUtil::format($dateTime, DateUtil::DATE_FORMAT), WCF::getLanguage()->get('wcf.global.date.dateTimeFormat'))) + ); } + return $return; } } -- 2.20.1