Added the possibility to remember up to 9 searchs. 0 disables
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 4 Jan 2002 11:39:06 +0000 (11:39 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 4 Jan 2002 11:39:06 +0000 (11:39 +0000)
searching memory.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2086 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/load_prefs.php
src/options_folder.php
src/search.php

index 30bce80e027ea5190179eba57a20d1fa0a897dcf..07856cf102b07a27b298db4ac42ed2084f67e9ba 100644 (file)
@@ -225,6 +225,9 @@ $javascript_setting =
     getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
 $javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON);
 
+global $search_memory;
+$search_memory = getPref($data_dir, $username, 'search_memory', 2);
+
 do_hook('loading_prefs');
 
 ?>
\ No newline at end of file
index 383d6ff021ddaa47dccba3988617d75a551b0c55..0cd7333e25b8c887c6861a045f1f0baacdb953f9 100644 (file)
@@ -185,6 +185,22 @@ function load_optpage_data_folder() {
                            SMPREF_TIME_24HR => _("24-hour clock")) 
     );
 
+    $optvals[SMOPT_GRP_FOLDERLIST][] = array(
+        'name'    => 'search_memory',
+        'caption' => _("Memory Search"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST,
+        'posvals' => array( 0 => _("Disabled"),
+                            1 => '1',
+                            2 => '2',
+                            3 => '3',
+                            4 => '4',
+                            5 => '5',
+                            6 => '6',
+                            7 => '7',
+                            8 => '8',
+                            9 => '9') 
+
     /* Assemble all this together and return it as our result. */
     $result = array(
         'grps' => $optgrps,
index 8081f0c2178372c076d7923eee42bfdd3d3828da..eddf8ae3943bf7c20ca5846350dae3cc7623b350 100644 (file)
@@ -16,80 +16,114 @@ require_once('../functions/array.php');
 
 function s_opt( $val, $sel, $tit ) {
     echo "            <option value=\"$val\"";
-    if ( $sel ) {
+    if ( $sel == $val ) {
         echo ' selected';
     }
     echo  ">$tit</option>\n";
 }
 
+/* ------------------------ main ------------------------ */
+
 displayPageHeader($color, $mailbox);
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 
+if( !isset( $search_memory ) ) {
+    $search_memory = 0;
+}
+
 do_hook('search_before_form');
 echo "<br>\n".
-    "      <table width=\"95%\" 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>'.
+     "      <table width=\"95%\" 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>';
 
-    "<FORM ACTION=\"$PHP_SELF\" NAME=s>\n".
-    "   <TABLE WIDTH=\"75%\">\n".
-    "     <TR>\n".
-    "       <TD WIDTH=\"33%\">\n".
-    '         <TT><SMALL><SELECT NAME="mailbox">';
+for ( $form = 0; $form <= $search_memory; $form++ ) {
 
-$boxes = sqimap_mailbox_list($imapConnection);
-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']);
-        if ($mailbox == $box) {
-            echo "         <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
+    $frm = "$form";
+    $what = "what$frm";
+    $where = "where$frm";
+    
+    if( $search_memory > 0 ) {
+        if ( $$what == '' ) {
+            $$what = getPref($data_dir, $username, "search_what$frm", '' );
+            $$where = getPref($data_dir, $username, "search_where$frm", '' );
         } else {
-            echo "         <OPTION VALUE=\"$box\">$box2</OPTION>\n";
-        }   
+            setpref( $data_dir, $username, "search_what$frm", $$what );
+            setpref( $data_dir, $username, "search_where$frm", $$where );
+        }
     }
-}
-echo '         </SELECT></SMALL></TT>'.
-     "       </TD>\n".
-     "        <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
-if (!isset($what)) {
-   $what = '';
-}
-$what_disp = ereg_replace(',', ' ', $what);
-$what_disp = str_replace('\\\\', '\\', $what_disp);
-$what_disp = str_replace('\\"', '"', $what_disp);
-$what_disp = str_replace('"', '&quot;', $what_disp);
-echo "          <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n".
-            '</TD>'.
-           "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n".
-             '<SELECT NAME="where">';
+    echo "   <TABLE WIDTH=\"75%\" cellpadding=0 cellspacing=0>\n";
+    if( !($form == 0 && $search_memory > 0) ) {
 
-s_opt( 'BODY', ($where == 'BODY'), _("Body") );
-s_opt( 'TEXT', ($where == 'TEXT'), _("Everywhere") );
-s_opt( 'SUBJECT', ($where == 'SUBJECT'), _("Subject") );
-s_opt( 'FROM', ($where == 'FROM'), _("From") );
-s_opt( 'CC', ($where == 'CC'), _("Cc") );
-s_opt( 'TO', ($where == 'TO'), _("To") );
+        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);
+        
+        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']);
+                if ($mailbox == $box) {
+                    echo "         <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
+                } else {
+                    echo "         <OPTION VALUE=\"$box\">$box2</OPTION>\n";
+                }   
+            }
+        }
+        echo '         </SELECT></SMALL></TT>'.
+             "       </TD>\n".
+             "        <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
+        if (!isset($$what)) {
+           $$what = '';
+        }
+        $what_disp = str_replace(',', ' ', $$what);
+        $what_disp = str_replace('\\\\', '\\', $what_disp);
+        $what_disp = str_replace('\\"', '"', $what_disp);
+        $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".
+                     "<SELECT NAME=\"where$frm\">";
+        
+        s_opt( 'BODY', $$where, _("Body") );
+        s_opt( 'TEXT', $$where, _("Everywhere") );
+        s_opt( 'SUBJECT', $$where, _("Subject") );
+        s_opt( 'FROM', $$where, _("From") );
+        s_opt( 'CC', $$where, _("Cc") );
+        s_opt( 'TO', $$where, _("To") );
+        
+        echo "         </SELECT>\n" .
+             "        </TD>\n".
+             "       <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
+             "         <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
+             "       </TD>\n".
+             "     </TR>\n".
+             '</FORM>';
+    }         
+    echo "   </TABLE>\n";
+}     
 
-echo "         </SELECT>\n" .
-     "        </TD>\n".
-     "       <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
-     "         <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
-     "       </TD>\n".
-     "     </TR>\n".
-     "   </TABLE>\n".
-     "</FORM>".
-     "</td></tr></table>";
+echo "</td></tr></table>";
 do_hook("search_after_form");
-if (isset($where) && $where && isset($what) && $what) {
+if( !isset( $pos ) ) {
+    $pos = $frm;
+}
+$what = "what$pos";
+$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);
 }
 do_hook("search_bottom");
 sqimap_logout ($imapConnection);
 
 echo '</body></html>';
 
-?>
+?>
\ No newline at end of file