ehh, hmm: include -> require
[squirrelmail.git] / src / search.php
index eddf8ae3943bf7c20ca5846350dae3cc7623b350..65e1695aebea571d689dad5d4fce74576fdfdd3a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * right_main.php
+ * search.php
  *
  * Copyright (c) 1999-2002 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
@@ -13,6 +13,7 @@ require_once('../src/validate.php');
 require_once('../functions/imap.php');
 require_once('../functions/imap_search.php');
 require_once('../functions/array.php');
+require_once('../functions/strings.php');
 
 function s_opt( $val, $sel, $tit ) {
     echo "            <option value=\"$val\"";
@@ -24,8 +25,14 @@ function s_opt( $val, $sel, $tit ) {
 
 /* ------------------------ main ------------------------ */
 
-displayPageHeader($color, $mailbox);
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+$boxes = sqimap_mailbox_list($imapConnection);
+
+if( $mailbox == 'None' ) {
+    $mailbox = $boxes[0]['unformatted'];
+}
+
+displayPageHeader($color, $mailbox);
 
 if( !isset( $search_memory ) ) {
     $search_memory = 0;
@@ -33,12 +40,22 @@ if( !isset( $search_memory ) ) {
 
 do_hook('search_before_form');
 echo "<br>\n".
-     "      <table width=\"95%\" align=center cellpadding=2 cellspacing=0 border=0>\n".
+     "      <table width=\"100%\" align=center cellpadding=2 cellspacing=0 border=0>\n".
      "      <tr><td bgcolor=\"$color[0]\">\n".
      "          <center><b>"._("Search")."</b></center>\n".
      "      </td></tr>\n".
      '      <tr><td align=center>';
 
+if( $search_memory > 0 ) {
+
+    if( isset( $pos) ) {
+        setpref( $data_dir, $username, 'search_pos', $pos );
+    } else {
+        $pos = getPref($data_dir, $username, 'search_pos', 0 );
+    }
+
+}
+
 for ( $form = 0; $form <= $search_memory; $form++ ) {
 
     $frm = "$form";
@@ -57,13 +74,16 @@ for ( $form = 0; $form <= $search_memory; $form++ ) {
     echo "   <TABLE WIDTH=\"75%\" cellpadding=0 cellspacing=0>\n";
     if( !($form == 0 && $search_memory > 0) ) {
 
+        if( $form == $pos ) {
+            $act = $color[5];
+        } else {
+            $act = $color[4];
+        }
+
         echo "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n".
              "<input type=hidden name=pos value=\"$frm\">".
-             "     <TR>\n".
-             "       <TD WIDTH=\"33%\">\n".
-             '         <TT><SMALL><SELECT NAME="mailbox">';
-        
-        $boxes = sqimap_mailbox_list($imapConnection);
+             "     <TR bgcolor=$act><td width=10></td>\n".
+             '       <TD><SELECT NAME="mailbox">';
         
         for ($i = 0; $i < count($boxes); $i++) {
             if (!in_array('noselect', $boxes[$i]['flags'])) {
@@ -76,9 +96,9 @@ for ( $form = 0; $form <= $search_memory; $form++ ) {
                 }   
             }
         }
-        echo '         </SELECT></SMALL></TT>'.
+        echo '         </SELECT>'.
              "       </TD>\n".
-             "        <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
+             "        <TD ALIGN=\"CENTER\">\n";
         if (!isset($$what)) {
            $$what = '';
         }
@@ -88,7 +108,7 @@ for ( $form = 0; $form <= $search_memory; $form++ ) {
         $what_disp = str_replace('"', '&quot;', $what_disp);
         echo "          <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what$frm\" VALUE=\"$what_disp\">\n".
                     '</TD>'.
-                   "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n".
+                   "<TD ALIGN=\"RIGHT\">\n".
                      "<SELECT NAME=\"where$frm\">";
         
         s_opt( 'BODY', $$where, _("Body") );
@@ -119,11 +139,11 @@ $where = "where$pos";
 
 if (isset($$where) && $$where && isset($$what) && $$what) {
     sqimap_mailbox_select($imapConnection, $mailbox);
-    sqimap_search($imapConnection, $$where, $$what, $mailbox, $color);
+    sqimap_search($imapConnection, $$where, $$what, $mailbox, $color, $pos);
 }
 do_hook("search_bottom");
 sqimap_logout ($imapConnection);
 
 echo '</body></html>';
 
-?>
\ No newline at end of file
+?>