From: Gunnar Wrobel
Date: Wed, 3 Mar 2010 11:02:21 +0000 (+0100) Subject: Move registry calls (returning the tasks and the URL of the login tasks view) into... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1f7de41018d25050570d2060f7d08941def76559;p=horde.git Move registry calls (returning the tasks and the URL of the login tasks view) into the backend. --- diff --git a/framework/LoginTasks/lib/Horde/LoginTasks.php b/framework/LoginTasks/lib/Horde/LoginTasks.php index 3dacf2f0c..a93298310 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks.php @@ -78,7 +78,11 @@ class Horde_LoginTasks { if (empty(self::$_instances[$app])) { self::$_instances[$app] = new self( - new Horde_LoginTasks_Backend_Horde($app), $app + new Horde_LoginTasks_Backend_Horde( + $GLOBALS['registry'], + $app + ), + $app ); } @@ -139,29 +143,10 @@ class Horde_LoginTasks $lasttask_pref = array(); } - /* Add Horde tasks here if not yet run. */ - $app_list = array($this->_app); - if (($this->_app != 'horde') && - !isset($_SESSION['horde_logintasks']['horde'])) { - array_unshift($app_list, 'horde'); - } - - $tasks = array(); - - foreach ($app_list as $app) { - foreach (array_merge($GLOBALS['registry']->getAppDrivers($app, 'LoginTasks_SystemTask'), $GLOBALS['registry']->getAppDrivers($app, 'LoginTasks_Task')) as $val) { - $tasks[$val] = $app; - } - } - - if (empty($tasks)) { - return; - } - /* Create time objects for today's date and last task run date. */ $cur_date = getdate(); - foreach ($tasks as $classname => $app) { + foreach ($this->_backend->getTasks() as $classname => $app) { $ob = new $classname(); /* If marked inactive, skip the task. */ @@ -298,13 +283,13 @@ class Horde_LoginTasks } /** - * Generated the login tasks URL. + * Generate the login tasks URL. * * @return string The login tasks URL. */ public function getLoginTasksUrl() { - return Horde::url(Horde_Util::addParameter($GLOBALS['registry']->get('webroot', 'horde') . '/services/logintasks.php', array('app' => $this->_app)), true); + return $this->_backend->getLoginTasksUrl(); } /** diff --git a/framework/LoginTasks/lib/Horde/LoginTasks/Backend.php b/framework/LoginTasks/lib/Horde/LoginTasks/Backend.php index 44a939509..b4b6bd3b8 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks/Backend.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks/Backend.php @@ -47,4 +47,18 @@ abstract class Horde_LoginTasks_Backend * @return NULL */ abstract public function registerShutdown($shutdown); + + /** + * Get the class names of the task classes that need to be performed. + * + * @return array An array of class names. + */ + abstract public function getTasks(); + + /** + * Return the URL of the login tasks view. + * + * @return string The URL of the login tasks view + */ + abstract public function getLoginTasksUrl(); } \ No newline at end of file diff --git a/framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php b/framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php index 2ae466076..ae032ed3b 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php @@ -27,9 +27,12 @@ extends Horde_LoginTasks_Backend * * @param string $app The Horde application that is currently active. */ - public function __construct($app) - { - $this->_app = $app; + public function __construct( + Horde_Registry $registry, + $app + ) { + $this->_registry = $registry; + $this->_app = $app; } /** @@ -79,4 +82,38 @@ extends Horde_LoginTasks_Backend { register_shutdown_function($shutdown); } + + /** + * Get the class names of the task classes that need to be performed. + * + * @return array An array of class names. + */ + public function getTasks() + { + /* Add Horde tasks here if not yet run. */ + $app_list = array($this->_app); + if (($this->_app != 'horde') && + !isset($_SESSION['horde_logintasks']['horde'])) { + array_unshift($app_list, 'horde'); + } + + $tasks = array(); + + foreach ($app_list as $app) { + foreach (array_merge($this->_registry->getAppDrivers($app, 'LoginTasks_SystemTask'), $this->_registry->getAppDrivers($app, 'LoginTasks_Task')) as $val) { + $tasks[$val] = $app; + } + } + return $tasks; + } + + /** + * Return the URL of the login tasks view. + * + * @return string The URL of the login tasks view + */ + public function getLoginTasksUrl() + { + return Horde::url(Horde_Util::addParameter($this->_registry->get('webroot', 'horde') . '/services/logintasks.php', array('app' => $this->_app)), true); + } } \ No newline at end of file