From 3224e2ac4b092b0315e8655b61aab86f6372b420 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 7 Oct 2010 00:19:30 -0600 Subject: [PATCH] Remove URL parameter dependency from Horde_LoginTasks --- framework/Core/lib/Horde/Registry.php | 4 ++- framework/LoginTasks/lib/Horde/LoginTasks.php | 37 ++++++++++++++++----------- framework/LoginTasks/package.xml | 6 +---- horde/services/logintasks.php | 25 +++++++++++++++--- 4 files changed, 47 insertions(+), 25 deletions(-) diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index 973873fd4..47c6f1d4f 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -1254,7 +1254,9 @@ class Horde_Registry if ($checkPerms && ($tasks = $GLOBALS['injector']->getInstance('Horde_Core_Factory_LoginTasks')->create($app)) && !empty($options['logintasks'])) { - $tasks->runTasks(false, Horde::selfUrl(true, true, true)); + $tasks->runTasks(array( + 'url' => Horde::selfUrl(true, true, true) + )); } return true; diff --git a/framework/LoginTasks/lib/Horde/LoginTasks.php b/framework/LoginTasks/lib/Horde/LoginTasks.php index 024703c6b..0834eca7c 100644 --- a/framework/LoginTasks/lib/Horde/LoginTasks.php +++ b/framework/LoginTasks/lib/Horde/LoginTasks.php @@ -151,11 +151,7 @@ class Horde_LoginTasks } if ($addtask) { - if ($ob instanceof Horde_LoginTasks_SystemTask) { - $ob->execute(); - } else { - $this->_tasklist->addTask($ob); - } + $this->_tasklist->addTask($ob); } } @@ -172,25 +168,36 @@ class Horde_LoginTasks * 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. - * @param string $url The URL to redirect to when finished. + * @param array $opts Options: + *
+     * confirmed - (array) The list of confirmed tasks.
+     * url - (string) The URL to redirect to when finished.
+     * user_confirmed - (boolean) If true, indicates that any pending actions
+     *                  have been confirmed by the user.
+     * 
*/ - public function runTasks($confirmed = false, $url = null) + public function runTasks(array $opts = array()) { if (!isset($this->_tasklist) || ($this->_tasklist === true)) { return; } + $opts = array_merge(array( + 'confirmed' => array(), + 'url' => null, + 'user_confirmed' => false + ), $opts); + if (empty($this->_tasklist->target)) { - $this->_tasklist->target = $url; + $this->_tasklist->target = $opts['url']; } /* Perform ready tasks now. */ - foreach ($this->_tasklist->ready(!$this->_tasklist->processed || $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)) { + foreach ($this->_tasklist->ready(!$this->_tasklist->processed || $opts['user_confirmed']) as $key => $val) { + if (($val instanceof Horde_LoginTasks_SystemTask) || + in_array($val->display, array(self::DISPLAY_AGREE, self::DISPLAY_NOTICE, self::DISPLAY_NONE)) || + in_array($key, $opts['confirmed'])) { $val->execute(); } } @@ -213,14 +220,14 @@ class Horde_LoginTasks return $this->_backend->redirect($url); } - if ((!$processed || $confirmed) && $this->_tasklist->needDisplay()) { + if ((!$processed || $opts['user_confirmed']) && + $this->_tasklist->needDisplay()) { return $this->_backend->redirect($this->getLoginTasksUrl()); } } /** * Generate the list of tasks that need to be displayed. - * * This is the function called from the login tasks page every time it * is loaded. * diff --git a/framework/LoginTasks/package.xml b/framework/LoginTasks/package.xml index ba58dabae..93c618f7a 100644 --- a/framework/LoginTasks/package.xml +++ b/framework/LoginTasks/package.xml @@ -21,7 +21,7 @@ beta LGPL - * Removed Core dependency. + * Removed horde/Core and horde/Util dependency. * Added system tasks. * Added ONCE interval. * Renamed Maintenance:: -> Horde_LoginTasks::. @@ -61,10 +61,6 @@ 1.5.4 - - Util - pear.horde.org - diff --git a/horde/services/logintasks.php b/horde/services/logintasks.php index b5e84e5d2..8c84e3300 100644 --- a/horde/services/logintasks.php +++ b/horde/services/logintasks.php @@ -7,15 +7,20 @@ * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. * - * @author Chuck Hagenbuch - * @author Michael Slusarz + * @author Chuck Hagenbuch + * @author Michael Slusarz + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Horde */ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('horde', array('nologintasks' => true)); +$vars = Horde_Variables::getDefaultVariables(); + /* If no 'module' parameter passed in, die with an error. */ -if (!($app = basename(Horde_Util::getFormData('app')))) { +if (!($app = basename($vars->app))) { throw new Horde_Exception('Do not directly access logintasks.php.'); } @@ -26,7 +31,19 @@ if (!($tasks = $injector->getInstance('Horde_Core_Factory_LoginTasks')->create($ } /* If we are through with tasks, this call will redirect to application. */ -$tasks->runTasks(Horde_Util::getPost('logintasks_page')); +$confirmed = array(); +if ($vars->logintasks_page) { + foreach ($vars as $key => $val) { + if ($val && (strpos($key, 'logintasks_confirm_') === 0)) { + $confirmed[] = $key; + } + } +} + +$tasks->runTasks(array( + 'confirmed' => $confirmed, + 'user_confirmed' => $vars->logintasks_page +)); /* Create the Horde_Template item. */ $template = $injector->createInstance('Horde_Template'); -- 2.11.0