Added numerous changes from embeejay
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 23 Oct 2000 16:17:52 +0000 (16:17 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 23 Oct 2000 16:17:52 +0000 (16:17 +0000)
Added an expunge button, shown only when needed
Better flag handling
ereg() calls instead of lots of other calls

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@819 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_mailbox.php
functions/imap_messages.php
functions/mailbox_display.php
functions/mime.php
functions/strings.php
src/move_messages.php

index a8b8ed1a59e021056c744e29ac11ed9ddda37c6e..de9ce022e9ec81c35bb612a5164a668777c6617b 100755 (executable)
       fputs ($imap_stream, "a001 LIST \"\" \"$mailbox\"\r\n");
       $mbx = sqimap_read_data($imap_stream, "a001", true, $response, $message);
       if ($mailbox) {
       fputs ($imap_stream, "a001 LIST \"\" \"$mailbox\"\r\n");
       $mbx = sqimap_read_data($imap_stream, "a001", true, $response, $message);
       if ($mailbox) {
-         if (ereg ("$mailbox", $mbx[0])) {
-            return true;
-         } else {
-            return false;
-         }
+         return !!(ereg ("$mailbox", $mbx[0]));  // To force into true/false
       }
    }
 
       }
    }
 
          $boxes[$g]["unformatted"] = $mailbox;
          $boxes[$g]["id"] = $g;
 
          $boxes[$g]["unformatted"] = $mailbox;
          $boxes[$g]["id"] = $g;
 
-         $flags = substr($line[$g], strpos($line[$g], "(")+1);
-         $flags = substr($flags, 0, strpos($flags, ")"));
-         $flags = str_replace("\\", "", $flags);
-         $flags = trim(strtolower($flags));
+         ereg("\(([^)]*)\)",$line[$g],$regs);
+         $flags = trim(strtolower(str_replace("\\", "",$regs[1])));
          if ($flags) {
             $boxes[$g]["flags"] = explode(" ", $flags);
          }
          if ($flags) {
             $boxes[$g]["flags"] = explode(" ", $flags);
          }
     ******************************************************************************/
    function sqimap_mailbox_list ($imap_stream) {
       global $load_prefs_php, $prefs_php, $config_php, $data_dir, $username, $list_special_folders_first;
     ******************************************************************************/
    function sqimap_mailbox_list ($imap_stream) {
       global $load_prefs_php, $prefs_php, $config_php, $data_dir, $username, $list_special_folders_first;
-               global $trash_folder, $sent_folder;
-               global $move_to_trash, $move_to_sent;
+      global $trash_folder, $sent_folder, $imap_server_type;
+      global $move_to_trash, $move_to_sent;
 
       $inbox_in_list = false;
       $inbox_subscribed = false;
 
       $inbox_in_list = false;
       $inbox_subscribed = false;
 
       /** LSUB array **/
       $inbox_subscribed = false;
 
       /** LSUB array **/
       $inbox_subscribed = false;
-      fputs ($imap_stream, "a001 LSUB \"\" \"*\"\r\n");
+      if ($imap_server_type == "uw") {
+         fputs ($imap_stream, "a001 LSUB \"~\" \"*\"\r\n");
+      }
+      else {
+         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++) {
       $lsub_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
    
       for ($i=0;$i < count($lsub_ary); $i++) {
       }   
 
       /** LIST array **/
       }   
 
       /** LIST array **/
-               for ($i=0; $i < count($sorted_lsub_ary); $i++) {
-                       if (substr($sorted_lsub_ary[$i], -1) == $dm)
-                               $mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
-                       else
-                               $mbx = $sorted_lsub_ary[$i];
-
-                       fputs ($imap_stream, "a001 LIST \"\" \"$mbx\"\r\n");
-                       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
-                       $sorted_list_ary[$i] = $read[0];
+      for ($i=0; $i < count($sorted_lsub_ary); $i++) {
+         if (substr($sorted_lsub_ary[$i], -1) == $dm)
+            $mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
+         else
+            $mbx = $sorted_lsub_ary[$i];
+
+         fputs ($imap_stream, "a001 LIST \"\" \"$mbx\"\r\n");
+         $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
+         $sorted_list_ary[$i] = $read[0];
          if (find_mailbox_name($sorted_list_ary[$i]) == "INBOX")
             $inbox_in_list = true;
          if (find_mailbox_name($sorted_list_ary[$i]) == "INBOX")
             $inbox_in_list = true;
-               }
+      }
                
       /** Just in case they're not subscribed to their inbox, we'll get it for them anyway **/
       if ($inbox_subscribed == false || $inbox_in_list == false) {
                
       /** Just in case they're not subscribed to their inbox, we'll get it for them anyway **/
       if ($inbox_subscribed == false || $inbox_in_list == false) {
          $sorted_lsub_ary[$pos] = find_mailbox_name($inbox_ary[0]);
       }
 
          $sorted_lsub_ary[$pos] = find_mailbox_name($inbox_ary[0]);
       }
 
-               $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary, $dm);
-               
-               /** Now, lets sort for special folders **/
+      $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary, $dm);
+
+      /** Now, lets sort for special folders **/
       for ($i = 0; $i < count($boxes); $i++) {
          if (strtolower($boxes[$i]["unformatted"]) == "inbox") {
             $boxesnew[0] = $boxes[$i];
       for ($i = 0; $i < count($boxes); $i++) {
          if (strtolower($boxes[$i]["unformatted"]) == "inbox") {
             $boxesnew[0] = $boxes[$i];
index 1f4d57d427c8d517a8c0a963d367d56b4ef67cbf..98449ad9e079b567580e442a0dd9fd2b9f538364 100755 (executable)
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
    }
 
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
    }
 
+
+   /******************************************************************************
+    **  Remove specified flag from specified messages
+    ******************************************************************************/
+   function sqimap_messages_remove_flag ($imap_stream, $start, $end, $flag) {
+      fputs ($imap_stream, "a001 STORE $start:$end -FLAGS (\\$flag)\r\n");
+      $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
+   }
+
+
    /******************************************************************************
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     ******************************************************************************/
    /******************************************************************************
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     ******************************************************************************/
index 95ea1b95cfbc985a72f511e366abb47c55bd6e18..30f51a9b1ac44a1e342e2f11e928d2f439dc6003 100644 (file)
@@ -12,7 +12,7 @@
 
    function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, $where, $what) {
       global $color, $msgs, $msort;
 
    function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, $where, $what) {
       global $color, $msgs, $msort;
-               global $sent_folder;
+      global $sent_folder;
       global $message_highlight_list;
       global $index_order;
 
       global $message_highlight_list;
       global $index_order;
 
                   echo "<font color=$color[1]>!</font>\n";
                   $stuff = true;
                }
                   echo "<font color=$color[1]>!</font>\n";
                   $stuff = true;
                }
+               if ($msg["FLAG_DELETED"]) {
+                  echo "<font color=\"$color[1]\">D</font>\n";
+                  $stuff = true;
+               }
+               
                if (!$stuff) echo "&nbsp;\n";
                echo "</small></b></td>\n";
                break;
                if (!$stuff) echo "&nbsp;\n";
                echo "</small></b></td>\n";
                break;
     **/
    function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
       global $msgs, $msort;
     **/
    function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
       global $msgs, $msort;
-               global $sent_folder;
+      global $sent_folder;
       global $message_highlight_list;
       global $auto_expunge;
 
       global $message_highlight_list;
       global $auto_expunge;
 
       if (!$use_cache) {
          if ($numMessages >= 1) {
             for ($q = 0; $q < $numMessages; $q++) {
       if (!$use_cache) {
          if ($numMessages >= 1) {
             for ($q = 0; $q < $numMessages; $q++) {
-                                       if ($mailbox == $sent_folder)
-                       $hdr = sqimap_get_small_header ($imapConnection, $q+1, true);
-                                       else
-                       $hdr = sqimap_get_small_header ($imapConnection, $q+1, false);
+               if($mailbox == $sent_folder)
+                  $hdr = sqimap_get_small_header ($imapConnection, $q+1, true);
+               else
+                  $hdr = sqimap_get_small_header ($imapConnection, $q+1, false);
+                       
                                                
                                                
-                                       $from[$q] = $hdr->from;
-                                       $date[$q] = $hdr->date;
-                                       $subject[$q] = $hdr->subject;
+              $from[$q] = $hdr->from;
+              $date[$q] = $hdr->date;
+              $subject[$q] = $hdr->subject;
                $to[$q] = $hdr->to;
                $priority[$q] = $hdr->priority;
                $cc[$q] = $hdr->cc;
                $size[$q] = $hdr->size;
                $type[$q] = $hdr->type0;
                $to[$q] = $hdr->to;
                $priority[$q] = $hdr->priority;
                $cc[$q] = $hdr->cc;
                $size[$q] = $hdr->size;
                $type[$q] = $hdr->type0;
-
                $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
             }
          }
                $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
             }
          }
             $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
             $messages[$j]["SUBJECT-SORT"] = strtolower(decodeHeader($subject[$j]));
             $messages[$j]["TO"] = decodeHeader($to[$j]);
             $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
             $messages[$j]["SUBJECT-SORT"] = strtolower(decodeHeader($subject[$j]));
             $messages[$j]["TO"] = decodeHeader($to[$j]);
-                               $messages[$j]["PRIORITY"] = $priority[$j];
+           $messages[$j]["PRIORITY"] = $priority[$j];
             $messages[$j]["CC"] = $cc[$j];
             $messages[$j]["SIZE"] = $size[$j];
             $messages[$j]["TYPE0"] = $type[$j];
             $messages[$j]["CC"] = $cc[$j];
             $messages[$j]["SIZE"] = $size[$j];
             $messages[$j]["TYPE0"] = $type[$j];
                if ($flags[$j][$num] == "Deleted") {
                   $messages[$j]["FLAG_DELETED"] = true;
                }
                if ($flags[$j][$num] == "Deleted") {
                   $messages[$j]["FLAG_DELETED"] = true;
                }
-               else if ($flags[$j][$num] == "Answered") {
+               elseif ($flags[$j][$num] == "Answered") {
                   $messages[$j]["FLAG_ANSWERED"] = true;
                }
                   $messages[$j]["FLAG_ANSWERED"] = true;
                }
-               else if ($flags[$j][$num] == "Seen") {
+               elseif ($flags[$j][$num] == "Seen") {
                   $messages[$j]["FLAG_SEEN"] = true;
                }
                   $messages[$j]["FLAG_SEEN"] = true;
                }
-               else if ($flags[$j][$num] == "Flagged") {
+               elseif ($flags[$j][$num] == "Flagged") {
                   $messages[$j]["FLAG_FLAGGED"] = true;
                }
                $num++;
             }
             $j++;
          }
                   $messages[$j]["FLAG_FLAGGED"] = true;
                }
                $num++;
             }
             $j++;
          }
-      
-         /** Find and remove the ones that are deleted */
-         $i = 0;
-         $j = 0;
-         while ($j < $numMessages) {
-            if ($messages[$j]["FLAG_DELETED"] == true) {
+
+         /* Only ignore messages flagged as deleted if we are using a
+          * trash folder or auto_expunge */
+         if ($move_to_trash || $auto_expunge)
+         {      
+            /** Find and remove the ones that are deleted */
+            $i = 0;
+            $j = 0;
+            while ($j < $numMessages) {
+               if ($messages[$j]["FLAG_DELETED"] == true) {
+                  $j++;
+                  continue;
+               }
+               $msgs[$i] = $messages[$j];
+   
+               $i++;
                $j++;
                $j++;
-               continue;
             }
             }
-            $msgs[$i] = $messages[$j];
-   
-            $i++;
-            $j++;
+            $numMessages = $i;
          }
          }
-         $numMessages = $i;
       }         
 
       // There's gotta be messages in the array for it to sort them.
       }         
 
       // There's gotta be messages in the array for it to sort them.
-      if (($numMessages > 0) && (!$use_cache)) {
+      if ($numMessages > 0 && ! $use_cache) {
          /** 0 = Date (up)      4 = Subject (up)
           ** 1 = Date (dn)      5 = Subject (dn)
           ** 2 = Name (up)
          /** 0 = Date (up)      4 = Subject (up)
           ** 1 = Date (dn)      5 = Subject (dn)
           ** 2 = Name (up)
          if (($sort == 4) || ($sort == 5))
             $msort = array_cleave ($msgs, "SUBJECT-SORT");
 
          if (($sort == 4) || ($sort == 5))
             $msort = array_cleave ($msgs, "SUBJECT-SORT");
 
-         if(($sort % 2) == 1) {
+         if($sort % 2) {
             asort($msort);
          } else {
             arsort($msort);
             asort($msort);
          } else {
             arsort($msort);
    // generic function to convert the msgs array into an HTML table
    function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
       global $folder_prefix, $sent_folder;
    // generic function to convert the msgs array into an HTML table
    function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
       global $folder_prefix, $sent_folder;
-               global $imapServerAddress;
+      global $imapServerAddress;
       global $index_order;
 
       // if cache isn't already set, do it now
       global $index_order;
 
       // if cache isn't already set, do it now
       $Message = '';
       if ($startMessage < $endMessage) {
          $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
       $Message = '';
       if ($startMessage < $endMessage) {
          $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
-      } else if ($startMessage == $endMessage) {
+      } elseif ($startMessage == $endMessage) {
          $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
       }
 
          $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
       }
 
          $More = "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
          $More .= "<A HREF=\"right_main.php?use_mailbox_cache=1&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
       }
          $More = "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
          $More .= "<A HREF=\"right_main.php?use_mailbox_cache=1&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
       }
-      else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
+      elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
          $More = "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
          $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
       }
          $More = "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
          $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
       }
-      else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
+      elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
          $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
          $More .= "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
       }
          $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
          $More .= "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
       }
       if ($numMessages == 0) { // if there's no messages in this folder
          echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
          echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp;</CENTER></TD></TR>";
       if ($numMessages == 0) { // if there's no messages in this folder
          echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
          echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp;</CENTER></TD></TR>";
-      } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
+      } elseif ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
          $i = $startMessage;
          reset($msort);
          do {
          $i = $startMessage;
          reset($msort);
          do {
    function mail_message_listing_beginning($imapConnection, $moveURL, 
        $mailbox = '', $sort = -1, $Message = '', $More = '')
    {
    function mail_message_listing_beginning($imapConnection, $moveURL, 
        $mailbox = '', $sort = -1, $Message = '', $More = '')
    {
-      global $color, $index_order;
+      global $color, $index_order, $auto_expunge, $move_to_trash;
        
          /** This is the beginning of the message list table.  It wraps around all messages */
       echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0>";
        
          /** This is the beginning of the message list table.  It wraps around all messages */
       echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0>";
       echo "         <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"". _("Move") ."\"></SMALL></NOBR>\n";
       echo "      </TD>\n";
       echo "      <TD WIDTH=40% ALIGN=RIGHT>\n";
       echo "         <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"". _("Move") ."\"></SMALL></NOBR>\n";
       echo "      </TD>\n";
       echo "      <TD WIDTH=40% ALIGN=RIGHT>\n";
+      if (! $move_to_trash && ! $auto_expunge) {
+         echo "         <NOBR><SMALL><INPUT TYPE=SUBMIT NAME=\"expungeButton\" VALUE=\"". _("Expunge") ."\">&nbsp;". _("mailbox") ."</SMALL></NOBR>&nbsp;&nbsp;\n";
+      }
       echo "         <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\">&nbsp;". _("checked messages") ."</SMALL></NOBR>\n";
       echo "      </TD>\n";
       echo "   </TR>\n";
       echo "         <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\">&nbsp;". _("checked messages") ."</SMALL></NOBR>\n";
       echo "      </TD>\n";
       echo "   </TR>\n";
          
                if ($sort == 2)
                   echo "   <A HREF=\"right_main.php?newsort=3&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
          
                if ($sort == 2)
                   echo "   <A HREF=\"right_main.php?newsort=3&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
-               else if ($sort == 3)
+               elseif ($sort == 3)
                   echo "   <A HREF=\"right_main.php?newsort=2&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
                   echo "   <A HREF=\"right_main.php?newsort=2&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
-               else if ($sort != -1)
+               elseif ($sort != -1)
                   echo "   <A HREF=\"right_main.php?newsort=3&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
                break;
                
                   echo "   <A HREF=\"right_main.php?newsort=3&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
                break;
                
                echo "   <TD nowrap WIDTH=1%><B>". _("Date") ."</B>";
                if ($sort == 0)
                   echo "   <A HREF=\"right_main.php?newsort=1&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
                echo "   <TD nowrap WIDTH=1%><B>". _("Date") ."</B>";
                if ($sort == 0)
                   echo "   <A HREF=\"right_main.php?newsort=1&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
-               else if ($sort == 1)
+               elseif ($sort == 1)
                   echo "   <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
                   echo "   <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
-               else if ($sort != -1)
+               elseif ($sort != -1)
                   echo "   <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
                break;
                
                   echo "   <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
                break;
                
                echo "   <TD WIDTH=%><B>". _("Subject") ."</B>\n";
                if ($sort == 4)
                  echo "   <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
                echo "   <TD WIDTH=%><B>". _("Subject") ."</B>\n";
                if ($sort == 4)
                  echo "   <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
-               else if ($sort == 5)
+               elseif ($sort == 5)
                   echo "   <A HREF=\"right_main.php?newsort=4&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
                   echo "   <A HREF=\"right_main.php?newsort=4&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
-               else if ($sort != -1)
+               elseif ($sort != -1)
                   echo "   <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
                break;
                
                   echo "   <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
                break;
                
index e60bcb62e878b2d3fcaead6bb33f88ccdd8388e0..13a453a9ef89983746d790814344a98011d778c9 100644 (file)
    
          // If there are other types that shouldn't be formatted, add
          // them here 
    
          // If there are other types that shouldn't be formatted, add
          // them here 
-         if ($message->header->type1 != "html") {   
+         if ($body_message->header->type1 != "html") {   
             translateText($body, $wrap_at, $body_message->header->charset);
          }   
    
             translateText($body, $wrap_at, $body_message->header->charset);
          }   
    
index ecd423b5a56c63b4686a53a946eb83f677c018cb..bee3eaa0a1cdb5c695ca97fa749631ed4402e78e 100644 (file)
@@ -6,29 +6,17 @@
    // Count the number of occurances of $needle are in $haystack.
    //*************************************************************************
    function countCharInString($haystack, $needle) {
    // Count the number of occurances of $needle are in $haystack.
    //*************************************************************************
    function countCharInString($haystack, $needle) {
-      $len = strlen($haystack);
-      for ($i = 0; $i < $len; $i++) {
-         if ($haystack[$i] == $needle)
-            $count++;
-      }
-      return $count;
+      $haystack = ereg_replace("[^$needle]","",$haystack);
+      return strlen($haystack);
    }
 
    //*************************************************************************
    // Read from the back of $haystack until $needle is found, or the begining
    }
 
    //*************************************************************************
    // Read from the back of $haystack until $needle is found, or the begining
-   //    of the $haystack is reached.
+   //    of the $haystack is reached.  $needle is a single character
    //*************************************************************************
    function readShortMailboxName($haystack, $needle) {
    //*************************************************************************
    function readShortMailboxName($haystack, $needle) {
-      if (substr($haystack, -1) == $needle)
-         $haystack = substr($haystack, 0, strlen($haystack) - 1);
-
-      if (strrpos($haystack, $needle)) {
-         $pos = strrpos($haystack, $needle) + 1;
-         $data = substr($haystack, $pos, strlen($haystack));
-      } else {
-         $data = $haystack;
-      }
-      return $data;
+      ereg("^$needle?([^$needle]+)$needle*",strrev($haystack),$regs);
+        return strrev($regs[1]);
    }
 
    // Searches for the next position in a string minus white space
    }
 
    // Searches for the next position in a string minus white space
       if (trim($text) == "") {
          return;
       }
       if (trim($text) == "") {
          return;
       }
-      $text = str_replace(" ", "", $text);
-      $text = ereg_replace( '"[^"]*"', "", $text);
-      $text = str_replace(",", ";", $text);
-      $array = explode(";", $text);
-      for ($i = 0; $i < count ($array); $i++) {
-                           $array[$i] = eregi_replace ("^.*[<]", "", $array[$i]);
-                           $array[$i] = eregi_replace ("[>].*$", "", $array[$i]);
-                 }
-      return $array;
+      $text=ereg_replace("[;,][^<]*<* *([^>]*) *>*",";\\1",",$text");
+      return split("[;]", substr($text,1));
    }
 
    /** Returns a line of comma separated email addresses from an array **/
    }
 
    /** Returns a line of comma separated email addresses from an array **/
          
          // We need to do it twice to catch times where there
          // are an odd number of spaces
          
          // We need to do it twice to catch times where there
          // are an odd number of spaces
-         if (ereg("^ (.*)$", $line, $regs))
-             $line = "&nbsp;" . $regs[1];
+         $line = ereg_replace("^ ", "&nbsp;", $line);
          $line = str_replace('  ', '&nbsp; ', $line);
          $line = str_replace('  ', '&nbsp; ', $line);
          $line = nl2br($line);
          $line = str_replace('  ', '&nbsp; ', $line);
          $line = str_replace('  ', '&nbsp; ', $line);
          $line = nl2br($line);
 
 
    function find_mailbox_name ($mailbox) {
 
 
    function find_mailbox_name ($mailbox) {
+/*
       $mailbox = trim($mailbox);
       if (substr($mailbox, strlen($mailbox)-1, strlen($mailbox)) == "\"") {
          $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
       $mailbox = trim($mailbox);
       if (substr($mailbox, strlen($mailbox)-1, strlen($mailbox)) == "\"") {
          $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
          $box = substr($mailbox, strrpos($mailbox, " ")+1, strlen($mailbox));
       }
       return $box;
          $box = substr($mailbox, strrpos($mailbox, " ")+1, strlen($mailbox));
       }
       return $box;
+*/      
+
+      if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs))
+          return $regs[1];
+      ereg(" *([^ \r\n\"]*)[ \r\n]*$",$mailbox,$regs);
+      return $regs[1];
+
    }
 
    function replace_spaces ($string) {
    }
 
    function replace_spaces ($string) {
index 8b6a5f543e6d829e4dc15b24480ae77f7754c8f6..87fb326cdaa29da6bead55d20ca18b9b61456dab 100644 (file)
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
    sqimap_mailbox_select($imapConnection, $mailbox);
 
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
    sqimap_mailbox_select($imapConnection, $mailbox);
 
+   // expunge-on-demand if user isn't using move_to_trash or auto_expunge
+   if($expungeButton) {
+     sqimap_mailbox_expunge($imapConnection, $mailbox);
+     $location = get_location();
+     if ($where && $what)
+       header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
+     else   
+       header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
+   }
+   // undelete messages if user isn't using move_to_trash or auto_expunge
+   elseif($undeleteButton) {
+      if (is_array($msg) == 1) {
+         // Removes \Deleted flag from selected messages
+         $j = 0;
+         $i = 0;
+      
+         // If they have selected nothing msg is size one still, but will be an infinite
+         //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
+         while ($j < count($msg)) {
+            if ($msg[$i]) {
+              sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
+               $j++;
+            }
+            $i++;
+         }
+         $location = get_location();
+
+         if ($where && $what)
+            header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
+         else   
+            header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
+      } else {
+         displayPageHeader($color, $mailbox);
+         error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
+      }
+   }
    // If the delete button was pressed, the moveButton variable will not be set.
    // If the delete button was pressed, the moveButton variable will not be set.
-   if (!$moveButton) {
+   elseif (!$moveButton) {
       if (is_array($msg) == 1) {
          // Marks the selected messages ad 'Deleted'
          $j = 0;
       if (is_array($msg) == 1) {
          // Marks the selected messages ad 'Deleted'
          $j = 0;