fix for incorrect PHP_SELF
[squirrelmail.git] / functions / mailbox_display.php
index 38d459c2928e2531a6acb9cd908e83e9287d2329..32f51bffcbdeca24fab570691bdf839028429b13 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);
@@ -349,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) {
@@ -379,8 +380,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 +390,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,25 +410,25 @@ 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
@@ -667,13 +668,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)) {
@@ -681,7 +687,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
@@ -703,7 +708,7 @@ 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 $mailbox"), 'left') .
                getSmallStringCell(_("Transform Selected Messages"), 'right')
             )
             . html_tag( 'tr' ) ."\n"
@@ -723,10 +728,10 @@ function mail_message_listing_beginning ($imapConnection,
   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';
+  if (!strpos($php_self,'mailbox')) {
+     $location = $php_self.'?mailbox=INBOX&amp;startMessage=1';
   } else {
-     $location = $PHP_SELF;
+     $location = $php_self;
   }
   echo '<INPUT TYPE="HIDDEN" NAME="location" VALUE="'.$location.'">';
   echo "</TD>\n"
@@ -761,12 +766,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
@@ -957,6 +956,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 {
@@ -967,6 +971,7 @@ function get_paginator_link($box, $start_msg, $use, $text) {
     . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
     . "TARGET=\"right\">$text</A>";
   return ($result);
+*/  
 }
 
 /*
@@ -1171,7 +1176,7 @@ function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
 }
 
 function processSubject($subject) {
-    global $squirrelmail_language;
+    global $languages, $squirrelmail_language;
   /* Shouldn't ever happen -- caught too many times in the IMAP functions */
   if ($subject == '')
     return _("(no subject)");
@@ -1199,8 +1204,9 @@ function processSubject($subject) {
     return $subject;
   }
   
-  if ($squirrelmail_language == 'ja_JP' && function_exists('mb_strimwidth')) {
-         return mb_strimwidth($subject, 0, $trim_val, '...');
+  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) . '...';