{
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
);
}
$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. */
}
/**
- * 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();
}
/**
* @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
*
* @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;
}
/**
{
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