final try
[squirrelmail.git] / src / search.php
index 74faba4404b96d12bf812f32a8a4418fba5a7683..cd7db4e28aeab6e15e691afd8347a8b0bc75d63b 100644 (file)
@@ -12,6 +12,7 @@
 require_once('../src/validate.php');
 require_once('../functions/imap.php');
 require_once('../functions/imap_search.php');
+require_once('../functions/imap_utf7_decode_local');
 require_once('../functions/array.php');
 require_once('../functions/strings.php');
 
@@ -165,6 +166,7 @@ $attributes = array ();
 $saved_attributes = array ();
 $search_all = 'none';
 $perbox_count = array ();
+$recent_count = getPref($data_dir, $username, 'search_memory', 0);
 
 /*  get mailbox names  */
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
@@ -179,8 +181,11 @@ if ($mailbox == 'All Folders') {
     $search_all = 'all';
 }
 
-displayPageHeader($color, $mailbox);
-
+if (isset($composenew) && $composenew) {
+    displayPageHeader($color, $mailbox, 'comp_in_new();', $session);
+} else {
+    displayPageHeader($color, $mailbox);
+}
 /*  See how the page was called and fire off correct function  */
 if ((!isset($submit) || empty($submit)) && !empty($what)) {
     $submit = _("Search");
@@ -188,7 +193,9 @@ if ((!isset($submit) || empty($submit)) && !empty($what)) {
 if ( !isset( $submit ) ) {
     $submit = '';
 } else if ($submit == _("Search") && !empty($what)) {
-    update_recent($what, $where, $mailbox, $username, $data_dir);
+    if ($recent_count > 0) {
+        update_recent($what, $where, $mailbox, $username, $data_dir);
+    }
 }
 elseif ($submit == 'forget') {
     forget_recent($count, $username, $data_dir);
@@ -211,7 +218,6 @@ echo "<BR>\n".
 
 /*  update the recent and saved searches from the pref files  */
 $attributes = get_recent($username, $data_dir);
-$recent_count = getPref($data_dir, $username, 'search_memory', 0);
 $saved_attributes = get_saved($username, $data_dir);
 $saved_count = count($saved_attributes['saved_what']);
 $count_all = 0;
@@ -305,7 +311,7 @@ echo '<B>' . _("Current Search") . '</B>'
 for ($i = 0; $i < count($boxes); $i++) {
     if (!in_array('noselect', $boxes[$i]['flags'])) {
         $box = $boxes[$i]['unformatted'];
-        $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
+        $box2 = imap_utf7_decode_local(str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']));
         if( $box2 == 'INBOX' ) {
             $box2 = _("INBOX");
         }
@@ -366,9 +372,9 @@ do_hook('search_after_form');
 */
 
 $old_value = 0;
-if ($allow_thread_sort == true) {
+if ($allow_thread_sort == TRUE) {
     $old_value = $allow_thread_sort;
-    $allow_thread_sort = false;
+    $allow_thread_sort = FALSE;
 }
 
 if ($search_all == 'all') {
@@ -389,11 +395,11 @@ if ($search_all == 'all') {
     }
     for ($i=0;$i<count($perbox_count);$i++) {
         if ($perbox_count[$i] != "") {
-           break;
+            $count_all = "found";
+            break;
         }
-        $count_all = "none";
     }
-    if ($count_all == "none") {
+    if ($count_all != "found") {
         echo '<br><b>' .
              _("No Messages found") .
              '</b><br>';