applied Patch #101198 There was an inconsistancy, where a color was hardcoded, and...
[squirrelmail.git] / functions / imap_mailbox.php
index 169633c818262feca6ab2a3ed910a051537a1187..422638ed3193150b8a06adb94ac9cfce9ade72ad 100755 (executable)
@@ -12,6 +12,7 @@
       sqimap_mailbox_select ($imap_stream, $mailbox);
       fputs ($imap_stream, "a001 EXPUNGE\r\n");
       $read = sqimap_read_data($imap_stream, "a001", true, $response, $message);
+      sqimap_mailbox_close ($imap_stream);
    }
 
 
    function sqimap_mailbox_exists ($imap_stream, $mailbox) {
       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;
+      if ($mailbox) {
+         if (ereg ("$mailbox", $mbx[0])) {
+            return true;
+         } else {
+            return false;
+         }
       }
    }
 
+   /******************************************************************************
+    **  Closes an open mailbox 
+    ******************************************************************************/
+   function sqimap_mailbox_close ($imap_stream) {
+      fputs ($imap_stream, "a001 CLOSE\r\n");
+      $tmp = sqimap_read_data($imap_stream, "a001", false, $response, $message);
+   }
 
-   
    /******************************************************************************
     **  Selects a mailbox
     ******************************************************************************/
-   function sqimap_mailbox_select ($imap_stream, $mailbox, $hide) {
+   function sqimap_mailbox_select ($imap_stream, $mailbox, $hide=true, $recent=false) {
       fputs ($imap_stream, "a001 SELECT \"$mailbox\"\r\n");
        $read = sqimap_read_data($imap_stream, "a001", true, $response, $message);
+      if ($recent) {
+         for ($i=0; $i<count($read); $i++) {
+            if (strpos(strtolower($read[$i]), "recent")) {
+               $r = explode(" ", $read[$i]);
+            }
+         }
+         return $r[1];
+      }
    }
 
    
             $dm_count--;
             
          for ($j = 0; $j < $dm_count - (countCharInString($folder_prefix, $dm)); $j++)
-            $boxes[$g]["formatted"] = $boxes[$g]["formatted"] . "  ";
+            $boxes[$g]["formatted"] = $boxes[$g]["formatted"] . "&nbsp;&nbsp;";
          $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $dm);
             
          $boxes[$g]["unformatted-dm"] = $mailbox;
       $inbox_subscribed = false;
       fputs ($imap_stream, "a001 LSUB \"\" \"*\"\r\n");
       $lsub_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
+   
       for ($i=0;$i < count($lsub_ary); $i++) {
          $sorted_lsub_ary[$i] = find_mailbox_name($lsub_ary[$i]);
          if ($sorted_lsub_ary[$i] == "INBOX")