X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsearch.php;h=3acc5b1262274dc0fea371b4eb4e21e19dcd48c4;hb=8e2ed8074e44d18b334e13bfa80c2a4a78d37d13;hp=8ace7760cb04d2182659311e9745bfa33d35e1db;hpb=548a552a51c35aff7b8a9db77fade2835685f2f5;p=squirrelmail.git diff --git a/src/search.php b/src/search.php index 8ace7760..3acc5b12 100644 --- a/src/search.php +++ b/src/search.php @@ -12,6 +12,7 @@ require_once('../src/validate.php'); require_once('../functions/imap.php'); require_once('../functions/imap_search.php'); +require_once('../functions/imap_mailbox.php'); require_once('../functions/array.php'); require_once('../functions/strings.php'); @@ -158,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 */ @@ -167,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); @@ -181,7 +211,9 @@ if ($mailbox == 'All Folders') { } if (isset($composenew) && $composenew) { - displayPageHeader($color, $mailbox, 'comp_in_new();'); + $comp_uri = "../src/compose.php?mailbox=". urlencode($mailbox). + "&session=$composesession&attachedmessages=true&"; + displayPageHeader($color, $mailbox, "comp_in_new(false,'$comp_uri');", false); } else { displayPageHeader($color, $mailbox); } @@ -208,12 +240,12 @@ elseif ($submit == 'delete') { do_hook('search_before_form'); -echo "
\n". - "\n". - "\n". - "
\n". - "
" . _("Search") . "
\n". - "
\n"; +echo "
\n". + html_tag( 'table', + html_tag( 'tr', "\n" . + html_tag( 'td', '' . _("Search") . '', 'center', $color[0] ) + ) , + '', '', 'width="100%"') . "\n"; /* update the recent and saved searches from the pref files */ $attributes = get_recent($username, $data_dir); @@ -223,47 +255,54 @@ $count_all = 0; /* Saved Search Table */ if ($saved_count > 0) { - echo "
\n" - . "" - . '
Saved Searches
' - . ''; + echo "
\n" + . html_tag( 'table', '', 'center', $color[9], 'width="95%" cellpadding="1" cellspacing="1" border="0"' ) + . html_tag( 'tr', + html_tag( 'td', 'Saved Searches', 'center' ) + ) + . html_tag( 'tr' ) + . html_tag( 'td' ) + . html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="2" cellspacing="2" border="0"' ); for ($i=0; $i < $saved_count; ++$i) { if ($i % 2) { - echo ""; + echo html_tag( 'tr', '', '', $color[0] ); } else { - echo ""; + echo html_tag( 'tr', '', '', $color[4] ); } - echo "" - . "" - . "" - . ''; + . '' + . ''; } - echo "
".$saved_attributes['saved_folder'][$i]."".$saved_attributes['saved_what'][$i]."".$saved_attributes['saved_where'][$i]."' - . '' . _("edit") . '' + . '>' . _("edit") . '' . ' | ' - . '' . _("search") . '' + . '>' . _("search") . '' . ' | ' - . "" + . "" . _("delete") - . '' - . '
\n"; + echo "\n"; } -/* Recent Search Table */ if ($recent_count > 0) { - echo "
\n" - . "\n" - . '
' . _("Recent Searches") . '
' - . ''; + echo "
\n" + . html_tag( 'table', '', 'center', $color[9], 'width="95%" cellpadding="1" cellspacing="1" border="0"' ) + . html_tag( 'tr', + html_tag( 'td', '' . _("Recent Searches") . '', 'center' ) + ) + . html_tag( 'tr' ) + . html_tag( 'td' ) + . html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="0" cellspacing="0" border="0"' ); for ($i=1; $i <= $recent_count; ++$i) { if (isset($attributes['search_folder'][$i])) { if ($attributes['search_folder'][$i] == "") { @@ -271,65 +310,86 @@ if ($recent_count > 0) { } } if ($i % 2) { - echo ""; + echo html_tag( 'tr', '', '', $color[0] ); } else { - echo ""; + echo html_tag( 'tr', '', '', $color[0] ); } if (isset($attributes['search_what'][$i]) && !empty($attributes['search_what'][$i])) { - echo "" - . "" - . "" - . ''; + . '' + . ''; } } - echo '
".$attributes['search_folder'][$i]."".$attributes['search_what'][$i]."".$attributes['search_where'][$i]."' - . "" + echo html_tag( 'td', $attributes['search_folder'][$i], 'left', '', 'width="35%"' ) + . html_tag( 'td', $attributes['search_what'][$i], 'left' ) + . html_tag( 'td', $attributes['search_where'][$i], 'center' ) + . html_tag( 'td', '', 'right' ) + . "" . _("save") - . '' + . '' . ' | ' - . '' . _("search") . '' + . '>' . _("search") . '' . ' | ' - . "" + . "" . _("forget") - . '' - . '

'; + 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 '' . _("Current Search") . '' - . '
' - . ' ' - . ' ' - . ' \n". - " \n"; if ( !isset( $what ) ) { $what = ''; } @@ -342,25 +402,22 @@ $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". - "
'; 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']); + $box2 = str_replace(' ', ' ', + imap_utf7_decode_local($boxes[$i]['unformatted-disp'])); if( $box2 == 'INBOX' ) { $box2 = _("INBOX"); } - if ($mailbox == $box) { - echo " \n"; - } - else { - echo " \n"; - } + echo ' ' . "\n"; } } - echo "\n"; -echo ' '. - " \n"; + echo ">All folders\n"; +echo ' '. + " \n". - "' . "\n", 'center' ) + . html_tag( 'td', '', 'right' ) + . "\n" . - " \n". - " \n". - "
\n". - "\n"; +echo " \n" . + " \n". + html_tag( 'td', '' . "\n", 'center', '', 'colspan="3"' ) . + " \n". + "\n". + " \n". + "\n"; do_hook('search_after_form'); @@ -388,41 +445,49 @@ if ($search_all == 'all') { } 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") . '
'; } } /* search one folder option */ else { if (($submit == _("Search") || $submit == 'Search_no_update') && !empty($what)) { - echo '
' . - _("Search Results") . - "
\n"; + 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") . '
'; + } } } /* must have search terms to search */ if ($submit == _("Search") && empty($what)) { - echo "
Please enter something to search for
\n"; + echo '
' + . html_tag( 'div', 'Please enter something to search for', 'center' ) . "\n"; } $allow_thread_sort = $old_value; + do_hook('search_bottom'); sqimap_logout ($imapConnection); echo '';