Simplify
authorGunnar Wrobel <p@rdus.de>
Tue, 9 Mar 2010 18:41:53 +0000 (19:41 +0100)
committerGunnar Wrobel <p@rdus.de>
Tue, 9 Mar 2010 18:41:53 +0000 (19:41 +0100)
framework/LoginTasks/lib/Horde/LoginTasks/Task.php
framework/LoginTasks/lib/Horde/LoginTasks/Tasklist.php

index 95c8417..7b279d7 100644 (file)
@@ -86,6 +86,16 @@ abstract class Horde_LoginTasks_Task
     }
 
     /**
+     * Does the task require to be displayed?
+     *
+     * @return boolean True in case the task should be displayed.
+     */
+    public function needsDisplay()
+    {
+        return $this->display != Horde_LoginTasks::DISPLAY_NONE;
+    }
+
+    /**
      * Indicates if the display of the current task should be joined with the
      * given previous task.
      *
index 0c54e68..5790df7 100644 (file)
@@ -54,22 +54,13 @@ class Horde_LoginTasks_Tasklist
      */
     public function addTask($task)
     {
-        $tmp = array(
-            'display' => false,
-            'task' => $task
-        );
-
-        if ($task->display != Horde_LoginTasks::DISPLAY_NONE) {
-            $tmp['display'] = true;
-        }
-
         switch ($task->priority) {
         case Horde_LoginTasks::PRIORITY_HIGH:
-            array_unshift($this->_tasks, $tmp);
+            array_unshift($this->_tasks, $task);
             break;
 
         case Horde_LoginTasks::PRIORITY_NORMAL:
-            $this->_tasks[] = $tmp;
+            $this->_tasks[] = $task;
             break;
         }
     }
@@ -87,10 +78,10 @@ class Horde_LoginTasks_Tasklist
 
         reset($this->_tasks);
         while (list($k, $v) = each($this->_tasks)) {
-            if ($v['display'] && ($k >= $this->_ptr)) {
+            if ($v->needsDisplay() && ($k >= $this->_ptr)) {
                 break;
             }
-            $tmp[] = $v['task'];
+            $tmp[] = $v;
         }
 
         if ($advance) {
@@ -115,12 +106,12 @@ class Horde_LoginTasks_Tasklist
 
         reset($this->_tasks);
         while (list($k, $v) = each($this->_tasks)) {
-            if (!$v['display'] ||
-                (!is_null($previous) && !$v['task']->joinDisplayWith($previous))) {
+            if (!$v->needsDisplay() ||
+                (!is_null($previous) && !$v->joinDisplayWith($previous))) {
                 break;
             }
-            $tmp[] = $v['task'];
-            $previous = $v['task'];
+            $tmp[] = $v;
+            $previous = $v;
         }
 
         if ($advance) {