took out some debugging code
[squirrelmail.git] / functions / tree.php
index 680b0d04478a3f8ee5461b8fe2610abb29789ce0..7abcc2d0106d09c3bcd10616b743f7b39f3315a3 100644 (file)
@@ -8,7 +8,7 @@
       if ((isset($tree[$treeIndexToStart])) && (strstr($value, $tree[$treeIndexToStart]["value"]))) {
          if ($tree[$treeIndexToStart]["doIHaveChildren"]) {
             for ($i=0;$i< count($tree[$treeIndexToStart]["subNodes"]);$i++) {
-               $result = findParentForChild($value, $tree[$treeIndexToStart]["subNodes"][$i]);
+               $result = findParentForChild($value, $tree[$treeIndexToStart]["subNodes"][$i], $tree);
                if ($result > -1)
                   return $result;
             }
       }
    }  
 
-   function addChildNodeToTree($value, &$tree) {
-      $parentNode = findParentForChild($value, 0, $tree);
+   function addChildNodeToTree($comparisonValue, $value, &$tree) {
+      $parentNode = findParentForChild($comparisonValue, 0, $tree);
 
       // create a new subNode
-      $newNodeIndex = count($tree) + 1;
+      $newNodeIndex = count($tree);
       $tree[$newNodeIndex]["value"] = $value;
       $tree[$newNodeIndex]["doIHaveChildren"] = false;
 
             sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $dm . $subFolderName);
       }
    }
+
+   function simpleWalkTreePre($index, $tree) {
+      if ($tree[$index]["doIHaveChildren"]) {
+         for ($j = 0; $j < count($tree[$index]["subNodes"]); $j++) {
+            simpleWalkTreePre($tree[$index]["subNodes"][$j], $tree);
+         }
+         echo $tree[$index]["value"] . "<br>";
+      } else {
+         echo $tree[$index]["value"] . "<br>";
+      }
+   }
 ?>