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;
}
}
+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', '<b><big>' . _("Folder:") . ' '. $showbox.'</big></b>','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 */
$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);
echo "</table></td></tr></table>\n";
}
-/* Recent Search Table */
if ($recent_count > 0) {
echo "<br>\n"
. html_tag( 'table', '', 'center', $color[9], 'width="95%" cellpadding="1" cellspacing="1" border="0"' )
echo '</table></td></tr></table><br>';
}
+
+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', '<b>' . _("Current Search") . '</b>', 'left' ) . "\n"
. '<form action="search.php" name="s">'
if ($search_all == 'all') {
$mailbox == '';
$boxcount = count($boxes);
- echo '<br><center><b>' .
+ echo '<BR><CENTER><B>' .
_("Search Results") .
- "</b><center><br>\n";
+ "</B><CENTER><BR>\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<count($perbox_count);$i++) {
- if ($perbox_count[$i] != "") {
- $count_all = "found";
+ if ($perbox_count[$i]) {
+ $count_all = true;
break;
}
}
- if ($count_all != "found") {
- echo '<br><b>' .
- _("No Messages found") .
- '</b><br>';
+ if (!$count_all) {
+ echo '<br><center>' . _("No Messages Found") . '</center>';
}
}
echo '<br>'
. html_tag( 'div', '<b>' . _("Search Results") . '</b>', '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 '<br><center>' . _("No Messages Found") . '</center>';
+ }
}
}
$allow_thread_sort = $old_value;
+
do_hook('search_bottom');
sqimap_logout ($imapConnection);
echo '</body></html>';