X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsearch.php;h=78f3f7e77d801b11b28f64a60090591e80ae770d;hb=3d8fe250df02c0414bc3014a46cf82374f96c975;hp=00c46a79fd279ccbd45b38baddd5da2c956b125a;hpb=91954f9e073843968c0c6cc575bf0af38410d7a7;p=squirrelmail.git diff --git a/src/search.php b/src/search.php index 00c46a79..78f3f7e7 100644 --- a/src/search.php +++ b/src/search.php @@ -16,9 +16,9 @@ require_once('../functions/array.php'); require_once('../functions/strings.php'); -// here are some functions, could go in imap_search.php -// this was here, pretty handy +/* here are some functions, could go in imap_search.php + this was here, pretty handy */ function s_opt( $val, $sel, $tit ) { echo " \n"; } -// function to get the recent searches and put them in arrays - +/* 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++; + $array[$n] = getPref($data_dir, $username, "$pref_name" . "$x", ""); + $n++; } return $array; } -// function to get the saved searches and put them in arrays - +/* 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++; + if ($array[$n] == "") { + array_pop($array); + return $array; + } + $n++; } return $array; } -// function to update pref file with recent searches - -function update_recent($array, $recent_value, $pref_name, $username, $data_dir) { - $array = get_recent($pref_name, $username, $data_dir); - array_push ($array, $recent_value); - array_shift ($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". - "
\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); + "\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_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
' - . ''; + . "
" + . '
Saved Searches
' + . ''; for ($i=0; $i < $saved_count; ++$i) { - if ($i % 2) { - echo ""; - } else { + if ($i % 2) { + echo ""; + } else { echo ""; } echo "" - . "" - . "" - . ''; + . "" + . "" + . ''; } echo "
$saved_folder_array[$i]$saved_what_array[$i]$saved_where_array[$i]' - . '' . _("edit") . '' - . ' | ' - . '' . _("search") . '' - . ' | ' - . "" - . _("delete") - . '' - . '
$saved_what_array[$i]$saved_where_array[$i]' + . '' . _("edit") . '' + . ' | ' + . '' . _("search") . '' + . ' | ' + . "" + . _("delete") + . '' + . '
\n"; } @@ -286,7 +297,7 @@ if ($recent_count > 0) { } /* Search Form */ -echo 'Current Search' +echo '' . _("Current Search") . '' . '
' . ' ' . ' ' @@ -295,12 +306,15 @@ for ($i = 0; $i < count($boxes); $i++) { if (!in_array('noselect', $boxes[$i]['flags'])) { $box = $boxes[$i]['unformatted']; $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']); + if( $box2 == 'INBOX' ) { + $box2 = _("INBOX"); + } if ($mailbox == $box) { echo " \n"; } else { echo " \n"; - } + } } } echo "\n". " \n". " \n". "\n". @@ -336,50 +353,59 @@ echo " \n" . "
\n"; +if ( !isset( $what ) ) { + $what = ''; +} $what_disp = str_replace(',', ' ', $what); $what_disp = str_replace('\\\\', '\\', $what_disp); $what_disp = str_replace('\\"', '"', $what_disp); @@ -328,7 +345,7 @@ s_opt( 'TO', $where, _("To") ); echo " \n" . " \n". - " \n". + " \n". "
\n"; -do_hook("search_after_form"); +do_hook('search_after_form'); -// search all folders option still in the works. returns a table for each -// folder it finds a match in. The toggle all link does not work +/* + search all folders option still in the works. returns a table for each + folder it finds a match in. +*/ - -if ($search_all == "all") { - $mailbox == ""; +if ($search_all == 'all') { + $mailbox == ''; $boxcount = count($boxes); - echo "
Search Results

\n"; + 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)) { + $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, $pos, $search_all, $count_all); - } + $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") . + '
'; } - if ($count_all == 0) { - echo "
No Messages found
"; - } } -// search one folder option - +/* search one folder option */ else { - if (($submit == "Search" || $submit == "Search_no_update") && !empty($what)) { - echo "
Search Results
\n"; + 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, $pos, $search_all, $count_all); + sqimap_search($imapConnection, $where, $what, $mailbox, $color, 0, $search_all, $count_all); } } -// must have search terms to search - -if ($submit == "Search" && empty($what)) { +/* must have search terms to search */ +if ($submit == _("Search") && empty($what)) { echo "
Please enter something to search for
\n"; } -do_hook("search_bottom"); - -// all done - +do_hook('search_bottom'); sqimap_logout ($imapConnection); echo '';