** imap_mailbox.php
**
** This impliments all functions that manipulate mailboxes
+ **
+ ** $Id$
**/
/******************************************************************************
return $boxes;
}
- /* patch from dave_michmerhuizen@yahoo.com
- * allows case insensativity when sorting folders
- */
- function _icmp ($a, $b) {
- return strcasecmp($a, $b);
- }
-
+
/******************************************************************************
** Returns sorted mailbox lists in several different ways.
** See comment on sqimap_mailbox_parse() for info about the returned array.
}
$sorted_lsub_ary = $new_ary;
if (isset($sorted_lsub_ary)) {
- usort($sorted_lsub_ary, "_icmp");
+ usort($sorted_lsub_ary, "strcasecmp");
//sort($sorted_lsub_ary);
}
for ($i = 0; $i < count($boxes); $i++) {
if (strtolower($boxes[$i]["unformatted"]) == "inbox") {
$boxesnew[] = $boxes[$i];
- $boxes[$i]["used"] = true;
+ $used[$i] = true;
$i = count($boxes);
}
}
if ($list_special_folders_first == true) {
// Then list special folders and their subfolders
- for ($i = 0 ; $i <= count($boxes) ; $i++) {
- if((eregi("^".$trash_folder.'$', $boxes[$i]["unformatted"]) ||
- eregi("^".$trash_folder.quotemeta($dm), $boxes[$i]["unformatted"]) ) &&
- ($move_to_trash)) {
+ for ($i = 0 ; $i < count($boxes) ; $i++) {
+ if ($move_to_trash &&
+ eregi("^" . quotemeta($trash_folder) . "(" .
+ quotemeta($dm) . ".*)?$", $boxes[$i]["unformatted"])) {
$boxesnew[] = $boxes[$i];
- $boxes[$i]["used"] = true;
+ $used[$i] = true;
}
- else if((eregi("^".$sent_folder.'$', $boxes[$i]["unformatted"]) ||
- eregi("^".$sent_folder.quotemeta($dm), $boxes[$i]["unformatted"]) ) &&
- ($move_to_sent)) {
+ elseif ($move_to_sent &&
+ eregi("^" . quotemeta($sent_folder) . "(" .
+ quotemeta($dm) . ".*)?$", $boxes[$i]["unformatted"])) {
$boxesnew[] = $boxes[$i];
- $boxes[$i]["used"] = true;
+ $used[$i] = true;
}
}
// Put INBOX.* folders ahead of the rest
- for ($i = 0; $i <= count($boxes); $i++) {
+ for ($i = 0; $i < count($boxes); $i++) {
if (eregi("^inbox\.", $boxes[$i]["unformatted"]) &&
- ($boxes[$i]["used"] == false)) {
+ (!isset($used[$i]) || $used[$i] == false)) {
$boxesnew[] = $boxes[$i];
- $boxes[$i]["used"] = true;
+ $used[$i] = true;
}
}
// Rest of the folders
for ($i = 0; $i < count($boxes); $i++) {
if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
- ($boxes[$i]["used"] == false)) {
+ (!isset($used[$i]) || $used[$i] == false)) {
$boxesnew[] = $boxes[$i];
- $boxes[$i]["used"] = true;
+ $used[$i] = true;
}
}