From: Marcel Werk Date: Wed, 30 May 2012 20:57:09 +0000 (+0200) Subject: Added cronjob execution X-Git-Tag: 2.0.0_Beta_1~1092 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b8050a71de7af05a1c2fcde5ab9ab74ba2bba42d;p=GitHub%2FWoltLab%2FWCF.git Added cronjob execution --- diff --git a/com.woltlab.wcf/template/headInclude.tpl b/com.woltlab.wcf/template/headInclude.tpl index e5070bb11a..50da11794e 100644 --- a/com.woltlab.wcf/template/headInclude.tpl +++ b/com.woltlab.wcf/template/headInclude.tpl @@ -86,6 +86,20 @@ WCF.Dropdown.init(); {event name='javascriptInit'} + + {if $executeCronjobs} + new WCF.Action.Proxy({ + autoSend: true, + data: { + className: 'wcf\\data\\cronjob\\CronjobAction', + actionName: 'executeCronjobs' + }, + showLoadingOverlay: false, + failure: function() { + return false; + } + }); + {/if} }); //]]> diff --git a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php index b2406050c6..e01e957715 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\cronjob\log\CronjobLogEditor; use wcf\data\AbstractDatabaseObjectAction; +use wcf\system\cronjob\CronjobScheduler; use wcf\system\exception\ValidateActionException; use wcf\system\WCF; use wcf\util\DateUtil; @@ -37,6 +38,11 @@ class CronjobAction extends AbstractDatabaseObjectAction { */ protected $permissionsUpdate = array('admin.system.cronjob.canEditCronjob'); + /** + * @see wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess + */ + protected $allowGuestAccess = array('executeCronjobs'); + /** * Validates permissions and parameters */ @@ -160,4 +166,16 @@ class CronjobAction extends AbstractDatabaseObjectAction { return $return; } + + /** + * Validates permissions and parameters + */ + public function validateExecuteCronjobs() {} + + /** + * Executes open cronjobs. + */ + public function executeCronjobs() { + CronjobScheduler::getInstance()->executeCronjobs(); + } } diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 868ab29a10..b5d6478486 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -1,12 +1,11 @@ initSession(); $this->initLanguage(); $this->initTPL(); + $this->initCronjobs(); $this->initBlacklist(); $this->initCoreObjects(); $this->initApplications(); @@ -647,4 +648,13 @@ class WCF { return $baseHref . 'index.php' . $path . '#' . $fragment; } + + /** + * Initialises the cronjobs. + */ + protected function initCronjobs() { + if (defined('PACKAGE_ID')) { + self::getTPL()->assign('executeCronjobs', CronjobScheduler::getInstance()->getNextExec() < TIME_NOW); + } + } } diff --git a/wcfsetup/install/files/lib/system/WCFACP.class.php b/wcfsetup/install/files/lib/system/WCFACP.class.php index f2f72d9939..6403d764d8 100644 --- a/wcfsetup/install/files/lib/system/WCFACP.class.php +++ b/wcfsetup/install/files/lib/system/WCFACP.class.php @@ -38,6 +38,7 @@ class WCFACP extends WCF { $this->initSession(); $this->initLanguage(); $this->initTPL(); + $this->initCronjobs(); $this->initBlacklist(); $this->initAuth(); $this->initCoreObjects(); diff --git a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php index 92875510b2..ac3cfd97de 100644 --- a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php @@ -91,6 +91,15 @@ class CronjobScheduler extends SingletonFactory { } } + /** + * Returns the next execution time. + * + * @return integer + */ + public function getNextExec() { + return $this->cache['nextExec']; + } + /** * Loads outstanding cronjobs. */