get the filename from the properties if the is no disposition info available
[squirrelmail.git] / src / search.php
index 1d32e7009d359541f8e1d173c23763f48de30252..8c5532240f0300f19c5720d5d0dd4a2ad4bf21ab 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * search.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * $Id$
@@ -17,7 +17,6 @@ require_once(SM_PATH . 'include/validate.php');
 require_once(SM_PATH . 'functions/imap.php');
 require_once(SM_PATH . 'functions/imap_search.php');
 require_once(SM_PATH . 'functions/imap_mailbox.php');
-require_once(SM_PATH . 'functions/array.php');
 require_once(SM_PATH . 'functions/strings.php');
 
 global $allow_thread_sort;
@@ -192,8 +191,8 @@ function save_recent($save_index, $username, $data_dir) {
 function printSearchMessages($msgs,$mailbox, $cnt, $imapConnection, $where, $what, $usecache = false, $newsort = false) {
     global $sort, $color;
     
-    $msort = calc_msort($msgs, $sort);
-    if ($cnt > 0) {
+       if ($cnt > 0) {
+          $msort = calc_msort($msgs, $sort);
        if ( $mailbox == 'INBOX' ) {
            $showbox = _("INBOX");
        } else {
@@ -384,7 +383,7 @@ if ($recent_count > 0) {
             if (isset($attributes['search_what'][$i]) &&
                 !empty($attributes['search_what'][$i])) {
             echo html_tag( 'td', $attributes['search_folder'][$i], 'left', '', 'width="35%"' )
-               . html_tag( 'td', $attributes['search_what'][$i], 'left' )
+               . html_tag( 'td', htmlentities($attributes['search_what'][$i]), 'left' )
                . html_tag( 'td', $attributes['search_where'][$i], 'center' )
                . html_tag( 'td', '', 'right' )
                .   "<a href=search.php?count=$i&amp;submit=save>"
@@ -436,27 +435,18 @@ echo html_tag( 'div', '<b>' . _("Current Search") . '</b>', 'left' ) . "\n"
    . html_tag( 'table', '', '', '', 'width="95%" cellpadding="0" cellspacing="0" border="0"' )
    . html_tag( 'tr' )
    . html_tag( 'td', '', 'left' )
-   . '<select name="mailbox">';
-for ($i = 0; $i < count($boxes); $i++) {
-    if (!in_array('noselect', $boxes[$i]['flags'])) {
-        $box = $boxes[$i]['unformatted'];
-        $box2 = str_replace(' ', '&nbsp;', 
-                         imap_utf7_decode_local($boxes[$i]['unformatted-disp']));
-        if( $box2 == 'INBOX' ) {
-            $box2 = _("INBOX");
-        }
-        echo '         <option value="' . $box . '"';
-        if ($mailbox == $box) { echo ' selected'; }
-        echo '>' . $box2 . '</option>' . "\n";
-    }
-}
-        echo '<option value="All Folders"';
-        if ($mailbox == 'All Folders') {
-            echo ' selected';
-        }
-        echo ">All folders</option>\n";
-echo '         </select>'.
-     "       </td>\n";
+   . '<select name="mailbox">'
+   . '<option value="All Folders"';
+   if ($mailbox == 'All Folders') {
+       echo ' selected';
+   }
+   echo '>[ ' . _("All Folders") . " ]</option>\n";
+
+   $show_selected = array(strtolower($mailbox));
+   echo sqimap_mailbox_option_list($imapConnection, $show_selected, 0, $boxes);
+
+   echo '         </select>'.
+        "       </td>\n";
 if ( !isset( $what ) ) {
     $what = '';
 }
@@ -505,7 +495,7 @@ if ($search_all == 'all') {
     $boxcount = count($boxes);
     echo '<BR><CENTER><B>' .
          _("Search Results") .
-         "</B><CENTER><BR>\n";
+         "</B></CENTER><BR>\n";
     for ($x=0;$x<$boxcount;$x++) {
         if (!in_array('noselect', $boxes[$x]['flags'])) {
             $mailbox = $boxes[$x]['unformatted'];