more button display enhancements
[squirrelmail.git] / functions / mailbox_display.php
index 0a139ed1d9d141f602cb1404774929d5c5b1d0a3..982c1316803c53830820fa6df1a1ccb0f7bd384b 100644 (file)
  * $Id$
  */
 
-require_once('../functions/strings.php');
-require_once('../functions/html.php');
-require_once('../class/html.class.php');
-require_once('../functions/imap_mailbox.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);
@@ -149,7 +149,7 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
     $row->class = 'm_r';
     $row->id = 'mr'.$t;
     
-    
+    $col = 0;
     if (sizeof($index_order)){
         foreach ($index_order as $index_order_part) {
             switch ($index_order_part) {
@@ -158,6 +158,7 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
                                "<input type=checkbox name=\"msg[$t]\" value=\"".$msg['ID']."\"$checked>",
                                'center', 
                                $hlt_color );
+               ++$col;
                 break;
             case 2: /* from */
                 echo html_tag( 'td',
@@ -165,6 +166,7 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
                                $fontstr_end . $flag_end . $bold_end . $italic_end,
                                'left',
                                $hlt_color );
+               ++$col;                        
                 break;
             case 3: /* date */
                 echo html_tag( 'td',
@@ -173,6 +175,7 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
                                'center',
                                $hlt_color,
                                'nowrap' );
+               ++$col;                        
                 break;
             case 4: /* subject */
                 $td_str = $bold;
@@ -194,6 +197,7 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
                 }
                 $td_str .= ">$flag$subject$flag_end</a>$bold_end";
                 echo html_tag( 'td', $td_str, 'left', $hlt_color );
+               ++$col;         
                 break;
             case 5: /* flags */
                 $stuff = false;
@@ -230,6 +234,7 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
                                'center',
                                $hlt_color,
                                'nowrap' );
+               ++$col;                        
                 break;
             case 6: /* size */
 
@@ -238,11 +243,13 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
                                $fontstr_end . $bold_end,
                                'right',
                                $hlt_color );
+               ++$col;                        
                 break;
             }
         }
     }
-    echo "</tr>\n";
+    echo '</tr>'."\n".'<tr><td colspan="'.$col.'" BGCOLOR="'.
+                               $color[0].'" HEIGHT="1"></td></tr>'."\n";
 }
 
 function getThreadMessages($imapConnection, $start_msg, $show_num, $num_msgs) {
@@ -349,6 +356,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) {
@@ -379,8 +387,8 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
 
      switch ($mode) {
        case 'thread':
-           session_unregister('msort');
-            session_unregister('msgs');
+           sqsession_unregister('msort');
+            sqsession_unregister('msgs');
             $msgs = getThreadMessages($imapConnection, $start_msg, $show_num, 
                                      $num_msgs);
            if ($msgs === false) {
@@ -389,13 +397,13 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
                  '</center></small></b>';
                $thread_sort_messages = 0;
               $msort = $msgs = array();
-               session_register('msort');
-               session_register('msgs');           
+               sqsession_register($msort, 'msort');
+               sqsession_register($msgs, 'msgs');          
             } else {
               $msort= $msgs;
               $sort = 6;
-               session_register('msort');
-               session_register('msgs');
+               sqsession_register($msort, 'msort');
+               sqsession_register($msgs, 'msgs');
             }
         
         break;
@@ -409,31 +417,33 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
             $sort = $server_sort_order;
             $allow_server_sort = FALSE;
            $msort = $msgs = array();
-            session_register('msort');
-            session_register('msgs');      
+            sqsession_register($msort, 'msort');
+            sqsession_register($msgs, 'msgs');     
             $id = array();
          } else {
             $sort = 6;
            $msort = $msgs;         
-            session_register('msort');
-            session_register('msgs');      
+            sqsession_register($msort, 'msort');
+            sqsession_register($msgs, 'msgs');     
          }
         break;
        default:
          if (!$use_cache) {
-            session_unregister('msgs');         
-            session_unregister('msort');        
+            sqsession_unregister('msgs');       
+            sqsession_unregister('msort');      
            $msgs= getSelfSortMessages($imapConnection, $start_msg, $show_num, 
                               $num_msgs, $sort, $mbxresponse); 
             $msort = calc_msort($msgs, $sort);
-           session_register('msort');
-            session_register('msgs');
+           sqsession_register($msort, 'msort');
+            sqsession_register($msgs, 'msgs');
          } /* !use cache */
         break;
      } // 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);
@@ -445,13 +455,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.
@@ -565,7 +577,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);
 
@@ -594,7 +608,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',
@@ -620,7 +634,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);
@@ -661,13 +675,18 @@ function mail_message_listing_beginning ($imapConnection,
   global $color, $auto_expunge, $base_uri, $thread_sort_messages, 
     $allow_thread_sort, $allow_server_sort, $server_sort_order,
     $PHP_SELF;
-
+    
+  $php_self = $PHP_SELF;
+  /* fix for incorrect $PHP_SELF */
+  if (strpos($php_self, 'move_messages.php')) {
+      $php_self = str_replace('move_messages.php', 'right_main.php', $php_self);
+  }
   $urlMailbox = urlencode($mailbox);
 
-  if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
+  if (preg_match('/^(.+)\?.+$/',$php_self,$regs)) {
      $source_url = $regs[1];
   } else {
-     $source_url = $PHP_SELF;
+     $source_url = $php_self;
   }
 
   if (!isset($msg)) {
@@ -675,7 +694,6 @@ function mail_message_listing_beginning ($imapConnection,
   }
   $moveURL = "move_messages.php?msg=$msg&amp;mailbox=$urlMailbox"
     . "&amp;startMessage=$start_msg";
-
   /*
    * This is the beginning of the message list table.
    * It wraps around all messages
@@ -697,26 +715,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";
 
@@ -749,12 +773,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
@@ -791,6 +809,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]) {
@@ -944,6 +963,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 {
@@ -954,6 +978,7 @@ function get_paginator_link($box, $start_msg, $use, $text) {
     . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
     . "TARGET=\"right\">$text</A>";
   return ($result);
+*/  
 }
 
 /*
@@ -1158,6 +1183,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)");
@@ -1185,6 +1211,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) . '...';
 }
 
@@ -1211,12 +1242,23 @@ function getMbxList($imapConnection) {
 }
 
 function getButton($type, $name, $value) {
-return '<INPUT TYPE="'.$type.'" NAME="'.$name.'" VALUE="'.$value . '">';
+global $color;
+$style = ' STYLE="background:'.$color[4].';font-size:80%;font-weight:bold;'.
+                  'color:'.$color[8].';margin:0.05em;border:0.2em outset '.
+                 $color[9].';"';
+$javascript = " onmouseover=\"this.style.color='$color[4]'".
+                           ";this.style.borderStyle='inset'" .
+                           ";this.style.background='$color[3]';\";" .
+             " onmouseout=\"this.style.color='$color[8]'".
+                           ";this.style.borderStyle='outset'" . 
+                           ";this.style.background='$color[4]';\";";
+
+return '<INPUT TYPE="'.$type.'" NAME="'.$name.'" VALUE="'.$value . '"'.$style.$javascript.'>';
 }
 
 function getSmallStringCell($string, $align) {
   return html_tag( 'td',            
-            '<small>' . $string . ': &nbsp; </small>',
+            '<small>' . $string . ':&nbsp; </small>',
             $align,
             '',
             'nowrap' );
@@ -1235,7 +1277,7 @@ function getEndMessage($start_msg, $show_num, $num_msgs) {
       $start_msg = 1;
     }
   }
-  return $end_msg;
+  return (array($start_msg,$end_msg));
 }
 
 function handleAsSent($mailbox) {