Преглед на файлове

Respect the permanentflags output. Do not show the alter flags buttons
/links if the mailbox does not allow it.

stekkel преди 21 години
родител
ревизия
d024fa15b0
променени са 3 файла, в които са добавени 140 реда и са изтрити 125 реда
  1. 50 48
      functions/imap_mailbox.php
  2. 40 32
      functions/mailbox_display.php
  3. 50 45
      src/read_body.php

+ 50 - 48
functions/imap_mailbox.php

@@ -1,5 +1,4 @@
 <?php
 <?php
-
 /**
 /**
  * imap_mailbox.php
  * imap_mailbox.php
  *
  *
@@ -20,12 +19,12 @@ global $boxesnew;
 
 
 /**
 /**
  * Mailboxes class
  * Mailboxes class
- * 
- * FIXME. This class should be extracted and placed in a separate file that 
+ *
+ * FIXME. This class should be extracted and placed in a separate file that
  * can be included before we start the session. That makes caching of the tree
  * can be included before we start the session. That makes caching of the tree
- * possible. On a refresh mailboxes from left_main.php the only function that 
- * should be called is the sqimap_get_status_mbx_tree. In case of subscribe 
- * / rename / delete / new we have to create methods for adding/changing the 
+ * possible. On a refresh mailboxes from left_main.php the only function that
+ * should be called is the sqimap_get_status_mbx_tree. In case of subscribe
+ * / rename / delete / new we have to create methods for adding/changing the
  * mailbox in the mbx_tree without the need for a refresh.
  * mailbox in the mbx_tree without the need for a refresh.
  * @package squirrelmail
  * @package squirrelmail
 */
 */
@@ -33,7 +32,7 @@ global $boxesnew;
 class mailboxes {
 class mailboxes {
     var $mailboxname_full = '', $mailboxname_sub= '', $is_noselect = false, $is_noinferiors = false,
     var $mailboxname_full = '', $mailboxname_sub= '', $is_noselect = false, $is_noinferiors = false,
         $is_special = false, $is_root = false, $is_inbox = false, $is_sent = false,
         $is_special = false, $is_root = false, $is_inbox = false, $is_sent = false,
-        $is_trash = false, $is_draft = false,  $mbxs = array(), 
+        $is_trash = false, $is_draft = false,  $mbxs = array(),
         $unseen = false, $total = false;
         $unseen = false, $total = false;
 
 
     function addMbx($mbx, $delimiter, $start, $specialfirst) {
     function addMbx($mbx, $delimiter, $start, $specialfirst) {
@@ -86,14 +85,14 @@ function sortSpecialMbx($a, $b) {
     } else {
     } else {
         $bcmp = '2' . $b->mailboxname_full;
         $bcmp = '2' . $b->mailboxname_full;
     }
     }
-    return strnatcasecmp($acmp, $bcmp);	
+    return strnatcasecmp($acmp, $bcmp);
 }
 }
 
 
 function compact_mailboxes_response($ary)
 function compact_mailboxes_response($ary)
 {
 {
     /*
     /*
      * Workaround for mailboxes returned as literal
      * Workaround for mailboxes returned as literal
-     * FIXME : Doesn't work if the mailbox name is multiple lines 
+     * FIXME : Doesn't work if the mailbox name is multiple lines
      * (larger then fgets buffer)
      * (larger then fgets buffer)
      */
      */
     for ($i = 0, $iCnt=count($ary); $i < $iCnt; $i++) {
     for ($i = 0, $iCnt=count($ary); $i < $iCnt; $i++) {
@@ -157,13 +156,13 @@ function readMailboxParent($haystack, $needle) {
     return( $ret );
     return( $ret );
 }
 }
 
 
-/** 
+/**
  * Check if $subbox is below the specified $parentbox
  * Check if $subbox is below the specified $parentbox
  */
  */
 function isBoxBelow( $subbox, $parentbox ) {
 function isBoxBelow( $subbox, $parentbox ) {
     global $delimiter;
     global $delimiter;
-    /* 
-     * Eliminate the obvious mismatch, where the 
+    /*
+     * Eliminate the obvious mismatch, where the
      * subfolder path is shorter than that of the potential parent
      * subfolder path is shorter than that of the potential parent
      */
      */
     if ( strlen($subbox) < strlen($parentbox) ) {
     if ( strlen($subbox) < strlen($parentbox) ) {
@@ -250,17 +249,17 @@ function sqimap_mailbox_expunge ($imap_stream, $mailbox, $handle_errors = true,
 
 
 /**
 /**
  * Expunge specified message, updated $msgs and $msort
  * Expunge specified message, updated $msgs and $msort
- * 
- * Until Marc and I come up with a better way to maintain 
- * these stupid arrays, we'll use this wrapper function to 
+ *
+ * Until Marc and I come up with a better way to maintain
+ * these stupid arrays, we'll use this wrapper function to
  * remove the message with the matching UID .. the order
  * remove the message with the matching UID .. the order
  * won't be changed - the array element for the message
  * won't be changed - the array element for the message
  * will just be removed.
  * will just be removed.
  */
  */
 function sqimap_mailbox_expunge_dmn($message_id, $aMbxResponse, &$server_sort_array)
 function sqimap_mailbox_expunge_dmn($message_id, $aMbxResponse, &$server_sort_array)
 {
 {
-    global $msgs, $msort, $sort, $imapConnection, 
-           $mailbox, $auto_expunge, 
+    global $msgs, $msort, $sort, $imapConnection,
+           $mailbox, $auto_expunge,
            $sort, $allow_server_sort, $thread_sort_messages, $allow_thread_sort,
            $sort, $allow_server_sort, $thread_sort_messages, $allow_thread_sort,
            $username, $data_dir;
            $username, $data_dir;
     $cnt = 0;
     $cnt = 0;
@@ -270,15 +269,15 @@ function sqimap_mailbox_expunge_dmn($message_id, $aMbxResponse, &$server_sort_ar
     }
     }
     // Got to grab this out of prefs, since it isn't saved from mailbox_view.php
     // Got to grab this out of prefs, since it isn't saved from mailbox_view.php
     if ($allow_thread_sort) {
     if ($allow_thread_sort) {
-        $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox",0); 
+        $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox",0);
     }
     }
 
 
     for ($i = 0; $i < count($msort); $i++) {
     for ($i = 0; $i < count($msort); $i++) {
         if ($msgs[$i]['ID'] == $message_id) {
         if ($msgs[$i]['ID'] == $message_id) {
-            break;   
+            break;
         }
         }
     }
     }
-    
+
     if ( isset($msgs) ) {
     if ( isset($msgs) ) {
         unset($msgs[$i]);
         unset($msgs[$i]);
         $msgs = array_values($msgs);
         $msgs = array_values($msgs);
@@ -303,7 +302,7 @@ function sqimap_mailbox_expunge_dmn($message_id, $aMbxResponse, &$server_sort_ar
     if ( $allow_thread_sort && $thread_sort_messages ) {
     if ( $allow_thread_sort && $thread_sort_messages ) {
         $server_sort_array = get_thread_sort($imapConnection);
         $server_sort_array = get_thread_sort($imapConnection);
     } elseif ( $allow_server_sort ) {
     } elseif ( $allow_server_sort ) {
-        if (is_array($server_sort_array)) { 
+        if (is_array($server_sort_array)) {
             $key = array_search($message_id,$server_sort_array,true);
             $key = array_search($message_id,$server_sort_array,true);
             if ($key !== false) {
             if ($key !== false) {
                 unset($server_sort_array[$key]);
                 unset($server_sort_array[$key]);
@@ -353,15 +352,18 @@ function sqimap_mailbox_select ($imap_stream, $mailbox) {
         } else {
         } else {
             if (preg_match("/PERMANENTFLAGS(.*)/i",$read[$i], $regs)) {
             if (preg_match("/PERMANENTFLAGS(.*)/i",$read[$i], $regs)) {
                 $regs[1]=trim(preg_replace (  array ("/\(/","/\)/","/\]/") ,'', $regs[1])) ;
                 $regs[1]=trim(preg_replace (  array ("/\(/","/\)/","/\]/") ,'', $regs[1])) ;
-                $result['PERMANENTFLAGS'] = $regs[1];
+                $result['PERMANENTFLAGS'] = explode(' ',strtolower($regs[1]));
             } else if (preg_match("/FLAGS(.*)/i",$read[$i], $regs)) {
             } else if (preg_match("/FLAGS(.*)/i",$read[$i], $regs)) {
                 $regs[1]=trim(preg_replace (  array ("/\(/","/\)/") ,'', $regs[1])) ;
                 $regs[1]=trim(preg_replace (  array ("/\(/","/\)/") ,'', $regs[1])) ;
-                $result['FLAGS'] = $regs[1];
+                $result['FLAGS'] = explode(' ',strtolower($regs[1]));
             }
             }
         }
         }
     }
     }
+    if (!isset($result['PERMANENTFLAGS'])) {
+        $result['PERMANENTFLAGS'] = $result['FLAGS'];
+    }
     if (preg_match('/^\[(.+)\]/',$message, $regs)) {
     if (preg_match('/^\[(.+)\]/',$message, $regs)) {
-        $result['RIGHTS']=$regs[1];
+        $result['RIGHTS']=strtoupper($regs[1]);
     }
     }
 
 
     return $result;
     return $result;
@@ -541,7 +543,7 @@ function sqimap_mailbox_parse ($line, $line_lsub) {
         $boxesall[$g]['flags'] = array();
         $boxesall[$g]['flags'] = array();
         if (isset($line[$g])) {
         if (isset($line[$g])) {
             ereg("\(([^)]*)\)",$line[$g],$regs);
             ereg("\(([^)]*)\)",$line[$g],$regs);
-            // FIXME Flags do contain the \ character. \NoSelect \NoInferiors 
+            // FIXME Flags do contain the \ character. \NoSelect \NoInferiors
             // and $MDNSent <= last one doesn't have the \
             // and $MDNSent <= last one doesn't have the \
             // It's better to follow RFC3501 instead of using our own naming.
             // It's better to follow RFC3501 instead of using our own naming.
             $flags = trim(strtolower(str_replace('\\', '',$regs[1])));
             $flags = trim(strtolower(str_replace('\\', '',$regs[1])));
@@ -571,7 +573,7 @@ function sqimap_mailbox_parse ($line, $line_lsub) {
  *                 \NoSelect and \NoInferiors
  *                 \NoSelect and \NoInferiors
  *   $use_long_format - override folder display preference and always show full folder name.
  *   $use_long_format - override folder display preference and always show full folder name.
  */
  */
-function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_skip = 0, $boxes = 0, 
+function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_skip = 0, $boxes = 0,
                                     $flag = 'noselect', $use_long_format = false ) {
                                     $flag = 'noselect', $use_long_format = false ) {
     global $username, $data_dir;
     global $username, $data_dir;
     $mbox_options = '';
     $mbox_options = '';
@@ -592,13 +594,13 @@ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_sk
             if ($folder_skip != 0 && in_array($box, $folder_skip) ) {
             if ($folder_skip != 0 && in_array($box, $folder_skip) ) {
                 continue;
                 continue;
             }
             }
-            $lowerbox = strtolower($box); 
+            $lowerbox = strtolower($box);
             // mailboxes are casesensitive => inbox.sent != inbox.Sent
             // mailboxes are casesensitive => inbox.sent != inbox.Sent
             // nevermind, to many dependencies this should be fixed!
             // nevermind, to many dependencies this should be fixed!
-         
+
             if (strtolower($box) == 'inbox') { // inbox is special and not casesensitive
             if (strtolower($box) == 'inbox') { // inbox is special and not casesensitive
                 $box2 = _("INBOX");
                 $box2 = _("INBOX");
-            } else { 
+            } else {
                 switch ($shorten_box_names)
                 switch ($shorten_box_names)
                 {
                 {
                   case 2:   /* delimited, style = 2 */
                   case 2:   /* delimited, style = 2 */
@@ -623,7 +625,7 @@ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_sk
 }
 }
 
 
 /**
 /**
- * Returns sorted mailbox lists in several different ways. 
+ * Returns sorted mailbox lists in several different ways.
  * See comment on sqimap_mailbox_parse() for info about the returned array.
  * See comment on sqimap_mailbox_parse() for info about the returned array.
  */
  */
 
 
@@ -647,10 +649,10 @@ function sqimap_mailbox_list($imap_stream, $force=false) {
             $lsub = 'LIST (SUBSCRIBED)';
             $lsub = 'LIST (SUBSCRIBED)';
         } else {
         } else {
             $lsub = 'LSUB';
             $lsub = 'LSUB';
-        } 
-        
+        }
+
         if ($noselect_fix_enable) {
         if ($noselect_fix_enable) {
-            
+
             $lsub_args = "$lsub \"$folder_prefix\" \"*%\"";
             $lsub_args = "$lsub \"$folder_prefix\" \"*%\"";
         } else {
         } else {
             $lsub_args = "$lsub \"$folder_prefix\" \"*\"";
             $lsub_args = "$lsub \"$folder_prefix\" \"*\"";
@@ -658,7 +660,7 @@ function sqimap_mailbox_list($imap_stream, $force=false) {
         /* LSUB array */
         /* LSUB array */
         $lsub_ary = sqimap_run_command ($imap_stream, $lsub_args,
         $lsub_ary = sqimap_run_command ($imap_stream, $lsub_args,
                                         true, $response, $message);
                                         true, $response, $message);
-        $lsub_ary = compact_mailboxes_response($lsub_ary);       
+        $lsub_ary = compact_mailboxes_response($lsub_ary);
 
 
         $sorted_lsub_ary = array();
         $sorted_lsub_ary = array();
         for ($i = 0, $cnt = count($lsub_ary);$i < $cnt; $i++) {
         for ($i = 0, $cnt = count($lsub_ary);$i < $cnt; $i++) {
@@ -693,9 +695,9 @@ function sqimap_mailbox_list($imap_stream, $force=false) {
 
 
             $read = sqimap_run_command ($imap_stream, 'LIST "" ' . sqimap_encode_mailbox_name($mbx),
             $read = sqimap_run_command ($imap_stream, 'LIST "" ' . sqimap_encode_mailbox_name($mbx),
                                         true, $response, $message);
                                         true, $response, $message);
- 
+
             $read = compact_mailboxes_response($read);
             $read = compact_mailboxes_response($read);
- 
+
             if (isset($read[0])) {
             if (isset($read[0])) {
                 $sorted_list_ary[$i] = $read[0];
                 $sorted_list_ary[$i] = $read[0];
             } else {
             } else {
@@ -846,7 +848,7 @@ function sqimap_mailbox_tree($imap_stream) {
             if (preg_match("/^\*\s+LSUB.*\s\"?INBOX\"?[^(\/\.)].*$/i",$lsub_ary[$i])) {
             if (preg_match("/^\*\s+LSUB.*\s\"?INBOX\"?[^(\/\.)].*$/i",$lsub_ary[$i])) {
 	        $lsub_ary[$i] = strtoupper($lsub_ary[$i]);
 	        $lsub_ary[$i] = strtoupper($lsub_ary[$i]);
                 // in case of an unsubscribed inbox an imap server can
                 // in case of an unsubscribed inbox an imap server can
-                // return the inbox in the lsub results with a \NoSelect 
+                // return the inbox in the lsub results with a \NoSelect
                 // flag.
                 // flag.
                 if (!preg_match("/\*\s+LSUB\s+\(.*\\\\NoSelect.*\).*/i",$lsub_ary[$i])) {
                 if (!preg_match("/\*\s+LSUB\s+\(.*\\\\NoSelect.*\).*/i",$lsub_ary[$i])) {
                     $has_inbox = true;
                     $has_inbox = true;
@@ -854,7 +856,7 @@ function sqimap_mailbox_tree($imap_stream) {
                     // remove the result and request it again  with a list
                     // remove the result and request it again  with a list
                     // response at a later stage.
                     // response at a later stage.
                     unset($lsub_ary[$i]);
                     unset($lsub_ary[$i]);
-                    // re-index the array otherwise the addition of the LIST 
+                    // re-index the array otherwise the addition of the LIST
                     // response will fail in PHP 4.1.2 and probably other older versions
                     // response will fail in PHP 4.1.2 and probably other older versions
                     $lsub_ary = array_values($lsub_ary);
                     $lsub_ary = array_values($lsub_ary);
                 }
                 }
@@ -874,7 +876,7 @@ function sqimap_mailbox_tree($imap_stream) {
         }
         }
 
 
         /*
         /*
-         * Section about removing the last element was removed 
+         * Section about removing the last element was removed
          * We don't return "* OK" anymore from sqimap_read_data
          * We don't return "* OK" anymore from sqimap_read_data
          */
          */
 
 
@@ -884,14 +886,14 @@ function sqimap_mailbox_tree($imap_stream) {
             $mbx = find_mailbox_name($lsub_ary[$i]);
             $mbx = find_mailbox_name($lsub_ary[$i]);
 
 
             // only do the noselect test if !uw, is checked later. FIX ME see conf.pl setting
             // only do the noselect test if !uw, is checked later. FIX ME see conf.pl setting
-            if ($imap_server_type != "uw") {                
+            if ($imap_server_type != "uw") {
                 $noselect = check_is_noselect($lsub_ary[$i]);
                 $noselect = check_is_noselect($lsub_ary[$i]);
                 $noinferiors = check_is_noinferiors($lsub_ary[$i]);
                 $noinferiors = check_is_noinferiors($lsub_ary[$i]);
             }
             }
             if (substr($mbx, -1) == $delimiter) {
             if (substr($mbx, -1) == $delimiter) {
                 $mbx = substr($mbx, 0, strlen($mbx) - 1);
                 $mbx = substr($mbx, 0, strlen($mbx) - 1);
             }
             }
-            $sorted_lsub_ary[] = array ('mbx' => $mbx, 'noselect' => $noselect, 'noinferiors' => $noinferiors); 
+            $sorted_lsub_ary[] = array ('mbx' => $mbx, 'noselect' => $noselect, 'noinferiors' => $noinferiors);
         }
         }
         // FIX ME this requires a config setting inside conf.pl instead of checking on server type
         // FIX ME this requires a config setting inside conf.pl instead of checking on server type
         if ($imap_server_type == "uw") {
         if ($imap_server_type == "uw") {
@@ -902,7 +904,7 @@ function sqimap_mailbox_tree($imap_stream) {
                $mbx = stripslashes($aMbx['mbx']);
                $mbx = stripslashes($aMbx['mbx']);
                sqimap_prepare_pipelined_query('LIST "" ' . sqimap_encode_mailbox_name($mbx), $tag, $aQuery, false);
                sqimap_prepare_pipelined_query('LIST "" ' . sqimap_encode_mailbox_name($mbx), $tag, $aQuery, false);
                $aTag[$tag] = $mbx;
                $aTag[$tag] = $mbx;
-           } 
+           }
            $sorted_lsub_ary = array();
            $sorted_lsub_ary = array();
            // execute all the queries at once
            // execute all the queries at once
            $aResponse = sqimap_run_pipelined_command ($imap_stream, $aQuery, false, $aServerResponse, $aServerMessage);
            $aResponse = sqimap_run_pipelined_command ($imap_stream, $aQuery, false, $aServerResponse, $aServerMessage);
@@ -958,7 +960,7 @@ function sqimap_fill_mailbox_tree($mbx_ary, $mbxs=false,$imap_stream) {
             $mbx = new mailboxes();
             $mbx = new mailboxes();
             $mailbox = $mbx_ary[$i]['mbx'];
             $mailbox = $mbx_ary[$i]['mbx'];
 
 
-            /* 
+            /*
                 sent subfolders messes up using existing code as subfolders
                 sent subfolders messes up using existing code as subfolders
                 were marked, but the parents were ordered somewhere else in
                 were marked, but the parents were ordered somewhere else in
                 the list, despite having "special folders at top" option set.
                 the list, despite having "special folders at top" option set.
@@ -1001,7 +1003,7 @@ function sqimap_fill_mailbox_tree($mbx_ary, $mbxs=false,$imap_stream) {
             $mbx->is_special |= ($mbx->is_draft = isDraftMailbox($mailbox));
             $mbx->is_special |= ($mbx->is_draft = isDraftMailbox($mailbox));
             if (!$mbx->is_special)
             if (!$mbx->is_special)
                 $mbx->is_special = boolean_hook_function('special_mailbox', $mailbox, 1);
                 $mbx->is_special = boolean_hook_function('special_mailbox', $mailbox, 1);
-            
+
             if (isset($mbx_ary[$i]['unseen'])) {
             if (isset($mbx_ary[$i]['unseen'])) {
                 $mbx->unseen = $mbx_ary[$i]['unseen'];
                 $mbx->unseen = $mbx_ary[$i]['unseen'];
             }
             }
@@ -1051,7 +1053,7 @@ function sqimap_tree_to_ref_array(&$mbx_tree,&$aMbxs) {
          sqimap_tree_to_ref_array($mbx_tree->mbxs[$i],$aMbxs);
          sqimap_tree_to_ref_array($mbx_tree->mbxs[$i],$aMbxs);
       }
       }
    }
    }
-} 
+}
 
 
 function sqimap_get_status_mbx_tree($imap_stream,&$mbx_tree) {
 function sqimap_get_status_mbx_tree($imap_stream,&$mbx_tree) {
     global $unseen_notify, $unseen_type, $trash_folder,$move_to_trash;
     global $unseen_notify, $unseen_type, $trash_folder,$move_to_trash;
@@ -1103,7 +1105,7 @@ function sqimap_get_status_mbx_tree($imap_stream,&$mbx_tree) {
             $oMbx =& $aMbxs[$i];
             $oMbx =& $aMbxs[$i];
             if (strtoupper($oMbx->mailboxname_full) == 'INBOX' ||
             if (strtoupper($oMbx->mailboxname_full) == 'INBOX' ||
                ($move_to_trash && $oMbx->mailboxname_full == $trash_folder)) {
                ($move_to_trash && $oMbx->mailboxname_full == $trash_folder)) {
-                 if ($unseen_type == 2 || 
+                 if ($unseen_type == 2 ||
                    ($oMbx->mailboxname_full == $trash_folder && $move_to_trash)) {
                    ($oMbx->mailboxname_full == $trash_folder && $move_to_trash)) {
                     $aStatus = sqimap_status_messages($imap_stream,$oMbx->mailboxname_full);
                     $aStatus = sqimap_status_messages($imap_stream,$oMbx->mailboxname_full);
                     $oMbx->unseen = $aStatus['UNSEEN'];
                     $oMbx->unseen = $aStatus['UNSEEN'];
@@ -1122,7 +1124,7 @@ function sqimap_get_status_mbx_tree($imap_stream,&$mbx_tree) {
                 }
                 }
             }
             }
         }
         }
-    }       
-} 
+    }
+}
 
 
 ?>
 ?>

+ 40 - 32
functions/mailbox_display.php

@@ -59,7 +59,7 @@ function elapsed($start)
 function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
 function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
                           $start_msg, $where, $what) {
                           $start_msg, $where, $what) {
     global $checkall,
     global $checkall,
-           $color, $msgs, $msort, $td_str, $msg, 
+           $color, $msgs, $msort, $td_str, $msg,
            $default_use_priority,
            $default_use_priority,
            $message_highlight_list,
            $message_highlight_list,
            $index_order,
            $index_order,
@@ -111,7 +111,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
     else
     else
         $bHandleAsSent = $bSentFolder;
         $bHandleAsSent = $bSentFolder;
     // If this is a Sent message, display To address instead of From
     // If this is a Sent message, display To address instead of From
-    if ($bHandleAsSent)	
+    if ($bHandleAsSent)
        $msg['FROM'] = $msg['TO'];
        $msg['FROM'] = $msg['TO'];
     // Passing 1 below results in only 1 address being parsed, thus defeating the following code
     // Passing 1 below results in only 1 address being parsed, thus defeating the following code
     $msg['FROM'] = parseAddress($msg['FROM']/*,1*/);
     $msg['FROM'] = parseAddress($msg['FROM']/*,1*/);
@@ -217,7 +217,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
                             $headertest = strtolower(decodeHeader($msg[$match_type], true, false));
                             $headertest = strtolower(decodeHeader($msg[$match_type], true, false));
                             if (strstr('^^' . $headertest, $high_val)) {
                             if (strstr('^^' . $headertest, $high_val)) {
                                 $hlt_color = $message_highlight_list_part['color'];
                                 $hlt_color = $message_highlight_list_part['color'];
-                                break 3; 
+                                break 3;
                             }
                             }
                             break;
                             break;
                     }
                     }
@@ -237,7 +237,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
             switch ($index_order_part) {
             switch ($index_order_part) {
             case 1: /* checkbox */
             case 1: /* checkbox */
                 echo html_tag( 'td',
                 echo html_tag( 'td',
-		               addCheckBox("msg[$t]", $checkall, $msg['ID']), 
+		               addCheckBox("msg[$t]", $checkall, $msg['ID']),
                                'center',
                                'center',
                                $hlt_color );
                                $hlt_color );
                 break;
                 break;
@@ -656,7 +656,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
 <table border="0" width="100%" cellpadding="0" cellspacing="0">
 <table border="0" width="100%" cellpadding="0" cellspacing="0">
   <tr>
   <tr>
     <td>
     <td>
-      <?php mail_message_listing_beginning($imapConnection, $mbxresponse, $mailbox, $sort, 
+      <?php mail_message_listing_beginning($imapConnection, $mbxresponse, $mailbox, $sort,
                                            $msg_cnt_str, $paginator_str, $start_msg); ?>
                                            $msg_cnt_str, $paginator_str, $start_msg); ?>
     </td>
     </td>
   </tr>
   </tr>
@@ -669,9 +669,9 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
             <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>">
             <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>">
               <tr>
               <tr>
                 <td>
                 <td>
-                  <?php 
+                  <?php
                     printHeader($mailbox, $srt, $color, !$thread_sort_messages, $start_msg);
                     printHeader($mailbox, $srt, $color, !$thread_sort_messages, $start_msg);
-                    displayMessageArray($imapConnection, $num_msgs, $start_msg, 
+                    displayMessageArray($imapConnection, $num_msgs, $start_msg,
 		                                $msort, $mailbox, $sort, $color, $show_num,0,0);
 		                                $msort, $mailbox, $sort, $color, $show_num,0,0);
                   ?>
                   ?>
                 </td>
                 </td>
@@ -681,7 +681,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
         </tr>
         </tr>
       </table>
       </table>
       <?php
       <?php
-        mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color); 
+        mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color);
       ?>
       ?>
     </td>
     </td>
   </tr>
   </tr>
@@ -853,7 +853,7 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
  * To finish the table, you need to do a "</table></table>";
  * To finish the table, you need to do a "</table></table>";
  *
  *
  * @param mixed $imapConnection
  * @param mixed $imapConnection
- * @param array $mbxresponse the array with the results of SELECT against the current mailbox 
+ * @param array $mbxresponse the array with the results of SELECT against the current mailbox
  * @param string $mailbox the current mailbox
  * @param string $mailbox the current mailbox
  * @param mixed $sort the current sorting method (-1 for no sorting available [searches])
  * @param mixed $sort the current sorting method (-1 for no sorting available [searches])
  * @param mixed $msg_cnt_str
  * @param mixed $msg_cnt_str
@@ -943,40 +943,48 @@ function mail_message_listing_beginning ($imapConnection,
               <tr>
               <tr>
                 <td align="left">
                 <td align="left">
                   <small><?php
                   <small><?php
-                    
+
                     // display flag buttons only if supported
                     // display flag buttons only if supported
-                    if ($show_flag_buttons && $mbxresponse != NULL && 
-                      strpos($mbxresponse['PERMANENTFLAGS'], '\\Flagged') !== FALSE) {
+                    if ($show_flag_buttons && $mbxresponse != NULL &&
+                      array_search('\\flagged',$mbxresponse['PERMANENTFLAGS'], true) !== FALSE) {
                         echo getButton('SUBMIT', 'markUnflagged',_("Unflag"));
                         echo getButton('SUBMIT', 'markUnflagged',_("Unflag"));
                         echo getButton('SUBMIT', 'markFlagged',_("Flag"));
                         echo getButton('SUBMIT', 'markFlagged',_("Flag"));
                         echo '&nbsp;';
                         echo '&nbsp;';
                     }
                     }
-                    echo getButton('SUBMIT', 'markUnread',_("Unread"));
-                    echo getButton('SUBMIT', 'markRead',_("Read"));
-                    echo '&nbsp;';
+                    if (array_search('\\seen',$mbxresponse['PERMANENTFLAGS'], true) !== FALSE) {
+                        echo getButton('SUBMIT', 'markUnread',_("Unread"));
+                        echo getButton('SUBMIT', 'markRead',_("Read"));
+                        echo '&nbsp;';
+                    }
 
 
                     echo getButton('SUBMIT', 'attache',_("Forward"));
                     echo getButton('SUBMIT', 'attache',_("Forward"));
                     echo '&nbsp;';
                     echo '&nbsp;';
-                    echo getButton('SUBMIT', 'delete',_("Delete"));
-                    echo '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash");
-                    echo '&nbsp;';
-                    if (!$auto_expunge) {
+                    if (array_search('\\deleted',$mbxresponse['PERMANENTFLAGS'], true) !== FALSE) {
+                        echo getButton('SUBMIT', 'delete',_("Delete"));
+                        echo '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash");
+                        echo '&nbsp;';
+                    }
+                    if (!$auto_expunge && $mbxresponse['RIGHTS'] != 'READ-ONLY') {
                       echo getButton('SUBMIT', 'expungeButton',_("Expunge"))  .'&nbsp;' . _("mailbox") . "\n";
                       echo getButton('SUBMIT', 'expungeButton',_("Expunge"))  .'&nbsp;' . _("mailbox") . "\n";
                       echo '&nbsp;';
                       echo '&nbsp;';
                     }
                     }
                     do_hook('mailbox_display_buttons');
                     do_hook('mailbox_display_buttons');
                   ?></small>
                   ?></small>
                 </td>
                 </td>
-                <td align="right">
-                  <small><?php
+                <?php
+                if (array_search('\\deleted',$mbxresponse['PERMANENTFLAGS'], true) !== FALSE) {
+                    echo '<td align="right">
+                  <small>';
                     //echo $thread_link_str;	//previous behaviour
                     //echo $thread_link_str;	//previous behaviour
-                    getMbxList($imapConnection);  
-                    echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n";
-                  ?></small>
+                    getMbxList($imapConnection);
+                    echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n
+                  </small>";
+                }
+                ?>
                 </td>
                 </td>
               </tr>
               </tr>
             </table>
             </table>
-          </td>    
+          </td>
         </tr>
         </tr>
       </table>
       </table>
 
 
@@ -1006,7 +1014,7 @@ function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $colo
     /* space between list and footer */
     /* space between list and footer */
 ?>
 ?>
   <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
   <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
-  <tr>  
+  <tr>
     <td>
     <td>
       <table width="100%" cellpadding="1"  cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
       <table width="100%" cellpadding="1"  cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
         <tr>
         <tr>
@@ -1048,7 +1056,7 @@ function printHeader($mailbox, $sort, $color, $showsort=true, $start_msg=1) {
     $widths = array(1=>1,2=>25,3=>5,4=>0,5=>1,6=>5);
     $widths = array(1=>1,2=>25,3=>5,4=>0,5=>1,6=>5);
     $subjectwidth = 100;
     $subjectwidth = 100;
     foreach($index_order as $item) {
     foreach($index_order as $item) {
-        $subjectwidth -= $widths[$item]; 
+        $subjectwidth -= $widths[$item];
     }
     }
 
 
     foreach ($index_order as $item) {
     foreach ($index_order as $item) {
@@ -1426,7 +1434,7 @@ function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
       /* Compute the 'show all' string. */
       /* Compute the 'show all' string. */
       $all_str = "<a href=\"right_main.php?PG_SHOWALL=1"
       $all_str = "<a href=\"right_main.php?PG_SHOWALL=1"
                  . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
                  . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
-                 . ">" . _("Show All") . '</a>'; 
+                 . ">" . _("Show All") . '</a>';
     }
     }
 
 
     $result .= ($pg_str  != '' ? $spc . '['.$spc.$pg_str.']' .  $spc : '');
     $result .= ($pg_str  != '' ? $spc . '['.$spc.$pg_str.']' .  $spc : '');
@@ -1456,7 +1464,7 @@ function truncateWithEntities($subject, $trim_at)
      * see if this is entities-encoded string
      * see if this is entities-encoded string
      * If so, Iterate through the whole string, find out
      * If so, Iterate through the whole string, find out
      * the real number of characters, and if more
      * the real number of characters, and if more
-     * than $trim_at, substr with an updated trim value. 
+     * than $trim_at, substr with an updated trim value.
      */
      */
     $trim_val = $trim_at;
     $trim_val = $trim_at;
     $ent_offset = 0;
     $ent_offset = 0;
@@ -1507,12 +1515,12 @@ function processSubject($subject, $threadlevel = 0) {
  * FIXME: Undocumented function
  * FIXME: Undocumented function
  *
  *
  * @param mixed $imapConnection
  * @param mixed $imapConnection
- * @param mixed $boxes 
+ * @param mixed $boxes
  */
  */
 function getMbxList($imapConnection, $boxes = 0) {
 function getMbxList($imapConnection, $boxes = 0) {
     global $lastTargetMailbox;
     global $lastTargetMailbox;
     echo  '         <small>&nbsp;<tt><select name="targetMailbox">';
     echo  '         <small>&nbsp;<tt><select name="targetMailbox">';
-    echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)), 0, $boxes); 
+    echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)), 0, $boxes);
     echo '         </select></tt>&nbsp;';
     echo '         </select></tt>&nbsp;';
 }
 }
 
 
@@ -1579,7 +1587,7 @@ function getEndMessage($start_msg, $show_num, $num_msgs) {
  */
  */
 function handleAsSent($mailbox) {
 function handleAsSent($mailbox) {
     global $handleAsSent_result;
     global $handleAsSent_result;
- 
+
     /* First check if this is the sent or draft folder. */
     /* First check if this is the sent or draft folder. */
     $handleAsSent_result = isSentMailbox($mailbox) || isDraftMailbox($mailbox);
     $handleAsSent_result = isSentMailbox($mailbox) || isDraftMailbox($mailbox);
 
 

+ 50 - 45
src/read_body.php

@@ -38,7 +38,7 @@ require_once(SM_PATH . 'functions/mailbox_display.php');
  * @return the index of the next valid message from the array
  * @return the index of the next valid message from the array
  */
  */
 function findNextMessage($passed_id) {
 function findNextMessage($passed_id) {
-    global $msort, $msgs, $sort, 
+    global $msort, $msgs, $sort,
            $thread_sort_messages, $allow_server_sort,
            $thread_sort_messages, $allow_server_sort,
            $server_sort_array;
            $server_sort_array;
     if (!is_array($server_sort_array)) {
     if (!is_array($server_sort_array)) {
@@ -54,7 +54,7 @@ function findNextMessage($passed_id) {
                     break;
                     break;
                 }
                 }
                 $result = $server_sort_array[$key + 1];
                 $result = $server_sort_array[$key + 1];
-                break; 
+                break;
             }
             }
         }
         }
     } else {
     } else {
@@ -120,7 +120,7 @@ function findPreviousMessage($numMessages, $passed_id) {
  * Displays a link to a page where the message is displayed more
  * Displays a link to a page where the message is displayed more
  * "printer friendly".
  * "printer friendly".
  * @param string $mailbox Name of current mailbox
  * @param string $mailbox Name of current mailbox
- * @param int $passed_id 
+ * @param int $passed_id
  */
  */
 function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) {
 function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) {
     global $javascript_on, $color;
     global $javascript_on, $color;
@@ -150,14 +150,16 @@ function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) {
     return $result;
     return $result;
 }
 }
 
 
-function ServerMDNSupport($read) {
-    /* escaping $ doesn't work -> \x36 */    
-    $ret = preg_match('/(\x36MDNSent|\\\\\*)/i', $read);
-    return $ret;
+function ServerMDNSupport($aFlags) {
+    /* escaping $ doesn't work -> \x36 */
+    return (array_search('$mdnsent',$aFlags,true) !== false ||
+            array_search('\\*',$aFlags,true) !== false) ? true : false;
+    //$ret = preg_match('/(\x36MDNSent|\\\\\*)/i', $read);
+    //return $ret;
 }
 }
 
 
 function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
 function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
-    global $username, $attachment_dir, 
+    global $username, $attachment_dir,
            $version, $attachments, $squirrelmail_language, $default_charset,
            $version, $attachments, $squirrelmail_language, $default_charset,
            $languages, $useSendmail, $domain, $sent_folder,
            $languages, $useSendmail, $domain, $sent_folder,
            $popuser, $data_dir, $username;
            $popuser, $data_dir, $username;
@@ -224,7 +226,7 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
             sprintf( _("Was displayed on %s"), $now );
             sprintf( _("Was displayed on %s"), $now );
 
 
     $special_encoding = '';
     $special_encoding = '';
-    if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && 
+    if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
         function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
         function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
         $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
         $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
         if (strtolower($default_charset) == 'iso-2022-jp') {
         if (strtolower($default_charset) == 'iso-2022-jp') {
@@ -320,7 +322,7 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
 function ToggleMDNflag ($set ,$imapConnection, $mailbox, $passed_id) {
 function ToggleMDNflag ($set ,$imapConnection, $mailbox, $passed_id) {
     $sg   =  $set?'+':'-';
     $sg   =  $set?'+':'-';
     $cmd  = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
     $cmd  = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
-    $read = sqimap_run_command ($imapConnection, $cmd, true, $response, 
+    $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
                                 $readmessage, TRUE);
                                 $readmessage, TRUE);
 }
 }
 
 
@@ -398,7 +400,7 @@ function formatRecipientString($recipients, $item ) {
     return $string;
     return $string;
 }
 }
 
 
-function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, 
+function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
                          $color, $FirstTimeSee) {
                          $color, $FirstTimeSee) {
     global $msn_user_support, $default_use_mdn, $default_use_priority,
     global $msn_user_support, $default_use_mdn, $default_use_priority,
            $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on,
            $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on,
@@ -431,8 +433,8 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
                 if ($message->is_mdnsent) {
                 if ($message->is_mdnsent) {
                     $env[_("Read receipt")] = _("sent");
                     $env[_("Read receipt")] = _("sent");
                 } else {
                 } else {
-                    $env[_("Read receipt")] = _("requested"); 
-                    if (!(handleAsSent($mailbox) || 
+                    $env[_("Read receipt")] = _("requested");
+                    if (!(handleAsSent($mailbox) ||
                           $message->is_deleted ||
                           $message->is_deleted ||
                           $passed_ent_id)) {
                           $passed_ent_id)) {
                         $mdn_url = $PHP_SELF . '&sendreceipt=1';
                         $mdn_url = $PHP_SELF . '&sendreceipt=1';
@@ -479,8 +481,8 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
 }
 }
 
 
 /**
 /**
- * Format message toolbar 
- * 
+ * Format message toolbar
+ *
  * @param string $mailbox Name of current mailbox
  * @param string $mailbox Name of current mailbox
  * @param int $passed_id UID of current message
  * @param int $passed_id UID of current message
  * @param int $passed_ent_id Id of entity within message
  * @param int $passed_ent_id Id of entity within message
@@ -489,7 +491,7 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
  */
  */
 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response, $nav_on_top = TRUE) {
 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response, $nav_on_top = TRUE) {
     global $base_uri, $draft_folder, $where, $what, $color, $sort,
     global $base_uri, $draft_folder, $where, $what, $color, $sort,
-           $startMessage, $PHP_SELF, $save_as_draft, 
+           $startMessage, $PHP_SELF, $save_as_draft,
            $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox,
            $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox,
            $data_dir, $username, $delete_prev_next_display,
            $data_dir, $username, $delete_prev_next_display,
            $compose_new_win, $javascript_on;
            $compose_new_win, $javascript_on;
@@ -573,14 +575,15 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
 
 
         // Only bother with Delete & Prev and Delete & Next IF
         // Only bother with Delete & Prev and Delete & Next IF
         // top display is enabled.
         // top display is enabled.
-        if ( $delete_prev_next_display == 1 ) {
+        if ( $delete_prev_next_display == 1 &&
+               array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) {
             $del_prev_link = _("Delete & Prev");
             $del_prev_link = _("Delete & Prev");
             if ($prev >= 0) {
             if ($prev >= 0) {
                 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
                 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
                        '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
                        '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
                        '&amp;startMessage='.$startMessage.'&amp;show_more=0'.
                        '&amp;startMessage='.$startMessage.'&amp;show_more=0'.
                        '&amp;delete_id='.$passed_id;
                        '&amp;delete_id='.$passed_id;
-                $del_prev_link = '<a href="'.$uri.'">'.$del_prev_link.'</a>';       
+                $del_prev_link = '<a href="'.$uri.'">'.$del_prev_link.'</a>';
             }
             }
 
 
             $del_next_link = _("Delete & Next");
             $del_next_link = _("Delete & Next");
@@ -621,8 +624,8 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
                 '&amp;mailbox=' . $urlMailbox .
                 '&amp;mailbox=' . $urlMailbox .
                 '&amp;startMessage=' . $startMessage .
                 '&amp;startMessage=' . $startMessage .
                  (isset($passed_ent_id) ? '&amp;passed_ent_id='.$passed_ent_id : '');
                  (isset($passed_ent_id) ? '&amp;passed_ent_id='.$passed_ent_id : '');
- 
-    // Start form for reply/reply all/forward.. 
+
+    // Start form for reply/reply all/forward..
     $target = '';
     $target = '';
     $on_click='';
     $on_click='';
     $method='method="post" ';
     $method='method="post" ';
@@ -659,33 +662,35 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
 
 
     $menu_row .= '</form>&nbsp;';
     $menu_row .= '</form>&nbsp;';
 
 
+    if (array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) {
     // Form for deletion
     // Form for deletion
-    $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox;
-    $menu_row .= '<form action="'.$delete_url.'" method="post" style="display: inline">';
+        $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox;
+        $menu_row .= '<form action="'.$delete_url.'" method="post" style="display: inline">';
 
 
-    if (!(isset($passed_ent_id) && $passed_ent_id)) {
-        $menu_row .= addHidden('message', $passed_id);
+        if (!(isset($passed_ent_id) && $passed_ent_id)) {
+            $menu_row .= addHidden('message', $passed_id);
 
 
-        if ($where && $what) {
-	    $menu_row .= addHidden('where', $where);
-	    $menu_row .= addHidden('what',  $what);
-        } else {
-	    $menu_row .= addHidden('sort',  $sort);
-	    $menu_row .= addHidden('startMessage', $startMessage);
+            if ($where && $what) {
+            $menu_row .= addHidden('where', $where);
+            $menu_row .= addHidden('what',  $what);
+            } else {
+            $menu_row .= addHidden('sort',  $sort);
+            $menu_row .= addHidden('startMessage', $startMessage);
+            }
+            $menu_row .= getButton('SUBMIT', 'delete', _("Delete"));
+            $menu_row .= '<input type="checkbox" name="bypass_trash">' . _("Bypass Trash");
         }
         }
-        $menu_row .= getButton('SUBMIT', 'delete', _("Delete"));
-        $menu_row .= '<input type="checkbox" name="bypass_trash">' . _("Bypass Trash");
-    }
-    else
-      $menu_row .= getButton('SUBMIT', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled
-
-    $menu_row .= '</form>';
+        else
+        $menu_row .= getButton('SUBMIT', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled
 
 
+        $menu_row .= '</form>';
+    }
 
 
     // Add top move link
     // Add top move link
     $menu_row .= '</small></td><td align="right">';
     $menu_row .= '</small></td><td align="right">';
-    if ( !(isset($passed_ent_id) && $passed_ent_id) ) {
-        
+    if ( !(isset($passed_ent_id) && $passed_ent_id) &&
+        array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) {
+
         $current_box = 'mailbox='.$mailbox.'&sort='.$sort.'&startMessage='.$startMessage;
         $current_box = 'mailbox='.$mailbox.'&sort='.$sort.'&startMessage='.$startMessage;
 
 
         // Set subsequent location based on whether or not there is a 'next' message.
         // Set subsequent location based on whether or not there is a 'next' message.
@@ -734,13 +739,13 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
 
 
 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
     global $base_uri, $where, $what;
     global $base_uri, $where, $what;
- 
+
     $urlMailbox = urlencode($mailbox);
     $urlMailbox = urlencode($mailbox);
     $urlPassed_id = urlencode($passed_id);
     $urlPassed_id = urlencode($passed_id);
     $urlPassed_ent_id = urlencode($passed_ent_id);
     $urlPassed_ent_id = urlencode($passed_ent_id);
- 
+
     $query_string = 'mailbox=' . $urlMailbox . '&amp;passed_id=' . $urlPassed_id . '&amp;passed_ent_id=' . $urlPassed_ent_id;
     $query_string = 'mailbox=' . $urlMailbox . '&amp;passed_id=' . $urlPassed_id . '&amp;passed_ent_id=' . $urlPassed_ent_id;
- 
+
     if (!empty($where)) {
     if (!empty($where)) {
         $query_string .= '&amp;where=' . urlencode($where);
         $query_string .= '&amp;where=' . urlencode($where);
     }
     }
@@ -925,7 +930,7 @@ echo html_tag( 'table' ,'' , 'left', '', 'cellpadding="1" cellspacing="5" border
 echo '              <tr>' . html_tag( 'td', '<br>'. $messagebody."\n", 'left')
 echo '              <tr>' . html_tag( 'td', '<br>'. $messagebody."\n", 'left')
                         . '</tr>';
                         . '</tr>';
 echo '            </table>';
 echo '            </table>';
-echo '          </td></tr>';      
+echo '          </td></tr>';
 echo '        </table></td></tr>';
 echo '        </table></td></tr>';
 echo '    </table>';
 echo '    </table>';
 echo '  </td></tr>';
 echo '  </td></tr>';
@@ -939,7 +944,7 @@ if ($attachmentsdisplay) {
    echo '    <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
    echo '    <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
    echo '     <tr><td>';
    echo '     <tr><td>';
    echo '       <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
    echo '       <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
-   echo '        <tr>' . html_tag( 'td', '', 'left', $color[9] );              
+   echo '        <tr>' . html_tag( 'td', '', 'left', $color[9] );
    echo '           <b>' . _("Attachments") . ':</b>';
    echo '           <b>' . _("Attachments") . ':</b>';
    echo '        </td></tr>';
    echo '        </td></tr>';
    echo '        <tr><td>';
    echo '        <tr><td>';
@@ -978,7 +983,7 @@ formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response, FAL
 do_hook('read_body_bottom');
 do_hook('read_body_bottom');
 do_hook('html_bottom');
 do_hook('html_bottom');
 sqimap_logout($imapConnection);
 sqimap_logout($imapConnection);
-/* sessions are written at the end of the script. it's better to register 
+/* sessions are written at the end of the script. it's better to register
    them at the end so we avoid double session_register calls */
    them at the end so we avoid double session_register calls */
 sqsession_register($messages,'messages');
 sqsession_register($messages,'messages');