Making delete button, when viewing a message, consider which page was viewed before
[squirrelmail.git] / functions / mailbox_display.php
index eadabbc73bb5919d3f5eb7c2a4a6952933c59e92..53b67c41e73466ee7c7699abcf2f73fa7da490c9 100644 (file)
@@ -94,11 +94,11 @@ function printMessageInfo($aMsg) {
         $default_use_priority,
         $message_highlight_list,
         $index_order,
-        $truncate_sender,      /* number of characters for From/To field (<= 0 for unchanged) */
+        $truncate_sender,           /* number of characters for From/To field (<= 0 for unchanged) */
         $email_address,
-        $show_recipient_instead,       /* show recipient name instead of default identity */
-        $use_icons,            /* indicates to use icons or text markers */
-        $icon_theme;           /* icons theming */
+        $show_recipient_instead,    /* show recipient name instead of default identity */
+        $use_icons,                 /* indicates to use icons or text markers */
+        $icon_theme;                /* icons theming */
 
     $color_string = $color[4];
 
@@ -197,8 +197,8 @@ function printMessageInfo($aMsg) {
     }
     // If Sent, prefix with To: but only if not Sent folder
     if ($bHandleAsSent ^ $bSentFolder) {
-        $senderName = _("To:") . ' ' . $senderName;
-        $senderAddress = _("To:") . ' ' . $senderAddress;
+        $senderName = _("To") . ': ' . $senderName;
+        $senderAddress = _("To") . ': ' . $senderAddress;
     }
 
     // this is a column property which can apply to multiple columns. Do not use vars for one column
@@ -300,7 +300,7 @@ function printMessageInfo($aMsg) {
     $sSubject = str_replace('&nbsp;', ' ', decodeHeader($sSubject));
     $subject = processSubject($sSubject, $iIndent);
 
-    echo html_tag( 'tr','','','','VALIGN="top"') . "\n";
+    echo html_tag( 'tr','','','','valign="top"') . "\n";
 
     if (sizeof($index_order)) {
         foreach ($index_order as $index_order_part) {
@@ -770,9 +770,9 @@ function get_sorted_msgs_list($imapConnection,&$aMailbox,&$error) {
         $aRes = get_thread_sort($imapConnection,$aMailbox['SEARCH'][$iSetIndx]);
         if ($aRes === false) {
             $error = '<b><small><center><font color=red>' .
-                    _("Thread sorting is not supported by your IMAP server.") . '<br />' .
-                    _("Please report this to the system administrator.").
-                    '</center></small></b>';
+                _("Thread sorting is not supported by your IMAP server.") . '<br />' .
+                _("Please contact your system administrator and report this error.") .
+                '</center></small></b>';
             $aMailbox['SORT'] -= SQSORT_THREAD;
         } else {
             $aMailbox['UIDSET'][$iSetIndx] = $aRes[0];
@@ -784,8 +784,8 @@ function get_sorted_msgs_list($imapConnection,&$aMailbox,&$error) {
         $id = sqimap_get_sort_order($imapConnection, $sSortField, $bDirection, $aMailbox['SEARCH'][$iSetIndx]);
         if ($id === false) {
             $error =  '<b><small><center><font color=red>' .
-                _( "Server-side sorting is not supported by your IMAP server.") . '<br />' .
-                _("Please report this to the system administrator.").
+                _("Server-side sorting is not supported by your IMAP server.") . '<br />' .
+                _("Please contact your system administrator and report this error.") .
                 '</center></small></b>';
         } else {
             $aMailbox['UIDSET'][$iSetIndx] = $id;
@@ -1185,16 +1185,39 @@ function mail_message_listing_beginning ($imapConnection,
     echo '<form name="' . $form_name . '" method="post" action="'.$php_self.'">' ."\n"
         . $moveFields;
 
-
+    $button_str = '';
+    // display flag buttons only if supported
+    if ($show_flag_buttons  &&
+        in_array('\\flagged',$aMailbox['PERMANENTFLAGS'], true) ) {
+        $button_str .= getButton('submit', 'markUnflagged', _("Unflag"));
+        $button_str .= getButton('submit', 'markFlagged',   _("Flag"));
+        $button_str .= "&nbsp;\n";
+    }
+    if (in_array('\\seen',$aMailbox['PERMANENTFLAGS'], true)) {
+        $button_str .= getButton('submit', 'markUnread', _("Unread"));
+        $button_str .= getButton('submit', 'markRead',   _("Read"));
+        $button_str .= "&nbsp;\n";
+    }
+    $button_str .= getButton('submit', 'attache',_("Forward")) .
+                   "&nbsp;\n";
+    if (in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) {
+        $button_str .= getButton('submit', 'delete',_("Delete"));
+        $button_str .= '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash");
+        $button_str .= "&nbsp;\n";
+    }
+    if (!$aMailbox['AUTO_EXPUNGE'] && $aMailbox['RIGHTS'] != 'READ-ONLY') {
+        $button_str .= getButton('submit', 'expungeButton',_("Expunge"))  .'&nbsp;' . _("mailbox") . "\n";
+        $button_str .= '&nbsp;';
+    }
 ?>
     <table width="100%" cellpadding="1"  cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
         <tr>
         <td>
             <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1"  cellspacing="0">
             <tr>
-                <td align="left"><small><?php echo $paginator . $thread_link_str; ?></small></td>
-                <td align="center"></td>
-                <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
+                <?php echo html_tag('td', '<small>' . $paginator . $thread_link_str . '</small>', 'left') . "\n"; ?>
+                <?php echo html_tag('td', '', 'center') . "\n"; ?>
+                <?php echo html_tag('td', '<small>' . $msg_cnt_str . '</small>', 'right') . "\n"; ?>
             </tr>
             </table>
         </td>
@@ -1203,45 +1226,23 @@ function mail_message_listing_beginning ($imapConnection,
         <td>
             <table border="0" width="100%" cellpadding="1"  cellspacing="0">
             <tr>
-                <td align="left">
-                <small><?php
-
-                    // display flag buttons only if supported
-                    if ($show_flag_buttons  &&
-                    in_array('\\flagged',$aMailbox['PERMANENTFLAGS'], true) ) {
-                        echo getButton('SUBMIT', 'markUnflagged',_("Unflag"));
-                        echo getButton('SUBMIT', 'markFlagged',_("Flag"));
-                        echo '&nbsp;';
-                    }
-                    if (in_array('\\seen',$aMailbox['PERMANENTFLAGS'], true)) {
-                        echo getButton('SUBMIT', 'markUnread',_("Unread"));
-                        echo getButton('SUBMIT', 'markRead',_("Read"));
-                        echo '&nbsp;';
-                    }
-
-                    echo getButton('SUBMIT', 'attache',_("Forward"));
-                    echo '&nbsp;';
-                    if (in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) {
-                        echo getButton('SUBMIT', 'delete',_("Delete"));
-                        echo '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash");
-                        echo '&nbsp;';
-                    }
-                    if (!$aMailbox['AUTO_EXPUNGE'] && $aMailbox['RIGHTS'] != 'READ-ONLY') {
-                    echo getButton('SUBMIT', 'expungeButton',_("Expunge"))  .'&nbsp;' . _("mailbox") . "\n";
-                    echo '&nbsp;';
-                    }
-                    do_hook('mailbox_display_buttons');
-                ?></small>
+                <?php echo html_tag('td', '', 'left') . "\n"; ?>
+                <small>
+                    <?php echo $button_str; ?>
+                    <?php do_hook('mailbox_display_buttons'); ?>
+                </small>
                 </td>
                 <?php
                 if (in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) {
-                    echo '<td align="right">
-                <small>';
-                    echo  '         <small>&nbsp;<tt><select name="targetMailbox">';
-                    echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)), 0, $boxes);
-                    echo '         </select></tt>&nbsp;';
-                    echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n
-                </small>";
+                ?>
+                <?php echo html_tag('td', '', 'right'); ?>
+                    <small>&nbsp;<tt>
+                        <select name="targetMailbox">
+                            <?php echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)), 0, $boxes); ?>
+                        </select></tt>&nbsp;
+                        <?php echo getButton('submit', 'moveButton',_("Move")); ?>
+                    </small>
+                <?php
                 }
                 ?>
                 </td>
@@ -1250,7 +1251,6 @@ function mail_message_listing_beginning ($imapConnection,
         </td>
         </tr>
     </table>
-
 <?php
     do_hook('mailbox_form_before');
 }
@@ -1276,8 +1276,8 @@ if ($num_msgs) {
         <td>
             <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1"  cellspacing="0">
             <tr>
-                <td align="left"><small><?php echo $paginator_str; ?></small></td>
-                <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
+                    <?php echo html_tag('td', '<small>' . $paginator_str . '</small>', 'left');  ?>
+                    <?php echo html_tag('td', '<small>' . $msg_cnt_str   . '</small>', 'right'); ?>
             </tr>
             </table>
         </td>
@@ -1483,7 +1483,7 @@ function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
         $result = sprintf(_("Viewing Messages: %s to %s (%s total)"),
                         '<b>'.$start_msg.'</b>', '<b>'.$end_msg.'</b>', $num_msgs);
     } else if ($start_msg == $end_msg) {
-        $result = sprintf(_("Viewing Message: %s (1 total)"), '<b>'.$start_msg.'</b>');
+        $result = sprintf(_("Viewing Message: %s (%s total)"), '<b>'.$start_msg.'</b>', $num_msgs);
     } else {
         $result = '<br />';
     }
@@ -1745,8 +1745,8 @@ function truncateWithEntities($subject, $trim_at)
         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);
+        function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_strimwidth')) {
+        return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_strimwidth', $subject, $trim_val);
     }
 
     return substr_replace($subject, '...', $trim_val);
@@ -1867,11 +1867,8 @@ function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = ar
                 !in_array($aUid[0],$aMailbox['UIDSET'][$aMailbox['SETINDEX']])) {
                 break;
             }
-            // What kind of hook is this, can it be removed? Disabled for now because it can invalidate the cache
-            //if (!boolean_hook_function('move_messages_button_action', NULL, 1)) {
-                $aUpdatedMsgs = sqimap_msgs_list_delete($imapConnection, $mailbox, $aUid,$bypass_trash);
-                $bExpunge = true;
-            //}
+            $aUpdatedMsgs = sqimap_msgs_list_delete($imapConnection, $mailbox, $aUid,$bypass_trash);
+            $bExpunge = true;
             break;
           case 'unsetDeleted':
           case 'setSeen':
@@ -1899,6 +1896,10 @@ function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = ar
                 $aMailbox['FORWARD_SESSION'] = $composesession;
             }
             break;
+          default:
+            // Hook for plugin buttons
+            do_hook_function('mailbox_display_button_action', $aUid);
+            break;
         }
         /**
          * Updates messages is an array containing the result of the untagged
@@ -2046,4 +2047,5 @@ function attachSelectedMessages($imapConnection,$aMsgHeaders) {
     return $composesession;
 }
 
-?>
+// vim: et ts=4
+?>
\ No newline at end of file