{
if (empty(self::$_instances[$app])) {
self::$_instances[$app] = new self(
- new Horde_LoginTasks_Backend_Horde(), $app
+ new Horde_LoginTasks_Backend_Horde($app), $app
);
}
$this->_app = $app;
- if (!Horde_Auth::getAuth()) {
+ if (!$this->_backend->isAuthenticated()) {
return;
}
/* Retrieves a cached tasklist or make sure one is created. */
- if (isset($_SESSION['horde_logintasks'][$app])) {
- $this->_tasklist = @unserialize($_SESSION['horde_logintasks'][$app]);
- }
+ $this->_tasklist = $this->_backend->getTaskListFromCache();
if (empty($this->_tasklist)) {
$this->_createTaskList();
* @author Gunnar Wrobel <wrobel@pardus.de>
* @package Horde_LoginTasks
*/
-class Horde_LoginTasks_Backend
+abstract class Horde_LoginTasks_Backend
{
+ /**
+ * Is the current session authenticated?
+ *
+ * @return boolean True if the user is authenticated, false otherwise.
+ */
+ abstract public function isAuthenticated();
+
+ /**
+ * Retrieve a cached tasklist if it exists.
+ *
+ * @return Horde_LoginTasks_Tasklist|boolean The cached task list or false
+ * if no task list was cached.
+ */
+ abstract public function getTasklistFromCache();
}
\ No newline at end of file
class Horde_LoginTasks_Backend_Horde
extends Horde_LoginTasks_Backend
{
+ /**
+ * The Horde application that is currently active.
+ *
+ * @var string
+ */
+ private $_app;
+
+ /**
+ * Constructor
+ *
+ * @param string $app The Horde application that is currently active.
+ */
+ public function __construct($app)
+ {
+ $this->_app = $app;
+ }
+
+ /**
+ * Is the current session authenticated?
+ *
+ * @return boolean True if the user is authenticated, false otherwise.
+ */
+ public function isAuthenticated()
+ {
+ return (Horde_Auth::getAuth() !== false);
+ }
+
+ /**
+ * Retrieve a cached tasklist if it exists.
+ *
+ * @return Horde_LoginTasks_Tasklist|boolean The cached task list or false
+ * if no task list was cached.
+ */
+ public function getTasklistFromCache()
+ {
+ if (isset($_SESSION['horde_logintasks'][$this->_app])) {
+ return @unserialize($_SESSION['horde_logintasks'][$this->_app]);
+ }
+ return false;
+ }
}
\ No newline at end of file