X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsearch.php;h=3acc5b1262274dc0fea371b4eb4e21e19dcd48c4;hb=6540ee5ef6f1183ea6620fec82ac53f82316a419;hp=8a04fd70b585616566eaa29e1e54e3fbb86a1576;hpb=fab3baa6746c2a20c9477b38dfd7f3e4aeeeeef7;p=squirrelmail.git diff --git a/src/search.php b/src/search.php index 8a04fd70..3acc5b12 100644 --- a/src/search.php +++ b/src/search.php @@ -12,10 +12,9 @@ require_once('../src/validate.php'); require_once('../functions/imap.php'); require_once('../functions/imap_search.php'); -require_once('../functions/imap_utf7_decode_local.php'); +require_once('../functions/imap_mailbox.php'); require_once('../functions/array.php'); require_once('../functions/strings.php'); -require_once('../functions/html.php'); global $allow_thread_sort; @@ -160,6 +159,34 @@ function save_recent($save_index, $username, $data_dir) { } } +function printSearchMessages($msgs,$mailbox, $cnt, $imapConnection, $where, $what, $usecache = false, $newsort = false) { + global $sort, $color; + + $msort = calc_msort($msgs, $sort); + if ($cnt > 0) { + if ( $mailbox == 'INBOX' ) { + $showbox = _("INBOX"); + } else { + $showbox = imap_utf7_decode_local($mailbox); + } + echo html_tag( 'div', '' . _("Folder:") . ' '. $showbox.'','center') . "\n"; + + + $msg_cnt_str = get_msgcnt_str(1, $cnt, $cnt); + + mail_message_listing_beginning($imapConnection, $mailbox, $sort, + $msg_cnt_str, '', 1); + + + printHeader($mailbox, 6, $color, false); + + displayMessageArray($imapConnection, $cnt, 1, + $msort, $mailbox, $sort, $color, $cnt, $where, $what); + + mail_message_listing_end($cnt, '', $msg_cnt_str, $color); + } +} + /* ------------------------ main ------------------------ */ /* reset these arrays on each page load just in case */ @@ -169,6 +196,7 @@ $search_all = 'none'; $perbox_count = array (); $recent_count = getPref($data_dir, $username, 'search_memory', 0); + /* get mailbox names */ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); @@ -266,7 +294,6 @@ if ($saved_count > 0) { echo "\n"; } -/* Recent Search Table */ if ($recent_count > 0) { echo "
\n" . html_tag( 'table', '', 'center', $color[9], 'width="95%" cellpadding="1" cellspacing="1" border="0"' ) @@ -313,6 +340,29 @@ if ($recent_count > 0) { echo '
'; } + +if (isset($newsort)) { + $sort = $newsort; + session_register('sort'); +} + +/********************************************************************* + * Check to see if we can use cache or not. Currently the only time * + * when you will not use it is when a link on the left hand frame is * + * used. Also check to make sure we actually have the array in the * + * registered session data. :) * + *********************************************************************/ +if (! isset($use_mailbox_cache)) { + $use_mailbox_cache = 0; +} + +/* There is a problem with registered vars in 4.1 */ +/* +if( substr( phpversion(), 0, 3 ) == '4.1' ) { + $use_mailbox_cache = FALSE; +} +*/ + /* Search Form */ echo html_tag( 'div', '' . _("Current Search") . '', 'left' ) . "\n" . '
' @@ -386,29 +436,30 @@ if ($allow_thread_sort == TRUE) { if ($search_all == 'all') { $mailbox == ''; $boxcount = count($boxes); - echo '
' . + echo '
' . _("Search Results") . - "

\n"; + "

\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); + $msgs = sqimap_search($imapConnection, $where, $what, $mailbox, $color, 0, $search_all, $count_all); + $count_all = count($msgs); + printSearchMessages($msgs, $mailbox, $count_all, $imapConnection, + $where, $what, false, false); + array_push($perbox_count, $count_all); } } for ($i=0;$i' . - _("No Messages found") . - '
'; + if (!$count_all) { + echo '
' . _("No Messages Found") . '
'; } } @@ -418,7 +469,13 @@ else { echo '
' . html_tag( 'div', '' . _("Search Results") . '', 'center' ) . "\n"; sqimap_mailbox_select($imapConnection, $mailbox); - sqimap_search($imapConnection, $where, $what, $mailbox, $color, 0, $search_all, $count_all); + $msgs = sqimap_search($imapConnection, $where, $what, $mailbox, $color, 0, $search_all, $count_all); + if (count($msgs)) { + printSearchMessages($msgs, $mailbox, count($msgs), $imapConnection, + $where, $what, false, false); + } else { + echo '
' . _("No Messages Found") . '
'; + } } } @@ -430,6 +487,7 @@ if ($submit == _("Search") && empty($what)) { $allow_thread_sort = $old_value; + do_hook('search_bottom'); sqimap_logout ($imapConnection); echo '';