Explorar el Código

Fixed some major bugs in getting the folder list. Might fix the problem with the left folder not refreshing. Also made the folder creation and deletion look nicer.

Luke Ehresman hace 25 años
padre
commit
db4f8834c4
Se han modificado 6 ficheros con 69 adiciones y 34 borrados
  1. 19 7
      functions/imap.php
  2. 3 0
      functions/strings.php
  3. 26 5
      po/squirrelmail.po
  4. 6 4
      src/folders_create.php
  5. 9 5
      src/folders_delete.php
  6. 6 13
      src/left_main.php

+ 19 - 7
functions/imap.php

@@ -46,13 +46,13 @@
    /** Parse the incoming mailbox name and return a string that is the FOLDER.MAILBOX **/
    function findMailboxName($mailbox) {
       $mailbox = trim($mailbox);
-      if (substr($mailbox,  strlen($mailbox)-1, strlen($mailbox)) == "\"") {
-         $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
-         $pos = strrpos($mailbox, "\"") + 1;
-         $box = substr($mailbox, $pos, strlen($mailbox));
-      } else {
+//      if (substr($mailbox,  strlen($mailbox)-1, strlen($mailbox)) == "\"") {
+//         $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
+//         $pos = strrpos($mailbox, "\"") + 1;
+//         $box = substr($mailbox, $pos, strlen($mailbox));
+//      } else {
          $box = substr($mailbox, strrpos($mailbox, " ")+1, strlen($mailbox));
-      }
+//      }
       return $box;
    }
 
@@ -82,7 +82,11 @@
       return $read;
    }
 
-   function getMailboxFlags($mailbox) {
+   function getMailboxFlags($imapConnection, $mailbox) {
+      $name = findMailboxName($mailbox);
+      fputs ($imapConnection, "1 LIST \"$name\" *\n");
+      $data = imapReadData($imapConnection, "1", true, $response, $message);
+      $mailbox = $data[0];
       $mailbox = trim($mailbox);
       $mailbox = substr($mailbox, strpos($mailbox, "(")+1, strlen($mailbox));
       $mailbox = substr($mailbox, 0, strpos($mailbox, ")"));
@@ -170,6 +174,9 @@
    }
 
    function removeFolder($imapConnection, $folder) {
+      fputs ($imapConnection, "1 unsubscribe \"$folder\"\n");
+      $data = imapReadData($imapConnection, "1", true, $response, $message);
+      echo $data[0] . "<BR>";
       fputs($imapConnection, "1 delete \"$folder\"\n");
       $data = imapReadData($imapConnection, "1", false, $response, $message);
       if ($response == "NO") {
@@ -201,6 +208,8 @@
 
             $mailbox = findMailboxName($mailbox);
             $periodCount = countCharInString($mailbox, $dm);
+            if (substr($mailbox, -1) == $dm)
+               $periodCount--;
 
             // indent the correct number of spaces.
             for ($j = 0;$j < $periodCount;$j++)
@@ -222,8 +231,11 @@
          if (substr(findMailboxName($mailbox), 0, 1) != ".") {
             $boxes[$g]["RAW"] = $mailbox;
 
+            // Get the mailbox name and format it.  If there is a $dm at the end of it, remove it.
             $mailbox = findMailboxName($mailbox);
             $periodCount = countCharInString($mailbox, $dm);
+            if (substr($mailbox, -1) == $dm)
+               $periodCount = $periodCount - 1;
 
             // indent the correct number of spaces.
             for ($j = 0;$j < $periodCount;$j++)

+ 3 - 0
functions/strings.php

@@ -17,6 +17,9 @@
    //    of the $haystack is reached.
    //*************************************************************************
    function readShortMailboxName($haystack, $needle) {
+      if (substr($haystack, -1) == $needle)
+         $haystack = substr($haystack, 0, strlen($haystack) - 1);
+
       if (strpos($haystack, $needle)) {
          $pos = strrpos($haystack, $needle) + 1;
          $data = substr($haystack, $pos, strlen($haystack));

+ 26 - 5
po/squirrelmail.po

@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2000-02-08 07:02-0500\n"
+"POT-Creation-Date: 2000-02-09 07:13-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -114,7 +114,28 @@ msgid ""
 msgstr ""
 
 #: squirrelmail/src/folders_create.php:35
-#: squirrelmail/src/folders_delete.php:77
+msgid "Folder Created!"
+msgstr ""
+
+#: squirrelmail/src/folders_create.php:36
+#: squirrelmail/src/folders_delete.php:80
+msgid "You will be automatically forwarded."
+msgstr ""
+
+#: squirrelmail/src/folders_create.php:36
+#: squirrelmail/src/folders_delete.php:80
+msgid "If not,"
+msgstr ""
+
+#: squirrelmail/src/folders_create.php:36
+#: squirrelmail/src/folders_delete.php:80
+msgid "click here"
+msgstr ""
+
+#: squirrelmail/src/folders_delete.php:79
+msgid "Folder Deleted!"
+msgstr ""
+
 #: squirrelmail/src/folders_rename_do.php:67
 msgid "Return"
 msgstr ""
@@ -128,7 +149,7 @@ msgid "New name:"
 msgstr ""
 
 #: squirrelmail/src/folders_rename_getname.php:34
-#: squirrelmail/src/options.php:259
+#: squirrelmail/src/options.php:258
 msgid "Submit"
 msgstr ""
 
@@ -196,11 +217,11 @@ msgstr ""
 msgid "         Size of editor window (in characters):"
 msgstr ""
 
-#: squirrelmail/src/options.php:147
+#: squirrelmail/src/options.php:146
 msgid "         Time between auto refresh of folder list:"
 msgstr ""
 
-#: squirrelmail/src/options.php:245
+#: squirrelmail/src/options.php:244
 msgid "Use a signature?"
 msgstr ""
 

+ 6 - 4
src/folders_create.php

@@ -27,13 +27,15 @@
    if (trim($subfolder) == "[ None ]") {
       createFolder($imapConnection, "$folder_name");
    } else {
-      createFolder($imapConnection, "$subfolder$dm$folder_name");
+      createFolder($imapConnection, "$subfolder$folder_name");
    }
    fputs($imapConnection, "1 logout\n");
 
-   echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
-   echo _("Return");
-   echo "</A>";
+   echo "<FONT FACE=\"Arial,Helvetica\">";
+   echo "<BR><BR><CENTER><B>" . _("Folder Created!") . "</B><BR><BR>";
+   echo _("You will be automatically forwarded.") . "<BR>" . _("If not,") . " <A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>" . _("click here") . "</a>.";   
+   echo "</CENTER></FONT>"; 
+         
 ?>
 </BODY></HTML>
 

+ 9 - 5
src/folders_delete.php

@@ -9,6 +9,8 @@
    include("../src/load_prefs.php");
 
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+   displayPageHeader($color, "None");  
+   
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
    getFolderList($imapConnection, $boxes);
 
@@ -19,7 +21,7 @@
          $tmp_trash_folder = $boxes[$i]["RAW"];
    }
 
-   $tmpflags = getMailboxFlags($tmp_trash_folder);
+   $tmpflags = getMailboxFlags($imapConnection, $tmp_trash_folder);
    $can_move_to_trash = true;
    for ($i = 0; $i < count($tmpflags); $i++) {
       if (strtolower($tmpflags[$i]) == "noinferiors")
@@ -33,7 +35,7 @@
          if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
              (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
             $folderWithoutINBOX = getFolderNameMinusINBOX($boxes[$i]["UNFORMATTED"], $dm);
-            $flags = getMailboxFlags($boxes[$i]["RAW"]);
+            $flags = getMailboxFlags($imapConnection, $boxes[$i]["RAW"]);
             for ($b = 0; $b < count($flags); $b++) {
                $type = $flags[$b];
             }
@@ -73,9 +75,11 @@
    /** Log out this session **/
    fputs($imapConnection, "1 logout");
 
-   echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
-   echo _("Return");
-   echo "</A>";
+   echo "<FONT FACE=\"Arial,Helvetica\">";
+   echo "<BR><BR><CENTER><B>" . _("Folder Deleted!") . "</B><BR><BR>";
+   echo _("You will be automatically forwarded.") . "<BR>" . _("If not,") . " <A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>" . _("click here") . "</A>";
+   echo "</CENTER></FONT>"; 
+   
    echo "</BODY></HTML>";
 ?>
 

+ 6 - 13
src/left_main.php

@@ -20,11 +20,11 @@
    include("../functions/imap.php");
    include("../functions/mailbox.php");
 
-   function formatMailboxName($imapConnection, $mailbox, $delimeter, $color, $move_to_trash) {
+   function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) {
       require ("../config/config.php");
 
       $mailboxURL = urlencode($mailbox);
-      selectMailbox($imapConnection, $mailbox, $numNessages);
+      selectMailbox($imapConnection, $real_box, $numNessages);
       $unseen = unseenMessages($imapConnection, $numUnseen);
 
       echo "<NOBR>";
@@ -87,15 +87,9 @@
    echo "<FONT FACE=\"Arial,Helvetica\">\n";
    $delimeter = findMailboxDelimeter($imapConnection);
    for ($i = 0;$i < count($boxes); $i++) {
-      $mailbox = $boxes[$i]["UNFORMATTED"];
-      $boxFlags = getMailboxFlags($boxes[$i]["RAW"]);
-
-      $boxCount = countCharInString($mailbox, $delimeter);
-
       $line = "";
-      // indent the correct number of spaces.
-      for ($j = 0;$j < $boxCount;$j++)
-         $line .= "&nbsp;&nbsp;";
+      $mailbox = $boxes[$i]["FORMATTED"];
+      $boxFlags = getMailboxFlags($imapConnection, $boxes[$i]["RAW"]);
 
       if (trim($boxFlags[0]) != "") {
          $noselect = false;
@@ -103,16 +97,15 @@
             if (strtolower($boxFlags[$h]) == "noselect")
                $noselect = true;
          }
-
          if ($noselect == true) {
             $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
             $line .= readShortMailboxName($mailbox, $delimeter);
             $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
          } else {
-            $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color, $move_to_trash);
+            $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash);
          }
       } else {
-         $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color, $move_to_trash);
+         $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash);
       }
       echo "$line<BR>";
    }