Added basic CSS support.
[squirrelmail.git] / functions / imap_mailbox.php
index 4cf6e3a69b54d22805165f8fa8fdab9954ff5968..169633c818262feca6ab2a3ed910a051537a1187 100755 (executable)
     **  Checks whether or not the specified mailbox exists 
     ******************************************************************************/
    function sqimap_mailbox_exists ($imap_stream, $mailbox) {
-      $boxes = sqimap_mailbox_list ($imap_stream);
-      $found = false;
-      for ($i = 0; $i < count ($boxes); $i++) {
-         if ($boxes[$i]["unformatted"] == $mailbox)
-            $found = true;
+      fputs ($imap_stream, "a001 LIST \"\" \"$mailbox\"\r\n");
+      $mbx = sqimap_read_data($imap_stream, "a001", true, $response, $message);
+      if (ereg ("$mailbox", $mbx[0])) {
+         return true;
+      } else {
+         return false;
       }
-      return $found;
    }
 
 
       if ($inbox_subscribed == false || $inbox_in_list == false) {
          fputs ($imap_stream, "a001 LIST \"\" \"INBOX\"\r\n");
          $inbox_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
-         $sorted_list_ary[count($sorted_list_ary)] = $inbox_ary[0];
+
+         $pos = count($sorted_list_ary);
+         $sorted_list_ary[$pos] = $inbox_ary[0];
+
+         $pos = count($sorted_lsub_ary);
+         $sorted_lsub_ary[$pos] = find_mailbox_name($inbox_ary[0]);
       }
 
                $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary, $dm);
          }
          $g++;
       }
-      $boxes = ary_sort ($boxes, "unformatted", 1);
+      if ($boxes) {
+         $boxes = ary_sort ($boxes, "unformatted", 1);
+      }
       return $boxes;
    }