Cleaning
[squirrelmail.git] / functions / mailbox_display.php
index e8523344f152819de184121693000864e83d07c2..e6e5f114431364407b4eeb1543070e7535ada174 100644 (file)
@@ -27,7 +27,7 @@
           }
           $GLOBALS["row_count"]++;
           if ($GLOBALS["row_count"] % 2) {
-          if (!isset($color[12])) $color[12] = "#EAEAEA";
+          if (!isset($color[12])) $color[12] = '#EAEAEA';
             $color_string = $color[12];
           }
       }
       $msg = $msgs[$key];
 
       $senderName = sqimap_find_displayable_name($msg['FROM']);
+      if( $mailbox == _("None") ) {
+         // $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+         $boxes = sqimap_mailbox_list($imapConnection);
+         // sqimap_logout($imapConnection);
+         $mailbox = $boxes[0]['unformatted'];
+         unset( $boxes );
+      }
       $urlMailbox = urlencode($mailbox);
       $subject = processSubject($msg['SUBJECT']);
 
       echo "<TR>\n";
 
-      if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) 
-      { 
-         $flag = "<font color=$color[2]>"; 
-         $flag_end = '</font>'; 
+      if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true)
+      {
+         $flag = "<font color=$color[2]>";
+         $flag_end = '</font>';
       }
       else
       {
          $flag = '';
          $flag_end = '';
       }
-      if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false) 
-      { 
-         $bold = '<b>'; 
-         $bold_end = '</b>'; 
+      if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false)
+      {
+         $bold = '<b>';
+         $bold_end = '</b>';
       }
       else
       {
          $bold = '';
          $bold_end = '';
       }
-      if ($mailbox == $sent_folder) 
-      { 
-         $italic = '<i>'; 
-         $italic_end = '</i>'; 
+      if ($mailbox == $sent_folder)
+      {
+         $italic = '<i>';
+         $italic_end = '</i>';
       }
       else
       {
@@ -72,8 +79,8 @@
       }
       if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'])
       {
-         $fontstr = "<font color=\"$color[9]\">"; 
-         $fontstr_end = '</font>'; 
+         $fontstr = "<font color=\"$color[9]\">";
+         $fontstr_end = '</font>';
       }
       else
       {
          $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what);
       }
 
-      if ($checkall == 1) 
+      if ($checkall == 1)
          $checked = ' checked';
       else
          $checked = '';
-      
+
       for ($i=1; $i <= count($index_order); $i++) {
          switch ($index_order[$i]) {
             case 1: # checkbox
             case 5: # flags
                $stuff = false;
                echo "   <td bgcolor=$hlt_color align=center nowrap><b><small>\n";
-               if (isset($msg['FLAG_ANSWERED']) && 
+               if (isset($msg['FLAG_ANSWERED']) &&
                    $msg['FLAG_ANSWERED'] == true) {
                   echo "A\n";
                   $stuff = true;
             if ($numMessages < $show_num)
                 $end_loop = $numMessages;
             elseif ($end > $numMessages)
-               $end_loop = $numMessages - $startMessage + 1;
-           else
+            $end_loop = $numMessages - $startMessage + 1;
+        else
                 $end_loop = $show_num;
          } else {
             $end = $numMessages;
 
          /* Only ignore messages flagged as deleted if we are using a
           * trash folder or auto_expunge */
-         if (((isset($move_to_trash) && $move_to_trash) 
+         if (((isset($move_to_trash) && $move_to_trash)
               || (isset($auto_expunge) && $auto_expunge)) && $sort != 6)
          {
             /** Find and remove the ones that are deleted */
                 $messages = array();
             $msgs = $messages;
          }
-      }         
+      }
 
       // There's gotta be messages in the array for it to sort them.
       if ($numMessages > 0 && ! $use_cache) {
          $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
       }
       if( $lMore <> '' )
-       $lMore .= ' | ';
+        $lMore .= ' | ';
 
       // Page selector block. Following code computes page links.
       $mMore = '';
                 $mMore .= '<b>' . ($i+1) . '</b> ';
                 } else {
                 $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start" .
-                        "&mailbox=$mailbox\" TARGET=\"right\">" .
+                        "&mailbox=$urlMailbox\" TARGET=\"right\">" .
                         ($i+1) .
                         '</a> ';
                 }
       global $color, $index_order, $auto_expunge, $move_to_trash;
       global $checkall, $sent_folder;
       $urlMailbox = urlencode($mailbox);
-         /** This is the beginning of the message list table.  It wraps around all messages */
-      echo '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="0">';
 
-      if ($Message)
-      {
+      /** This is the beginning of the message list table.  It wraps around all messages */
+      echo '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="0">';
+      if ($Message) {
          echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n";
       }
 
       echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
       echo "$More</td><td align=right>\n";
       ShowSelectAllLink($startMessage, $sort);
-
       echo '</td></tr></table></td></tr>';
 
       /** The delete and move options */
 
       echo "\n<FORM name=messageList method=post action=\"$moveURL\">\n";
       echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
-      echo "   <TR>\n";
-      echo "      <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER>\n";
-
 
-      echo '         <NOBR><SMALL>'. _("Move selected to:") .'</SMALL>';
-      echo '         <TT><SMALL><SELECT NAME="targetMailbox">';
+      echo "   <TR>\n";
+      echo "      <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER NOWRAP>\n";
+      echo '         <SMALL>&nbsp;' . _("Move selected to:") . "</SMALL>\n";
+      echo "      </TD>\n";
+      echo "      <TD>&nbsp;</TD>\n";
+      echo "      <TD WIDTH=\"1%\" ALIGN=RIGHT NOWRAP>\n";
+      echo '         <SMALL>&nbsp;' . _("Transform Selected Messages") . ": </SMALL><BR>\n";
+      echo "      </TD>\n";
+      echo "   </TR>\n";
+      echo "   <TR>\n";
+      echo "      <TD ALIGN=LEFT VALIGN=CENTER NOWRAP>\n";
+      echo '         <TT><SMALL>&nbsp;&nbsp;&nbsp;<SELECT NAME="targetMailbox">';
 
       $boxes = sqimap_mailbox_list($imapConnection);
       for ($i = 0; $i < count($boxes); $i++) {
          }
       }
       echo '         </SELECT></SMALL></TT>';
-      echo '         <SMALL><INPUT TYPE=SUBMIT NAME="moveButton" VALUE="'. _("Move") ."\"></SMALL></NOBR>\n";
+      echo "         <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"" . _("Move") . "\"></SMALL>\n";
       echo "      </TD>\n";
-      echo "      <TD WIDTH=40% ALIGN=RIGHT>\n";
+      echo "      <TD>&nbsp;</TD>\n";
+      echo "      <TD ALIGN=RIGHT NOWRAP>&nbsp;&nbsp;&nbsp;\n";
       if (! $auto_expunge) {
-         echo '         <NOBR><SMALL><INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'">&nbsp;'. _("mailbox") ."</SMALL></NOBR>&nbsp;&nbsp;\n";
+         echo '         <INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'">&nbsp;'. _("mailbox") ."&nbsp;\n";
       }
-      echo "         <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\">&nbsp;". _("checked messages") ."</SMALL></NOBR>\n";
+      echo "         <INPUT TYPE=SUBMIT NAME=\"markRead\" VALUE=\"". _("Read")."\">\n";
+      echo "         <INPUT TYPE=SUBMIT NAME=\"markUnread\" VALUE=\"". _("Unread")."\">\n";
+      echo "         <INPUT TYPE=SUBMIT VALUE=\"". _("Delete") . "\">&nbsp;\n";
       echo "      </TD>\n";
       echo "   </TR>\n";
-
       echo "</TABLE>\n";
       do_hook('mailbox_form_before');
       echo '</TD></TR>';
             case 5: # flags
                echo '   <TD WIDTH="1%"><B>&nbsp;</B></TD>';
                break;
-               
+
             case 2: # from
                if ($mailbox == $sent_folder)
                   echo '   <TD WIDTH="25%"><B>'. _("To") .'</B>';
                else
                     echo '   <TD WIDTH="25%"><B>'. _("From") .'</B>';
-              ShowSortButton($sort, $mailbox, 2, 3);
+           ShowSortButton($sort, $mailbox, 2, 3);
                echo "</TD>\n";
                break;
-               
+
             case 3: # date
                echo '   <TD NOWRAP WIDTH="5%"><B>'. _("Date") .'</B>';
-              ShowSortButton($sort, $mailbox, 0, 1);
+               ShowSortButton($sort, $mailbox, 0, 1);
                echo "</TD>\n";
                break;
-               
+
             case 4: # subject
                echo '   <TD><B>'. _("Subject") .'</B> ';
-              ShowSortButton($sort, $mailbox, 4, 5);
+               ShowSortButton($sort, $mailbox, 4, 5);
                echo "</TD>\n";
                break;
-               
-            case 6: # size 
+
+            case 6: # size
                echo '   <TD WIDTH="5%"><b>' . _("Size")."</b></TD>\n";
                break;
          }
       }
       echo "</TR>\n";
    }
-   
+
    function ShowSortButton($sort, $mailbox, $Up, $Down) {
       if ($sort != $Up && $sort != $Down) {
          $img = 'sort_none.gif';
          $which = $Up;
       } elseif ($sort == $Up) {
          $img = 'up_pointer.gif';
-        $which = $Down;
+         $which = $Down;
       } else {
          $img = 'down_pointer.gif';
-        $which = 6;
+         $which = 6;
       }
-      echo ' <a href="right_main.php?newsort=' . $which . 
-        '&startMessage=1&mailbox=' . urlencode($mailbox) . 
-        '"><IMG SRC="../images/' . $img . 
-        '" BORDER=0 WIDTH=12 HEIGHT=10></a>';
+      echo ' <a href="right_main.php?newsort=' . $which .
+           '&startMessage=1&mailbox=' . urlencode($mailbox) .
+           '"><IMG SRC="../images/' . $img .
+           '" BORDER=0 WIDTH=12 HEIGHT=10></a>';
    }
-   
+
    function ShowSelectAllLink($startMessage, $sort)
    {
        global $checkall, $PHP_SELF, $what, $where, $mailbox;
 
        // This code is from Philippe Mingo <mingo@rotedic.com>
-    
+
        ?>
 <script language="JavaScript">
 <!--
@@ -660,7 +674,7 @@ window.document.write('<a href="#" onClick="CheckAll();"><?php echo
            echo _("Unselect All");
        else
            echo _("Select All");
-          
+
        echo "</A>\n</noscript>\n";
    }
 
@@ -669,10 +683,10 @@ window.document.write('<a href="#" onClick="CheckAll();"><?php echo
       // Shouldn't ever happen -- caught too many times in the IMAP functions
       if ($subject == '')
           return _("(no subject)");
-         
+
       if (strlen($subject) <= 55)
           return $subject;
-         
+
       $ent_strlen=strlen($subject);
       $trim_val=50;
       $ent_offset=0;
@@ -683,15 +697,15 @@ window.document.write('<a href="#" onClick="CheckAll();"><?php echo
       while (($ent_loc = strpos($subject, '&', $ent_offset)) !== false &&
              ($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false)
       {
-        $trim_val += ($ent_loc_end-$ent_loc)+1;
-        $ent_strlen -= $ent_loc_end-$ent_loc;
-        $ent_offset = $ent_loc_end+1;
+     $trim_val += ($ent_loc_end-$ent_loc)+1;
+     $ent_strlen -= $ent_loc_end-$ent_loc;
+     $ent_offset = $ent_loc_end+1;
       }
-      
+
       if ($ent_strlen <= 55)
           return $subject;
 
       return substr($subject, 0, $trim_val) . '...';
    }
 
-?>
+?>
\ No newline at end of file