From: Gunnar Wrobel Date: Wed, 3 Mar 2010 13:08:17 +0000 (+0100) Subject: Transfer the rest of the preferences based functionality into the backend. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=fa219594824bd28097b539254cf2ca1d3653bb25;p=horde.git Transfer the rest of the preferences based functionality into the backend. --- diff --git a/framework/LoginTasks/lib/Horde/LoginTasks.php b/framework/LoginTasks/lib/Horde/LoginTasks.php index 43270ed89..feecd1c9b 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks.php @@ -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 diff --git a/framework/LoginTasks/lib/Horde/LoginTasks/Backend.php b/framework/LoginTasks/lib/Horde/LoginTasks/Backend.php index b4c5483c8..56cfe9097 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks/Backend.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks/Backend.php @@ -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. diff --git a/framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php b/framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php index 0c951827f..c34d190c9 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks/Backend/Horde.php @@ -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