Added unsubscribe/subscribe to folders
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 25 Mar 2000 00:07:06 +0000 (00:07 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 25 Mar 2000 00:07:06 +0000 (00:07 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@339 7612ce4b-ef26-0410-bec9-ea0150e637f0

TODO
functions/imap_mailbox.php
src/folders.php

diff --git a/TODO b/TODO
index 146b674a30692c814e9bcc169b727d323f1823f6..28bf0bbebaa94bcdb5f9bb5bd37411ccc18f0041 100644 (file)
--- a/TODO
+++ b/TODO
@@ -15,12 +15,12 @@ initials = taken by that person
   -     Better inline HTML support including graphics (content-disposition)
   -     Maybe a rewrite of mime.php (see Gustav before any work is done)
   -     Better handling emptying Trash folder.  Some servers don't allow deleting it (Courier)
   -     Better inline HTML support including graphics (content-disposition)
   -     Maybe a rewrite of mime.php (see Gustav before any work is done)
   -     Better handling emptying Trash folder.  Some servers don't allow deleting it (Courier)
-(lme)   Fix "Seen" bug with UW IMAP server
-  -     Add "subscribe" to folders section.
+(lme)   Add "subscribe" to folders section.
   -     Make Location redirects absolute rather than relative (index.php)
   -     POP suport (maybe)
 
 
 Finished:
 ------------------------------------------------------
   -     Make Location redirects absolute rather than relative (index.php)
   -     POP suport (maybe)
 
 
 Finished:
 ------------------------------------------------------
- (lme)  Saving sent messages
+(lme)   Saving sent messages
+(lme)   Fix "Seen" bug with UW IMAP server
index 963f7d43faea7831e12f2201c3305cf068e4835f..8d2dc88c36ac51148ef47a55d0ea96083b8afddd 100755 (executable)
 
       return $boxesnew;
    }
 
       return $boxesnew;
    }
+
+   
+   /******************************************************************************
+    **  Returns a list of all folders, subscribed or not
+    ******************************************************************************/
+   function sqimap_mailbox_list_all ($imap_stream) {
+      global $special_folders, $list_special_folders_first;
+      
+      if (!function_exists ("ary_sort"))
+         include ("../functions/array.php");
+      
+      $dm = sqimap_get_delimiter ($imap_stream);
+
+      fputs ($imap_stream, "a001 LIST \"\" *\r\n");
+      $read_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
+      $g = 0;
+      $phase = "inbox"; 
+      for ($i = 0; $i < count($read_ary); $i++) {
+         if (substr ($read_ary[$i], 0, 4) != "a001") {
+            $boxes[$g]["raw"] = $read_ary[$i];
+
+            $mailbox = find_mailbox_name($read_ary[$i]);
+            $dm_count = countCharInString($mailbox, $dm);
+            if (substr($mailbox, -1) == $dm)
+               $dm_count--;
+               
+            for ($j = 0; $j < $dm_count; $j++)
+               $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;
+            $boxes[$g]["id"] = $g;
+
+            /** Now lets get the flags for this mailbox **/
+            fputs ($imap_stream, "a002 LIST \"\" \"$mailbox\"\r\n"); 
+            $read_mlbx = sqimap_read_data ($imap_stream, "a002", true, $response, $message);
+
+            $flags = substr($read_mlbx[0], strpos($read_mlbx[0], "(")+1);
+            $flags = substr($flags, 0, strpos($flags, ")"));
+            $flags = str_replace("\\", "", $flags);
+            $flags = trim(strtolower($flags));
+            if ($flags) {
+               $boxes[$g]["flags"] = explode(" ", $flags);
+            }
+         }
+         $g++;
+      }
+      $boxes = ary_sort ($boxes, "unformatted", 1);
+      return $boxes;
+   }
    
 ?>
    
 ?>
index 861ddf0997975ee943f3abdcf2a5b1dfc2b20ece..069857b53495f87c30f5b280f89634717895db9c 100644 (file)
       echo "<INPUT TYPE=SUBMIT VALUE=\"";
       echo _("Rename");
       echo "\">\n";
       echo "<INPUT TYPE=SUBMIT VALUE=\"";
       echo _("Rename");
       echo "\">\n";
+      echo "</FORM></TD></TR>\n";
+   } else {
+      echo _("No mailboxes found") . "<br><br></td></tr>";
+   }
+   $boxes_sub = $boxes;
+   
+   /** UNSUBSCRIBE FOLDERS **/
+   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
+   echo _("Unsubscribe/Subscribe");
+   echo "</B></TD></TR>";
+   echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
+   if ($count_special_folders < count($boxes)) {
+      echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=POST>\n";
+      echo "<TT><SELECT NAME=mailbox>\n";
+      for ($i = 0; $i < count($boxes); $i++) {
+         $use_folder = true;
+         for ($p = 0; $p < count($special_folders); $p++) {
+            if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
+               $use_folder = false;
+            } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
+               $use_folder = false;
+            }
+         }
+         if ($use_folder == true) {
+            $box = $boxes[$i]["unformatted-dm"];
+            $box2 = replace_spaces($boxes[$i]["formatted"]);
+            echo "         <OPTION VALUE=\"$box\">$box2\n";
+         }
+      }
+      echo "</SELECT></TT>\n";
+      echo "<INPUT TYPE=SUBMIT VALUE=\"";
+      echo _("Unsubscribe");
+      echo "\">\n";
+      echo "</FORM></TD></TR>\n";
+   } else {
+      echo _("No mailboxes found") . "<br><br></td></tr>";
+   }
+   $boxes_sub = $boxes;
+   
+   /** SUBSCRIBE TO FOLDERS **/
+
+   echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
+   if ($count_special_folders < count($boxes)) {
+      $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
+      $boxes = sqimap_mailbox_list_all ($imap_stream);
+      
+      echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=POST>\n";
+      echo "<TT><SELECT NAME=mailbox>\n";
+      for ($i = 0; $i < count($boxes); $i++) {
+         $use_folder = true;
+         for ($p = 0; $p < count($special_folders); $p++) {
+            if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
+               $use_folder = false;
+            } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
+               $use_folder = false;
+            }
+
+            for ($q = 0; $q < count($boxes_sub); $q++) {
+               if ($boxes[$i]["unformatted"] == $boxes_sub[$q]["unformatted"]) 
+                  $use_folder = false;
+            }
+         }
+         if ($use_folder == true) {
+            $box = $boxes[$i]["unformatted-dm"];
+            $box2 = replace_spaces($boxes[$i]["formatted"]);
+            echo "         <OPTION VALUE=\"$box\">$box2\n";
+         }
+      }
+      echo "</SELECT></TT>\n";
+      echo "<INPUT TYPE=SUBMIT VALUE=\"";
+      echo _("Subscribe");
+      echo "\">\n";
       echo "</FORM></TD></TR></TABLE><BR>\n";
    } else {
       echo _("No mailboxes found") . "<br><br></td></tr></table>";
       echo "</FORM></TD></TR></TABLE><BR>\n";
    } else {
       echo _("No mailboxes found") . "<br><br></td></tr></table>";