Implemented the possibility to execute cronjobs
authorTim Düsterhus <timwolla@arcor.de>
Sun, 21 Aug 2011 11:54:23 +0000 (13:54 +0200)
committerTim Düsterhus <timwolla@arcor.de>
Sun, 21 Aug 2011 11:54:23 +0000 (13:54 +0200)
wcfsetup/install/files/acp/templates/cronjobList.tpl
wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php

index 86f34533b609da3650136b8891a1fdb24e4a6be9..b9380d81f1e1494fbbab2b72bcd5184ab7585724 100644 (file)
@@ -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();
                                                }
                                        });
index 72f5fdfe02bd6106e0f4280fc3f7a9fa2f9258ca..4816dff890b5511312181cd49b6828e86e052ca5 100644 (file)
@@ -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;
        }
 }