self::$_instances[$app] = new self(
new Horde_LoginTasks_Backend_Horde(
$GLOBALS['registry'],
+ $GLOBALS['prefs'],
$app
),
$app
/* 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();
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
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;
}
}
/**
+ * 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
<channel>pear.horde.org</channel>
</package>
</required>
+ <optional>
+ <package>
+ <name>Prefs</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ </optional>
</dependencies>
<phprelease>
<filelist>
<?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;
}
}