X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fsearch.php;h=bb98716a15f9c18b51d061cc29886c4047acc0c7;hp=eddf8ae3943bf7c20ca5846350dae3cc7623b350;hb=854000c01b0a890c69ce818a00517acb35e1857a;hpb=0d672ac0213e1aa4b87954a10796cf4fdc0adf3c diff --git a/src/search.php b/src/search.php index eddf8ae3..bb98716a 100644 --- a/src/search.php +++ b/src/search.php @@ -1,7 +1,7 @@ $tit\n"; } +/* function to get the recent searches and put them in arrays */ +function get_recent($pref_name, $username, $data_dir) { + $array = array (); + $recent_count = getPref($data_dir, $username, 'search_memory', 0); + $n = 0; + for ($x=1;$x<=$recent_count;$x++) { + $array[$n] = getPref($data_dir, $username, "$pref_name" . "$x", ""); + $n++; + } + return $array; +} + +/* function to get the saved searches and put them in arrays */ +function get_saved($pref_name, $username, $data_dir) { + $array = array (); + $n = 0; + for ($x=1;;$x++) { + $array[$n] = getPref($data_dir, $username, "$pref_name" . "$x", ""); + if ($array[$n] == "") { + array_pop($array); + return $array; + } + $n++; + } + return $array; +} + +/* function to update recent pref arrays */ +function update_recent($what, $where, $mailbox, $username, $data_dir) { + $what_array = get_recent('search_what', $username, $data_dir); + $where_array = get_recent('search_where', $username, $data_dir); + $folder_array = get_recent('search_folder', $username, $data_dir); + $dupe = 'no'; + for ($i=0;$i\n". - " \n". - " \n". - '
\n". - "
"._("Search")."
\n". - "
'; - -for ( $form = 0; $form <= $search_memory; $form++ ) { - - $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", '' ); + +echo "
\n". + "\n". + "\n". + "
\n". + "
" . _("Search") . "
\n". + "
\n"; + +/* update the recent and saved searches from the pref files */ +$what_array = get_recent('search_what', $username, $data_dir); +$where_array = get_recent('search_where', $username, $data_dir); +$folder_array = get_recent('search_folder', $username, $data_dir); +$recent_count = getPref($data_dir, $username, 'search_memory', 0); +$saved_what_array = get_saved('saved_what', $username, $data_dir); +$saved_where_array = get_saved('saved_where', $username, $data_dir); +$saved_folder_array = get_saved('saved_folder', $username, $data_dir); +$saved_count = count($saved_what_array); +$count_all = 0; + +/* Saved Search Table */ +if ($saved_count > 0) { + echo "
\n" + . "" + . '
Saved Searches
' + . ''; + for ($i=0; $i < $saved_count; ++$i) { + if ($i % 2) { + echo ""; } else { - setpref( $data_dir, $username, "search_what$frm", $$what ); - setpref( $data_dir, $username, "search_where$frm", $$where ); + echo ""; } + echo "" + . "" + . "" + . ''; } - echo "
$saved_folder_array[$i]$saved_what_array[$i]$saved_where_array[$i]' + . '' . _("edit") . '' + . ' | ' + . '' . _("search") . '' + . ' | ' + . "" + . _("delete") + . '' + . '
\n"; - if( !($form == 0 && $search_memory > 0) ) { - - echo "\n". - "". - " \n". - "
\n". - '
\n"; +} + +/* Recent Search Table */ +if ($recent_count > 0) { + echo "
\n" + . "\n" + . '
Recent Searches
' + . ''; + for ($i=0; $i < $recent_count; ++$i) { + if (!empty($what_array[$i])) { + if ($folder_array[$i] == "") { + $folder_array[$i] = "INBOX"; + } + if ($i % 2) { + echo ""; + } else { + echo ""; } + echo "" + . "" + . "" + . ''; } - echo ' '. - " \n". - "
$folder_array[$i]$what_array[$i]$where_array[$i]' + . "" + . _("save") + . '' + . ' | ' + . '' . _("search") . '' + . ' | ' + . "" + . _("forget") + . '' + . '
\n"; - if (!isset($$what)) { - $$what = ''; + } + echo '

'; +} + +/* Search Form */ +echo '' . _("Current Search") . '' + . '' + . ' ' + . ' ' + . ' '. - "\n". - " \n". - " \n". - ''; - } - echo "
\n". - '\n". - "\n" . - " \n". - " \n". - "
\n"; -} - -echo "
"; -do_hook("search_after_form"); -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); -} -do_hook("search_bottom"); -sqimap_logout ($imapConnection); + if ($mailbox == $box) { + echo " \n"; + } + else { + echo " \n"; + } + } +} + echo "\n"; +echo ' '. + " \n". + " \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('"', '"', $what_disp); +echo " \n". + " \n". + "\n". + "\n" . + " \n". + " \n". + " \n". + " \n". + " \n". + "\n". + " \n". + "\n"; + +do_hook('search_after_form'); + +/* + search all folders option still in the works. returns a table for each + folder it finds a match in. +*/ + +if ($search_all == 'all') { + $mailbox == ''; + $boxcount = count($boxes); + echo '
' . + _("Search Results") . + "

\n"; + for ($x=0;$x<$boxcount;$x++) { + if (!in_array('noselect', $boxes[$x]['flags'])) { + $mailbox = $boxes[$x]['unformatted']; + } + if (($submit == _("Search") || $submit == 'Search_no_update') && !empty($what)) { + sqimap_mailbox_select($imapConnection, $mailbox); + $count_all = sqimap_search($imapConnection, $where, $what, $mailbox, $color, 0, $search_all, $count_all); + array_push($perbox_count, $count_all); + } + } + for ($i=0;$i' . + _("No Messages found") . + '
'; + } +} + +/* search one folder option */ +else { + if (($submit == _("Search") || $submit == 'Search_no_update') && !empty($what)) { + echo '
' . + _("Search Results") . + "
\n"; + sqimap_mailbox_select($imapConnection, $mailbox); + sqimap_search($imapConnection, $where, $what, $mailbox, $color, 0, $search_all, $count_all); + } +} + +/* must have search terms to search */ +if ($submit == _("Search") && empty($what)) { + echo "
Please enter something to search for
\n"; +} + +do_hook('search_bottom'); +sqimap_logout ($imapConnection); echo ''; -?> \ No newline at end of file +?>