** This function simply deletes the given folder
******************************************************************************/
function sqimap_mailbox_delete ($imap_stream, $mailbox) {
- sqimap_unsubscribe ($imap_stream, $mailbox);
fputs ($imap_stream, "a001 DELETE \"$mailbox\"\n");
$read_ary = sqimap_read_data($imap_stream, "a001", true, $response, $message);
+ sqimap_unsubscribe ($imap_stream, $mailbox);
}
$boxes[$g]["formatted"] = $boxes[$g]["formatted"] . " ";
$boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $dm);
+ $boxes[$g]["unformatted-dm"] = $mailbox;
if (substr($mailbox, -1) == $dm)
$mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
$boxes[$g]["unformatted"] = $mailbox;
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]);
- if ($result > -1)
+ $result = findParentForChild($value, $tree[$treeIndexToStart]["subNodes"][$i], $tree);
+ if ($result > -1) {
+ echo "parent for $value is : " . $tree[$treeIndexToStart]["subNodes"][$i] . "<br>";
return $result;
+ }
}
return $treeIndexToStart;
} else
}
}
- 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>";
+ }
+ }
?>
}
}
if ($use_folder == true) {
- $box = $boxes[$i]["unformatted"];
+ $box = $boxes[$i]["unformatted-dm"];
$box2 = replace_spaces($boxes[$i]["formatted"]);
echo " <OPTION VALUE=\"$box\">$box2\n";
}
for ($i = 0; $i < count($boxes); $i++) {
for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
- if ($boxes[$i]["flags"][$j] == "noinferiors") {
+ if ($boxes[$i]["flags"][$j] != "noinferiors") {
if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
$box = $boxes[$i]["unformatted"];
$box2 = replace_spaces($boxes[$i]["formatted"]);
$imap_stream = sqimap_login($username, $key, $imapServerAddress, 0);
$boxes = sqimap_mailbox_list ($imap_stream);
$dm = sqimap_get_delimiter($imap_stream);
+ if (substr($mailbox, -1) == $dm)
+ $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1);
+ else
+ $mailbox_no_dm = $mailbox;
/** lets see if we CAN move folders to the trash.. otherwise, just delete them **/
for ($i = 0; $i < count($boxes); $i++) {
/** First create the top node in the tree **/
for ($i = 0;$i < count($boxes);$i++) {
- if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
+ if (($boxes[$i]["unformatted-dm"] == $mailbox) && (strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) {
$foldersTree[0]["value"] = $mailbox;
$foldersTree[0]["doIHaveChildren"] = false;
continue;
// on the end of the $mailbox string, and compare to that.
$j = 0;
for ($i = 0;$i < count($boxes);$i++) {
- if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == ($mailbox . $dm)) {
- addChildNodeToTree($boxes[$i]["unformatted"], $foldersTree);
+ if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $dm)) == ($mailbox_no_dm . $dm)) {
+// echo "<B>".$boxes[$i]["unformatted-dm"] . "</b><BR>";
+ addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
}
}
+// simpleWalkTreePre(0, $foldersTree);
/** Lets start removing the folders and messages **/
if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/