Move the first preferences based task into the backend.
authorGunnar Wrobel <p@rdus.de>
Wed, 3 Mar 2010 12:58:25 +0000 (13:58 +0100)
committerGunnar Wrobel <p@rdus.de>
Wed, 3 Mar 2010 12:58:25 +0000 (13:58 +0100)
framework/LoginTasks/lib/Horde/LoginTasks.php
framework/LoginTasks/lib/Horde/LoginTasks/Backend.php
framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php
framework/LoginTasks/package.xml
framework/LoginTasks/test/Horde/LoginTasks/Stubs.php

index a932983..43270ed 100644 (file)
@@ -80,6 +80,7 @@ class Horde_LoginTasks
             self::$_instances[$app] = new self(
                 new Horde_LoginTasks_Backend_Horde(
                     $GLOBALS['registry'],
+                    $GLOBALS['prefs'],
                     $app
                 ),
                 $app
@@ -138,10 +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 = @unserialize($GLOBALS['prefs']->getValue('last_logintasks'));
-        if (!is_array($lasttask_pref)) {
-            $lasttask_pref = array();
-        }
+        $lasttask_pref = $this->_backend->getLastTasks();
 
         /* Create time objects for today's date and last task run date. */
         $cur_date = getdate();
index b4b6bd3..b4c5483 100644 (file)
@@ -56,6 +56,15 @@ abstract class Horde_LoginTasks_Backend
     abstract public function getTasks();
 
     /**
+     * Get the information about the last time the tasks were run. Array keys
+     * are app names, values are last run timestamps. Special key '_once'
+     * contains list of ONCE tasks previously run.
+     *
+     * @return array The information about the last time the tasks were run.
+     */
+    abstract public function getLastTasks();
+
+    /**
      * Return the URL of the login tasks view.
      *
      * @return string The URL of the login tasks view
index ae032ed..0c95182 100644 (file)
@@ -23,15 +23,31 @@ extends Horde_LoginTasks_Backend
     private $_app;
 
     /**
+     * The Horde registry.
+     *
+     * @var Horde_Registry
+     */
+    private $_registry;
+
+    /**
+     * The Horde preferences system
+     *
+     * @var Horde_Prefs
+     */
+    private $_prefs;
+
+    /**
      * Constructor
      *
      * @param string $app The Horde application that is currently active.
      */
     public function __construct(
         Horde_Registry $registry,
+        Horde_Prefs    $prefs,
         $app
     ) {
         $this->_registry = $registry;
+        $this->_prefs    = $prefs;
         $this->_app      = $app;
     }
     
@@ -108,6 +124,22 @@ extends Horde_LoginTasks_Backend
     }
 
     /**
+     * Get the information about the last time the tasks were run. Array keys
+     * are app names, values are last run timestamps. Special key '_once'
+     * contains list of ONCE tasks previously run.
+     *
+     * @return array The information about the last time the tasks were run.
+     */
+    public function getLastTasks()
+    {
+        $lasttask_pref = @unserialize($this->_prefs->getValue('last_logintasks'));
+        if (!is_array($lasttask_pref)) {
+            $lasttask_pref = array();
+        }
+        return $lasttask_pref;
+    }
+
+    /**
      * Return the URL of the login tasks view.
      *
      * @return string The URL of the login tasks view
index 68c721a..8e6f0c2 100644 (file)
@@ -63,6 +63,12 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <channel>pear.horde.org</channel>
    </package>
   </required>
+  <optional>
+   <package>
+    <name>Prefs</name>
+    <channel>pear.horde.org</channel>
+   </package>
+  </optional>
  </dependencies>
  <phprelease>
   <filelist>
index 02f256e..73e034e 100644 (file)
@@ -1,17 +1,22 @@
 <?php
 
 class Horde_LoginTasks_Stub_Prefs
+extends Horde_Prefs
 {
     private $_storage = array();
 
-    public function setValue($key, $value)
+    public function __construct()
     {
-        $this->_storage[$key] = $value;
     }
 
-    public function getValue($key)
+    public function setValue($pref, $val, $convert = true)
     {
-        return isset($this->_storage[$key]) ? $this->_storage[$key] : null;
+        $this->_storage[$pref] = $val;
+    }
+
+    public function getValue($pref, $convert = true)
+    {
+        return isset($this->_storage[$pref]) ? $this->_storage[$pref] : null;
     }
 }