Remove URL parameter dependency from Horde_LoginTasks
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 7 Oct 2010 06:19:30 +0000 (00:19 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 7 Oct 2010 06:45:41 +0000 (00:45 -0600)
framework/Core/lib/Horde/Registry.php
framework/LoginTasks/lib/Horde/LoginTasks.php
framework/LoginTasks/package.xml
horde/services/logintasks.php

index 973873f..47c6f1d 100644 (file)
@@ -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;
index 024703c..0834eca 100644 (file)
@@ -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:
+     * <pre>
+     * 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.
+     * </pre>
      */
-    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.
      *
index ba58dab..93c618f 100644 (file)
@@ -21,7 +21,7 @@
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Removed Core dependency.
+ <notes>* Removed horde/Core and horde/Util dependency.
  * Added system tasks.
  * Added ONCE interval.
  * Renamed Maintenance:: -&gt; Horde_LoginTasks::.
    <pearinstaller>
     <min>1.5.4</min>
    </pearinstaller>
-   <package>
-    <name>Util</name>
-    <channel>pear.horde.org</channel>
-   </package>
   </required>
  </dependencies>
  <phprelease>
index b5e84e5..8c84e33 100644 (file)
@@ -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 <chuck@horde.org>
- * @author Michael Slusarz <slusarz@horde.org>
+ * @author   Chuck Hagenbuch <chuck@horde.org>
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @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');