From: Michael M Slusarz Date: Thu, 25 Jun 2009 21:54:50 +0000 (-0600) Subject: Fixes for LoginTasks. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5168b02808a6d578f229b4258c63b90f0a683cae;p=horde.git Fixes for LoginTasks. Use basename() to determine classname. Prevent circumventing confirmation screens by refreshing browser. Fix DISPLAY_NONE. --- diff --git a/framework/LoginTasks/lib/Horde/LoginTasks.php b/framework/LoginTasks/lib/Horde/LoginTasks.php index 88865f39a..46fb2374f 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks.php @@ -139,15 +139,13 @@ class Horde_LoginTasks if (!is_null($fileroot) && is_dir($fileroot . '/lib/LoginTasks/Task')) { foreach (scandir($fileroot . '/lib/LoginTasks/Task') as $file) { - if (stripos($file, '.php') !== false) { - $classname = $app . '_LoginTasks_Task_' . substr($file, 0, -4); - if (class_exists($classname)) { - $tasks[$classname] = $app; - if (!isset($lasttasks[$app])) { - $lasttasks[$app] = empty($last_logintasks[$app]) - ? 0 - : getdate($last_logintasks[$app]); - } + $classname = $app . '_LoginTasks_Task_' . basename($file, '.php'); + if (class_exists($classname)) { + $tasks[$classname] = $app; + if (!isset($lasttasks[$app])) { + $lasttasks[$app] = empty($last_logintasks[$app]) + ? 0 + : getdate($last_logintasks[$app]); } } } @@ -212,17 +210,19 @@ class Horde_LoginTasks * This function will generate the list of tasks to perform during this * login and will redirect to the login tasks page if necessary. This is * the function that should be called from the application upon login. + * + * @param boolean $confirmed If true, indicates that any pending actions + * have been confirmed by the user. */ - public function runTasks() + public function runTasks($confirmed = false) { if ($this->_tasklist === true) { return; } /* Perform ready tasks now. */ - foreach ($this->_tasklist->ready() as $key => $val) { - if (($val->display == self::DISPLAY_AGREE) || - ($val->display == self::DISPLAY_NOTICE) || + foreach ($this->_tasklist->ready($this->_init || $confirmed) as $key => $val) { + if (in_array($val->display, array(self::DISPLAY_AGREE, self::DISPLAY_NOTICE, self::DISPLAY_NONE)) || Horde_Util::getFormData('logintasks_confirm_' . $key)) { $val->execute(); } diff --git a/framework/LoginTasks/lib/Horde/LoginTasks/Tasklist.php b/framework/LoginTasks/lib/Horde/LoginTasks/Tasklist.php index af5dc0516..c3426131a 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks/Tasklist.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks/Tasklist.php @@ -45,7 +45,7 @@ class Horde_LoginTasks_Tasklist * * @var integer */ - protected $_ptr = null; + protected $_ptr = -1; /** * Constructor. @@ -93,22 +93,23 @@ class Horde_LoginTasks_Tasklist /** * Returns the list of tasks to perform. * + * @param boolean $complete Mark ready tasks as completed? + * * @return array The list of tasks to perform. */ - public function ready() + public function ready($advance = false) { $tmp = array(); reset($this->_tasks); while (list($k, $v) = each($this->_tasks)) { - if ($v['display'] && - (is_null($this->_ptr) || ($k > $this->_ptr))) { + if ($v['display'] && ($k > $this->_ptr)) { break; } $tmp[] = $v['task']; } - if (!is_null($this->_ptr)) { + if ($advance) { $this->_tasks = array_slice($this->_tasks, $this->_ptr); $this->_ptr = 0; }