Transfer the rest of the preferences based functionality into the backend.
authorGunnar Wrobel <p@rdus.de>
Wed, 3 Mar 2010 13:08:17 +0000 (14:08 +0100)
committerGunnar Wrobel <p@rdus.de>
Wed, 3 Mar 2010 13:08:17 +0000 (14:08 +0100)
framework/LoginTasks/lib/Horde/LoginTasks.php
framework/LoginTasks/lib/Horde/LoginTasks/Backend.php
framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php

index 43270ed..feecd1c 100644 (file)
@@ -139,7 +139,7 @@ class Horde_LoginTasks
         /* Get last task run date(s). Array keys are app names, values are
          * last run timestamps. Special key '_once' contains list of
          * ONCE tasks previously run. */
-        $lasttask_pref = $this->_backend->getLastTasks();
+        $lasttask_pref = $this->_backend->getLastRun();
 
         /* Create time objects for today's date and last task run date. */
         $cur_date = getdate();
@@ -185,7 +185,7 @@ class Horde_LoginTasks
                         !in_array($classname, $lasttask_pref['_once'])) {
                         $addtask = true;
                         $lasttask_pref['_once'][] = $classname;
-                        $GLOBALS['prefs']->setValue('last_logintasks', serialize($lasttask_pref));
+                        $this->_backend->setLastRun($lasttask_pref);
                     }
                     break;
                 }
@@ -240,14 +240,7 @@ class Horde_LoginTasks
         /* If we've successfully completed every task in the list (or skipped
          * it), record now as the last time login tasks was run. */
         if ($this->_tasklist->isDone()) {
-            $lasttasks = unserialize($GLOBALS['prefs']->getValue('last_logintasks'));
-            $lasttasks[$this->_app] = time();
-            if (($this->_app != 'horde') &&
-                !isset($_SESSION['horde_logintasks']['horde'])) {
-                $lasttasks['horde'] = time();
-                $_SESSION['horde_logintasks']['horde'] = true;
-            }
-            $GLOBALS['prefs']->setValue('last_logintasks', serialize($lasttasks));
+            $this->_backend->markLastRun();
 
             /* This will prevent us from having to store the entire tasklist
              * object in the session, while still indicating we have
index b4c5483..56cfe90 100644 (file)
@@ -62,7 +62,23 @@ abstract class Horde_LoginTasks_Backend
      *
      * @return array The information about the last time the tasks were run.
      */
-    abstract public function getLastTasks();
+    abstract public function getLastRun();
+
+    /**
+     * Store the information about the last time the tasks were run.
+     *
+     * @param array $last The information about the last time the tasks were run.
+     *
+     * @return NULL
+     */
+    abstract public function setLastRun(array $last);
+
+    /**
+     * Mark the current time as time the login tasks were run for the last time.
+     *
+     * @return NULL
+     */
+    abstract public function markLastRun();
 
     /**
      * Return the URL of the login tasks view.
index 0c95182..c34d190 100644 (file)
@@ -130,7 +130,7 @@ extends Horde_LoginTasks_Backend
      *
      * @return array The information about the last time the tasks were run.
      */
-    public function getLastTasks()
+    public function getLastRun()
     {
         $lasttask_pref = @unserialize($this->_prefs->getValue('last_logintasks'));
         if (!is_array($lasttask_pref)) {
@@ -140,6 +140,35 @@ extends Horde_LoginTasks_Backend
     }
 
     /**
+     * Store the information about the last time the tasks were run.
+     *
+     * @param array $last The information about the last time the tasks were run.
+     *
+     * @return NULL
+     */
+    public function setLastRun(array $last)
+    {
+        $this->_prefs->setValue('last_logintasks', serialize($last));
+    }
+
+    /**
+     * Mark the current time as time the login tasks were run for the last time.
+     *
+     * @return NULL
+     */
+    public function markLastRun()
+    {
+        $lasttasks = $this->getLastRun();
+        $lasttasks[$this->_app] = time();
+        if (($this->_app != 'horde') &&
+            !isset($_SESSION['horde_logintasks']['horde'])) {
+            $lasttasks['horde'] = time();
+            $_SESSION['horde_logintasks']['horde'] = true;
+        }
+        $GLOBALS['prefs']->setValue('last_logintasks', serialize($lasttasks));
+    }
+
+    /**
      * Return the URL of the login tasks view.
      *
      * @return string The URL of the login tasks view