X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsearch.php;h=5b2118632ca8370d5b65f54e4c81c09fc4b061fa;hb=605ce3855a47f1062e4ddc8fe96d70b366e49269;hp=78beb7317bb9d9e9a4858225b9c7723d04b2962c;hpb=8cc8ec794a4111845258794961df8cb093ab2b3f;p=squirrelmail.git diff --git a/src/search.php b/src/search.php index 78beb731..5b211863 100644 --- a/src/search.php +++ b/src/search.php @@ -1,39 +1,40 @@ ' . $txt . ''; } - /** -* @param array $color color array -* @param string $txt text to display -* @return string error text ready to display -*/ + * @param array $color color array + * @param string $txt text to display + * @return string error text ready to display + */ function asearch_get_error_display(&$color, $txt) { return '' . '' . $txt . ''; } /** -* @param array $input_array array to serialize -* @return string a string containing a byte-stream representation of value that can be stored anywhere -*/ + * @param array $input_array array to serialize + * @return string a string containing a byte-stream representation of value that can be stored anywhere + */ function asearch_serialize(&$input_array) { global $search_advanced; @@ -146,9 +147,9 @@ function asearch_serialize(&$input_array) } /** -* @param string $input_string string to unserialize -* @return array -*/ + * @param string $input_string string to unserialize + * @return array + */ function asearch_unserialize($input_string) { global $search_advanced; @@ -158,11 +159,11 @@ function asearch_unserialize($input_string) } /** -* @param string $key the pref key -* @param integer $index the pref key index -* @param string $default default value -* @return string pref value -*/ + * @param string $key the pref key + * @param integer $index the pref key index + * @param string $default default value + * @return string pref value + */ function asearch_getPref(&$key, $index, $default = '') { global $data_dir, $username, $search_advanced; @@ -170,11 +171,11 @@ function asearch_getPref(&$key, $index, $default = '') } /** -* @param string $key the pref key -* @param integer $index the pref key index -* @param string $value pref value to set -* @return bool status -*/ + * @param string $key the pref key + * @param integer $index the pref key index + * @param string $value pref value to set + * @return bool status + */ function asearch_setPref(&$key, $index, $value) { global $data_dir, $username, $search_advanced; @@ -182,10 +183,10 @@ function asearch_setPref(&$key, $index, $value) } /** -* @param string $key the pref key -* @param integer $index the pref key index -* @return bool status -*/ + * @param string $key the pref key + * @param integer $index the pref key index + * @return bool status + */ function asearch_removePref(&$key, $index) { global $data_dir, $username, $search_advanced; @@ -193,7 +194,7 @@ function asearch_removePref(&$key, $index) } /** Sanity checks, done before running the imap command and before calling push_recent -*/ + */ function asearch_check_query(&$where_array, &$what_array, &$exclude_array) { global $imap_asearch_opcodes; @@ -212,7 +213,7 @@ function asearch_check_query(&$where_array, &$what_array, &$exclude_array) } /** Read the recent searches from the prefs -*/ + */ function asearch_read_recent() { global $recent_prefkeys, $search_memory; @@ -222,14 +223,14 @@ function asearch_read_recent() for ($pref_num = 0; $pref_num < $search_memory; $pref_num++) { foreach ($recent_prefkeys as $prefkey) { $pref = asearch_getPref($prefkey, $pref_num); -/* if (!empty($pref))*/ +/* if (!empty($pref))*/ $recent_array[$prefkey][$recent_num] = $pref; } if (empty($recent_array[$recent_prefkeys[0]][$recent_num])) { foreach ($recent_prefkeys as $key) { array_pop($recent_array[$key]); } -// break; //Disabled to support old search code broken prefs +// break; //Disabled to support old search code broken prefs } else $recent_num++; @@ -238,7 +239,7 @@ function asearch_read_recent() } /** Read the saved searches from the prefs -*/ + */ function asearch_read_saved() { global $saved_prefkeys; @@ -259,7 +260,7 @@ function asearch_read_saved() } /** Save a recent search to the prefs -*/ + */ function asearch_save_recent($recent_index) { global $recent_prefkeys, $saved_prefkeys; @@ -279,7 +280,7 @@ function asearch_save_recent($recent_index) } /** Write a recent search to prefs -*/ + */ function asearch_write_recent(&$recent_array) { global $recent_prefkeys, $search_memory; @@ -298,7 +299,7 @@ function asearch_write_recent(&$recent_array) } /** Remove a recent search from prefs -*/ + */ function asearch_forget_recent($forget_index) { global $recent_prefkeys; @@ -311,7 +312,7 @@ function asearch_forget_recent($forget_index) } /** Find a recent search in the prefs (used to avoid saving duplicates) -*/ + */ function asearch_find_recent(&$recent_array, &$mailbox_array, &$biop_array, &$unop_array, &$where_array, &$what_array, &$exclude_array, &$sub_array) { global $recent_prefkeys, $search_advanced; @@ -345,17 +346,22 @@ function asearch_find_recent(&$recent_array, &$mailbox_array, &$biop_array, &$un } /** Push a recent search into the prefs -*/ + */ function asearch_push_recent(&$mailbox_array, &$biop_array, &$unop_array, &$where_array, &$what_array, &$exclude_array, &$sub_array) { global $recent_prefkeys, $search_memory; - - $criteria = array($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array); + //global $what; // Hack to access issued search from read_body.php + $what = 1; + /** + * Update search history and store it in the session so we can retrieve the + * issued search when returning from an external page like read_body.php + */ + $criteria[$what] = array($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array); sqsession_register($criteria, ASEARCH_CRITERIA); if ($search_memory > 0) { $recent_array = asearch_read_recent(); $recent_found = asearch_find_recent($recent_array, $mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array); - if ($recent_found >= 0) { // Remove identical recent + if ($recent_found >= 0) { // Remove identical recent foreach ($recent_prefkeys as $key) { array_splice($recent_array[$key], $recent_found, 1); } @@ -371,8 +377,8 @@ function asearch_push_recent(&$mailbox_array, &$biop_array, &$unop_array, &$wher } /** Edit a recent search -* @global array mailbox_array searched mailboxes -*/ + * @global array mailbox_array searched mailboxes + */ function asearch_edit_recent($index) { global $recent_prefkeys, $search_advanced; @@ -391,30 +397,31 @@ function asearch_edit_recent($index) } /** Get last search criteria from session or prefs -*/ -function asearch_edit_last() -{ + * FIX ME, try to avoid globals + */ +function asearch_edit_last($index) { if (sqGetGlobalVar(ASEARCH_CRITERIA, $criteria, SQ_SESSION)) { global $where_array, $mailbox_array, $what_array, $unop_array; global $biop_array, $exclude_array, $sub_array; - $mailbox_array = $criteria[0]; - $biop_array = $criteria[1]; - $unop_array = $criteria[2]; - $where_array = $criteria[3]; - $what_array = $criteria[4]; - $exclude_array = $criteria[5]; - $sub_array = $criteria[6]; - sqsession_unregister(ASEARCH_CRITERIA); - } - else { + $mailbox_array = $criteria[$index][0]; + $biop_array = $criteria[$index][1]; + $unop_array = $criteria[$index][2]; + $where_array = $criteria[$index][3]; + $what_array = $criteria[$index][4]; + $exclude_array = $criteria[$index][5]; + $sub_array = $criteria[$index][6]; + unset($criteria[$index]); + //sqsession_unregister(ASEARCH_CRITERIA); + } else { global $search_memory; - if ($search_memory > 0) + if ($search_memory > 0) { asearch_edit_recent(0); + } } } /** Edit a saved search -*/ + */ function asearch_edit_saved($index) { global $saved_prefkeys, $search_advanced; @@ -433,7 +440,7 @@ function asearch_edit_saved($index) } /** Write a saved search to the prefs -*/ + */ function asearch_write_saved(&$saved_array) { global $saved_prefkeys; @@ -450,7 +457,7 @@ function asearch_write_saved(&$saved_array) } /** Delete a saved search from the prefs -*/ + */ function asearch_delete_saved($saved_index) { global $saved_prefkeys; @@ -464,9 +471,9 @@ function asearch_delete_saved($saved_index) } /** Translate the input date to imap date to local date display, -* so the user can know if the date is wrong or illegal -* @return string locally formatted date or error text -*/ + * so the user can know if the date is wrong or illegal + * @return string locally formatted date or error text + */ function asearch_get_date_display(&$what) { $what_parts = sqimap_asearch_parse_date($what); @@ -480,8 +487,8 @@ function asearch_get_date_display(&$what) } /** Translate the query to rough natural display -* @return string rough natural query ready to display -*/ + * @return string rough natural query ready to display + */ function asearch_get_query_display(&$color, &$mailbox_array, &$biop_array, &$unop_array, &$where_array, &$what_array, &$exclude_array, &$sub_array) { global $imap_asearch_biops_in, $imap_asearch_biops, $imap_asearch_unops, $imap_asearch_options; @@ -517,7 +524,7 @@ function asearch_get_query_display(&$color, &$mailbox_array, &$biop_array, &$uno $where_display = $unop_display . asearch_nz($imap_asearch_options[$where], $where); $what_type = $imap_asearch_opcodes[$where]; $what = $what_array[$crit_num]; - if ($what_type) { /* Check opcode parameter */ + if ($what_type) { /* Check opcode parameter */ if ($what == '') $what_display = ' ' . asearch_get_error_display($color, _("(Missing argument)")); else { @@ -543,9 +550,30 @@ function asearch_get_query_display(&$color, &$mailbox_array, &$biop_array, &$uno return $query_display; } +/** + * Creates button + * + * @deprecated see form functions available in 1.5.1 and 1.4.3. + * @param string $type + * @param string $name + * @param string $value + * @param string $js + * @param bool $enabled + */ +function getButton($type, $name, $value, $js = '', $enabled = TRUE) { + $disabled = ( $enabled ? '' : 'disabled ' ); + $js = ( $js ? $js.' ' : '' ); + return ''; +} + + /** Handle the alternate row colors -* @return string color value -*/ + * @return string color value + */ function asearch_get_row_color(&$color, $row_num) { /*$color_string = ($row_num%2 ? $color[0] : $color[4]);*/ @@ -561,7 +589,7 @@ function asearch_get_row_color(&$color, $row_num) } /** Print a whole query array, recent or saved -*/ + */ function asearch_print_query_array(&$boxes, &$query_array, &$query_keys, &$action_array, $title, $show_pref) { global $color; @@ -619,7 +647,7 @@ function asearch_print_query_array(&$boxes, &$query_array, &$query_keys, &$actio } /** Print the saved array -*/ + */ function asearch_print_saved(&$boxes) { global $saved_prefkeys; @@ -635,8 +663,8 @@ function asearch_print_saved(&$boxes) } /** -* Print the recent array -*/ + * Print the recent array + */ function asearch_print_recent(&$boxes) { global $recent_prefkeys, $search_memory; @@ -652,14 +680,14 @@ function asearch_print_recent(&$boxes) } /** Build an ' . "\n"; + return '' . "\n"; } /** Build a ' . "\n"; @@ -670,8 +698,8 @@ function asearch_opt_array($var_name, $opt_array, $cur_val) } /** Verify that a mailbox exists -* @return bool mailbox exists -*/ + * @return bool mailbox exists + */ function asearch_mailbox_exists($mailbox, &$boxes) { foreach ($boxes as $box) { @@ -682,13 +710,14 @@ function asearch_mailbox_exists($mailbox, &$boxes) } /** Build the mailbox select -*/ + */ function asearch_get_form_mailbox($imapConnection, &$boxes, $mailbox, $row_num = 0) { - if (($mailbox != 'All Folders') && (!asearch_mailbox_exists($mailbox, $boxes))) + if (($mailbox != 'All Folders') && (!asearch_mailbox_exists($mailbox, $boxes))) { $missing = asearch_opt($mailbox, $mailbox, '[' . _("Missing") . '] ' . asearch_get_mailbox_display($mailbox)); - else + } else { $missing = ''; + } return '