don't STATUS a mailbox that isn't selectable
[squirrelmail.git] / functions / mailbox_display.php
index b978c33bc43da216897a9f12b99d798840a870e3..e91a1c7edcd63e28b05bfa194a343a67ff33a685 100644 (file)
  * $Id$
  */
 
-require_once('../functions/strings.php');
-require_once('../functions/html.php');
-require_once('../class/html.class');
-require_once('../functions/imap_utf7_decode_local.php');
+require_once(SM_PATH . 'functions/strings.php');
+require_once(SM_PATH . 'functions/html.php');
+require_once(SM_PATH . 'class/html.class.php');
+require_once(SM_PATH . 'functions/imap_mailbox.php');
 
 /* Default value for page_selector_max. */
 define('PG_SEL_MAX', 10);
 
 function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, 
-                          $start_msg) {
+                          $start_msg, $where, $what) {
     global $checkall,
            $color, $msgs, $msort,
            $default_use_priority,
@@ -109,6 +109,11 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
         $fontstr_end = '';
     }
 
+    if ($where && $what) {
+        $searchstr = '&where='.$where.'&what='.$what;
+    } else {
+        $searchstr = '';
+    }  
     /**
     * AAAAH! Make my eyes stop bleeding!
     * Who wrote this?!
@@ -178,8 +183,7 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
                 }
                 $td_str .= '<a href="read_body.php?mailbox='.$urlMailbox
                             .'&amp;passed_id='. $msg["ID"]
-                             . '&amp;startMessage='.$start_msg
-                            .'&amp;show_more=0"';
+                             . '&amp;startMessage='.$start_msg.$searchstr.'"';
                 do_hook("subject_link");
                 if ($subject != $msg['SUBJECT']) {
                     $title = get_html_translation_table(HTML_SPECIALCHARS);
@@ -345,6 +349,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
   if ($auto_expunge == true) {
      $exp_cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, false, '');
      $mbxresponse['EXISTS'] = $mbxresponse['EXISTS'] - $exp_cnt;
+     $num_msgs = $mbxresponse['EXISTS'];
   }
 
   if ($mbxresponse['EXISTS']>0) {
@@ -429,7 +434,9 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
      } // switch
   } /* if exists > 0 */
 
-  $end_msg = getEndMessage(&$start_msg, $show_num, $num_msgs);
+  $res = getEndMessage($start_msg, $show_num, $num_msgs);
+  $start_msg = $res[0]; 
+  $end_msg = $res[1];
 
   $paginator_str = get_paginator_str($mailbox, $start_msg, $end_msg, 
                                     $num_msgs, $show_num, $sort);
@@ -441,13 +448,15 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
   mail_message_listing_beginning($imapConnection, $mailbox, $sort, 
                                   $msg_cnt_str, $paginator_str, $start_msg);
 
-
+  
+  echo '<table bgcolor="' . $color[0] . '" border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td>';
   printHeader($mailbox, $srt, $color, !$thread_sort_messages);
 
   displayMessageArray($imapConnection, $num_msgs, $start_msg, 
                      $msort, $mailbox, $sort, $color, $show_num,0,0);
 
   mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color); 
+  echo '</td></tr></table>';
                      
   /**
    * TODO: Switch to using $_SESSION[] whenever we ditch the 4.0.x series.
@@ -561,7 +570,9 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
     $indent_array, $thread_sort_messages, $allow_server_sort, 
     $server_sort_order, $PHP_SELF;
 
-  $end_msg = getEndMessage(&$start_msg, $show_num, $num_msgs);
+  $res = getEndMessage($start_msg, $show_num, $num_msgs);
+  $start_msg = $res[0]; 
+  $end_msg = $res[1];
 
   $urlMailbox = urlencode($mailbox);
 
@@ -590,7 +601,7 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
   $t = 0;
 
   /* messages display */
-  echo  html_tag( 'table' ,'' , '', '', 'border="0" width="100%" cellpadding="1"  cellspacing="0"' );
+  
   if ($num_msgs == 0) {
     /* if there's no messages in this folder */
         echo html_tag( 'tr',
@@ -616,7 +627,7 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
       $k++;
     } while (isset ($key) && ($k < $i));
     printMessageInfo($imapConnection, $t, $i, $key, $mailbox,  
-                    $real_startMessage);
+                    $real_startMessage, $where, $what);
   } else {
     $i = $start_msg;
     reset($msort);
@@ -628,7 +639,7 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
     } while (isset ($key) && ($k < $i));
     do {
       printMessageInfo($imapConnection, $t, $i, $key, $mailbox, 
-                      $real_startMessage);
+                      $real_startMessage, $where, $what);
       $key = key($msort);
       $t++;
       $i++;
@@ -693,26 +704,32 @@ function mail_message_listing_beginning ($imapConnection,
         . html_tag( 'td' ,'' , 'left', $color[0], '' )
         . html_tag( 'table' ,'' , '', $color[0], 'border="0" width="100%" cellpadding="0"  cellspacing="0"' )
             . html_tag( 'tr',
-               getSmallStringCell(_("Move Selected To:"), 'left') .
+               getSmallStringCell(_("Move Selected To"), 'left') .
                getSmallStringCell(_("Transform Selected Messages"), 'right')
             )
             . html_tag( 'tr' ) ."\n"
             . html_tag( 'td', '', 'left', '', 'valign="middle" nowrap' );
             getMbxList($imapConnection);  
-            echo getButton('SUBMIT', 'moveButton',_("Move")) . '&nbsp;'."\n";   
-            echo getButton('SUBMIT', 'attache',_("Forward")) . '&nbsp;'."\n";   
+            echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n";   
+            echo getButton('SUBMIT', 'attache',_("Forward")) . "\n";   
 
   echo "      </TD>\n"
     . html_tag( 'td', '', 'right', '', 'nowrap' );
 
   if (!$auto_expunge) {
      echo getButton('SUBMIT', 'expungeButton',_("Expunge")) 
-          .'&nbsp;' . _("mailbox") . '&nbsp;'."\n";   
+          .'&nbsp;' . _("mailbox") . "\n";   
   }
   
-  echo getButton('SUBMIT', 'markRead',_("Read")) ."\n";   
-  echo getButton('SUBMIT', 'markUnread',_("Unread")) ."\n";   
-  echo getButton('SUBMIT', 'delete',_("Delete")) .'&nbsp;'."\n";
+  echo getButton('SUBMIT', 'markRead',_("Read"));
+  echo getButton('SUBMIT', 'markUnread',_("Unread"));
+  echo getButton('SUBMIT', 'delete',_("Delete")) ."&nbsp\n";
+  if (!strpos($PHP_SELF,'mailbox')) {
+     $location = $PHP_SELF.'?mailbox=INBOX&amp;startMessage=1';
+  } else {
+     $location = $PHP_SELF;
+  }
+  echo '<INPUT TYPE="HIDDEN" NAME="location" VALUE="'.$location.'">';
   echo "</TD>\n"
        . "   </TR>\n";
 
@@ -745,12 +762,6 @@ function mail_message_listing_beginning ($imapConnection,
     echo '</td></tr>'
     .  html_tag( 'tr' )
     . html_tag( 'td' ,'' , '', $color[0], '' );
-    if ($GLOBALS['alt_index_colors']){
-        $cellspacing =  '0';
-    } else {
-        $cellspacing = '1';
-    }
-    echo html_tag( 'table' ,'' , '', $color[0], 'border="0" width="100%" cellpadding="2"  cellspacing="'. $cellspacing .'"' );
 
     /* if using server sort we highjack the
     * the $sort var and use $server_sort_order
@@ -787,6 +798,7 @@ function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $colo
 
 function printHeader($mailbox, $sort, $color, $showsort=true) {
   global $index_order;
+    echo html_tag( 'table' ,'' , '', $color[4], 'border="0" width="100%" cellpadding="1" cellspacing="0"' );
     echo html_tag( 'tr' ,'' , 'center', $color[5] );
     for ($i=1; $i <= count($index_order); $i++) {
         switch ($index_order[$i]) {
@@ -940,6 +952,11 @@ function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
 function get_paginator_link($box, $start_msg, $use, $text) {
   global $PHP_SELF;
 
+  $result = "<A HREF=\"right_main.php?use_mailbox_cache=$use"
+    . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
+    . "TARGET=\"right\">$text</A>";
+  return ($result);
+/*
   if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
      $source_url = $regs[1];
   } else {
@@ -950,6 +967,7 @@ function get_paginator_link($box, $start_msg, $use, $text) {
     . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
     . "TARGET=\"right\">$text</A>";
   return ($result);
+*/  
 }
 
 /*
@@ -1154,6 +1172,7 @@ function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
 }
 
 function processSubject($subject) {
+    global $languages, $squirrelmail_language;
   /* Shouldn't ever happen -- caught too many times in the IMAP functions */
   if ($subject == '')
     return _("(no subject)");
@@ -1181,6 +1200,11 @@ function processSubject($subject) {
     return $subject;
   }
   
+  if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
+      function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
+      return $languages[$squirrelmail_language]['XTRA_CODE']('strimwidth', $subject, $trim_val);
+  }
+  
   return substr($subject, 0, $trim_val) . '...';
 }
 
@@ -1212,7 +1236,7 @@ return '<INPUT TYPE="'.$type.'" NAME="'.$name.'" VALUE="'.$value . '">';
 
 function getSmallStringCell($string, $align) {
   return html_tag( 'td',            
-            '<small>' . $string . ': &nbsp; </small>',
+            '<small>' . $string . ':&nbsp; </small>',
             $align,
             '',
             'nowrap' );
@@ -1231,7 +1255,7 @@ function getEndMessage($start_msg, $show_num, $num_msgs) {
       $start_msg = 1;
     }
   }
-  return $end_msg;
+  return (array($start_msg,$end_msg));
 }
 
 function handleAsSent($mailbox) {