Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F224707
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index 2078262eb..5cc2a574d 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -1,81 +1,87 @@
<?php
/*
+-----------------------------------------------------------------------+
| program/steps/mail/list.inc |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
| Send message list to client (as remote response) |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
$Id$
*/
// is there a sort type for this request?
if ($sort = get_input_value('_sort', RCUBE_INPUT_GET))
{
// yes, so set the sort vars
list($sort_col, $sort_order) = explode('_', $sort);
// set session vars for sort (so next page and task switch know how to sort)
$save_arr = array();
$_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col;
$_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order;
$RCMAIL->user->save_prefs($save_arr);
}
else
{
// use session settings if set, defaults if not
$sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
$sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
}
$mbox_name = $IMAP->get_mailbox_name();
// initialize searching result if search_filter is used
if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL')
{
$search_request = md5($mbox_name.$_SESSION['search_filter']);
$IMAP->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $sort_col);
$_SESSION['search'][$search_request] = $IMAP->get_search_set();
$OUTPUT->set_env('search_request', $search_request);
}
// fetch message headers
if ($IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
$a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
$count = $IMAP->messagecount($mbox_name);
$unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh']));
// update message count display
$pages = ceil($count/$IMAP->page_size);
$OUTPUT->set_env('messagecount', $count);
$OUTPUT->set_env('pagecount', $pages);
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count));
$OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text());
// add message rows
if (isset($a_headers) && count($a_headers))
+{
rcmail_js_message_list($a_headers);
+ if ($search_request)
+ $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
+}
+else if ($search_request)
+ $OUTPUT->show_message('searchnomatch', 'notice');
else
$OUTPUT->show_message('nomessagesfound', 'notice');
// update mailboxlist
$OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
// send response
$OUTPUT->send();
?>
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index b7ab2e182..aa76f8e43 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -1,121 +1,121 @@
<?php
/*
+-----------------------------------------------------------------------+
| steps/mail/search.inc |
| |
| Search functions for rc webmail |
| Licensed under the GNU GPL |
| |
+-----------------------------------------------------------------------+
| Author: Benjamin Smith <defitro@gmail.com> |
| Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
*/
$REMOTE_REQUEST = TRUE;
// reset list_page and old search results
$IMAP->set_page(1);
$IMAP->set_search_set(NULL);
$_SESSION['page'] = 1;
// using encodeURI with javascript "should" give us
// a correctly UTF-8 encoded query string
$imap_charset = 'UTF-8';
// get search string
$str = get_input_value('_q', RCUBE_INPUT_GET);
$filter = get_input_value('_filter', RCUBE_INPUT_GET);
$mbox = get_input_value('_mbox', RCUBE_INPUT_GET);
$search_request = md5($mbox.$filter.$str);
// add list filter string
$search_str = $filter && $filter != 'ALL' ? $filter : '';
$_SESSION['search_filter'] = $filter;
// Check the search string for type of search
if (preg_match("/^from:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject = "HEADER FROM";
$search = trim($srch);
}
else if (preg_match("/^to.*:/i", $str))
{
list(,$srch) = explode(":", $str);
$subject = "HEADER TO";
$search = trim($srch);
}
else if (preg_match("/^cc:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject = "HEADER CC";
$search = trim($srch);
}
else if (preg_match("/^subject:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject = "HEADER SUBJECT";
$search = trim($srch);
}
else if (preg_match("/^body:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject = "TEXT";
$search = trim($srch);
}
// search in subject and sender by default
else if(trim($str))
{
$from = ($mbox == $CONFIG['sent_mbox'] || $mbox == $CONFIG['drafts_mbox']) ? "TO" : "FROM";
$subject = array("HEADER SUBJECT", "HEADER $from");
$search = trim($str);
}
if ($subject && !is_array($subject))
$search_str .= sprintf(" %s {%d}\r\n%s", $subject, strlen($search), $search);
else if ($subject) {
$search_str .= ' OR';
foreach($subject as $sub)
$search_str .= sprintf(" %s {%d}\r\n%s", $sub, strlen($search), $search);
}
$search_str = trim($search_str);
// execute IMAP search
if ($search_str)
$result = $IMAP->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']);
// Get the headers
$result_h = $IMAP->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']);
$count = $IMAP->messagecount();
// save search results in session
if (!is_array($_SESSION['search']))
$_SESSION['search'] = array();
// Make sure we got the headers
if (!empty($result_h))
{
+ rcmail_js_message_list($result_h);
if ($search_str) {
$_SESSION['search'][$search_request] = $IMAP->get_search_set();
$_SESSION['last_text_search'] = $str;
+ $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
}
- rcmail_js_message_list($result_h);
- $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
}
else
{
$OUTPUT->show_message('searchnomatch', 'notice');
}
// update message count display
$OUTPUT->set_env('search_request', $search_str ? $search_request : -1);
$OUTPUT->set_env('messagecount', $count);
$OUTPUT->set_env('pagecount', ceil($count/$IMAP->page_size));
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1));
$OUTPUT->send();
?>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Mar 1, 12:02 PM (3 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
166892
Default Alt Text
(7 KB)
Attached To
Mode
R3 roundcubemail
Attached
Detach File
Event Timeline
Log In to Comment