From 41fd4ed4ae4431f7951052a15d24bfce43e8c6db Mon Sep 17 00:00:00 2001 From: nehresma Date: Mon, 6 Mar 2000 16:02:05 +0000 Subject: [PATCH] documentation added git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@275 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/tree.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/functions/tree.php b/functions/tree.php index 7abcc2d0..25c3ed99 100644 --- a/functions/tree.php +++ b/functions/tree.php @@ -4,18 +4,24 @@ if (!isset($imap_php)) include("../functions/imap.php"); + // Recursive function to find the correct parent for a new node function findParentForChild($value, $treeIndexToStart, $tree) { + // is $value in $tree[$treeIndexToStart]["value"] if ((isset($tree[$treeIndexToStart])) && (strstr($value, $tree[$treeIndexToStart]["value"]))) { + // do I have children, if not then must be a childnode of the current node if ($tree[$treeIndexToStart]["doIHaveChildren"]) { + // loop through each subNode checking to see if we are a subNode of one of them for ($i=0;$i< count($tree[$treeIndexToStart]["subNodes"]);$i++) { $result = findParentForChild($value, $tree[$treeIndexToStart]["subNodes"][$i], $tree); if ($result > -1) return $result; } + // if we aren't a child of one of the subNodes, must be a child of current node return $treeIndexToStart; } else return $treeIndexToStart; } else { + // we aren't a child of this node at all return -1; } } -- 2.25.1