unsetting an array element didn't re-index the array which caused a failure
[squirrelmail.git] / functions / mailbox_display.php
index e0486680a7c5c7af0e95f426d0a03ef70159ad46..b2d1fd985ceda1d750de08d30b3f6112d13a69c2 100644 (file)
@@ -585,7 +585,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
 <table border="0" width="100%" cellpadding="0" cellspacing="0">
   <tr>
     <td>
-      <?php mail_message_listing_beginning($imapConnection, $mailbox, $sort, 
+      <?php mail_message_listing_beginning($imapConnection, $mbxresponse, $mailbox, $sort, 
                                            $msg_cnt_str, $paginator_str, $start_msg); ?>
     </td>
   </tr>
@@ -753,6 +753,7 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
  * you need to do a "</table></table>";
  *
  * $moveURL is the URL to submit the delete/move form to
+ * $mbxresponse is the array with the results of SELECT against the current mailbox 
  * $mailbox is the current mailbox
  * $sort is the current sorting method (-1 for no sorting available [searches])
  * $Message is a message that is centered on top of the list
@@ -760,11 +761,12 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
  */
 
 function mail_message_listing_beginning ($imapConnection,
+                                         $mbxresponse,
                                          $mailbox = '', $sort = -1,
                                          $msg_cnt_str = '',
                                          $paginator = '&nbsp;',
                                          $start_msg = 1) {
-    global $color, $auto_expunge, $base_uri,
+    global $color, $auto_expunge, $base_uri, $show_flag_buttons,
            $allow_server_sort, $server_sort_order,
            $PHP_SELF, $allow_thread_sort, $thread_sort_messages;
 
@@ -802,6 +804,7 @@ function mail_message_listing_beginning ($imapConnection,
      */
     $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $mailbox);
     $form_name = "FormMsgs" . $safe_name;
+
     echo '<form name="' . $form_name . '" method="post" action="move_messages.php">' ."\n"
             . $moveFields;
 ?>
@@ -822,6 +825,15 @@ function mail_message_listing_beginning ($imapConnection,
               <tr>
                 <td align="left">
                   <small><?php
+                    
+                    // display flag buttons only if supported
+                    if ($show_flag_buttons && $mbxresponse != NULL && 
+                        strpos($mbxresponse['PERMANENTFLAGS'], '\Flagged') !== FALSE) {
+                        echo getButton('SUBMIT', 'markFlagged',_("Flag"));
+                        echo '&nbsp;';
+                        echo getButton('SUBMIT', 'markUnflagged',_("Unflag"));
+                        echo '&nbsp;';
+                    }
                     echo getButton('SUBMIT', 'markRead',_("Read"));
                     echo '&nbsp;';
                     echo getButton('SUBMIT', 'markUnread',_("Unread"));
@@ -921,7 +933,7 @@ function printHeader($mailbox, $sort, $color, $showsort=true, $start_msg=1) {
     foreach ($index_order as $item) {
         switch ($item) {
         case 1: /* checkbox */
-            echo html_tag( 'td',get_selectall_link($start_msg, $sort) , '', '', 'width="1%"' );
+            echo html_tag( 'td',get_selectall_link($start_msg, $sort, $mailbox) , '', '', 'width="1%"' );
             break;
         case 5: /* flags */
             echo html_tag( 'td','' , '', '', 'width="1%"' );
@@ -996,8 +1008,8 @@ function ShowSortButton($sort, $mailbox, $Down, $Up ) {
          . _("Click here to change the sorting of the message list") .'"></a>';
 }
 
-function get_selectall_link($start_msg, $sort) {
-    global $checkall, $what, $where, $mailbox, $javascript_on;
+function get_selectall_link($start_msg, $sort, $mailbox) {
+    global $checkall, $what, $where, $javascript_on;
     global $PHP_SELF, $PG_SHOWNUM;
 
     $result = '';