fixed some more warning messages
[squirrelmail.git] / functions / imap_mailbox.php
index 01ab0f9af19c8b8ed4ecb6c7301880887b234e4b..5c6f851ffa8f0f7bbfb1865a13510b261055de61 100755 (executable)
@@ -3,6 +3,8 @@
     **  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 ($move_to_trash && 
-               eregi("^" . quotemeta($trash_folder) . "(" . 
-                   quotemeta($dm) . ")?$", $boxes[$i]["unformatted"]))
-           {
+         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;
             }
             elseif ($move_to_sent &&
                eregi("^" . quotemeta($sent_folder) . "(" .
-                   quotemeta($dm) . ")?$", $boxes[$i]["unformatted"]))
-           {
+               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;
          }
       }