Consider search scope (and changes) for filter searches + disable folder operation commands in multi-folder search mode (#1485234)

pull/171/merge
Thomas Bruederli 11 years ago
parent 8087b13d20
commit 26b5200322

@ -1300,6 +1300,11 @@ function rcube_webmail()
} }
}; };
this.command_enabled = function(cmd)
{
return this.commands[cmd];
}
// lock/unlock interface // lock/unlock interface
this.set_busy = function(a, message, id) this.set_busy = function(a, message, id)
{ {
@ -2193,6 +2198,7 @@ function rcube_webmail()
// reset vars // reset vars
this.env.current_page = 1; this.env.current_page = 1;
this.env.search_filter = filter;
this.http_request('search', this.search_params(false, filter), lock); this.http_request('search', this.search_params(false, filter), lock);
}; };
@ -4198,7 +4204,11 @@ function rcube_webmail()
this.env.qsearch = {lock: lock, request: r}; this.env.qsearch = {lock: lock, request: r};
this.enable_command('set-listmode', this.env.threads && (this.env.search_scope || 'base') == 'base'); this.enable_command('set-listmode', this.env.threads && (this.env.search_scope || 'base') == 'base');
return true;
} }
return false;
}; };
// build URL params for search // build URL params for search
@ -4262,8 +4272,9 @@ function rcube_webmail()
// re-send search query with new scope // re-send search query with new scope
if (scope != old && this.env.search_request) { if (scope != old && this.env.search_request) {
this.qsearch(this.gui_objects.qsearchbox.value); if (!this.qsearch(this.gui_objects.qsearchbox.value) && this.env.search_filter && this.env.search_filter != 'ALL')
if (scope == 'base') this.filter_mailbox(this.env.search_filter);
if (scope != 'all')
this.select_folder(this.env.mailbox, '', true); this.select_folder(this.env.mailbox, '', true);
} }
}; };
@ -7066,11 +7077,13 @@ function rcube_webmail()
this.env.qsearch = null; this.env.qsearch = null;
case 'list': case 'list':
if (this.task == 'mail') { if (this.task == 'mail') {
var is_multifolder = this.is_multifolder_listing();
this.enable_command('show', 'select-all', 'select-none', this.env.messagecount > 0); this.enable_command('show', 'select-all', 'select-none', this.env.messagecount > 0);
this.enable_command('expunge', this.env.exists); this.enable_command('expunge', this.env.exists && !is_multifolder);
this.enable_command('purge', this.purge_mailbox_test()); this.enable_command('purge', this.purge_mailbox_test() && !is_multifolder);
this.enable_command('expand-all', 'expand-unread', 'collapse-all', this.env.threading && this.env.messagecount); this.enable_command('import-messages', !is_multifolder);
this.enable_command('set-listmode', this.env.threads && !this.is_multifolder_listing()); this.enable_command('expand-all', 'expand-unread', 'collapse-all', this.env.threading && this.env.messagecount && !is_multifolder);
this.enable_command('set-listmode', this.env.threads && !is_multifolder);
if ((response.action == 'list' || response.action == 'search') && this.message_list) { if ((response.action == 'list' || response.action == 'search') && this.message_list) {
this.msglist_select(this.message_list); this.msglist_select(this.message_list);

@ -1492,7 +1492,7 @@ class rcube_imap extends rcube_storage
* @param string $str Search criteria * @param string $str Search criteria
* @param string $charset Search charset * @param string $charset Search charset
* @param string $sort_field Header field to sort by * @param string $sort_field Header field to sort by
* * @return rcube_result_index Search result object
* @todo: Search criteria should be provided in non-IMAP format, eg. array * @todo: Search criteria should be provided in non-IMAP format, eg. array
*/ */
public function search($folder='', $str='ALL', $charset=NULL, $sort_field=NULL) public function search($folder='', $str='ALL', $charset=NULL, $sort_field=NULL)
@ -1531,6 +1531,8 @@ class rcube_imap extends rcube_storage
$this->set_search_set(array($str, $results, $charset, $sort_field, $this->set_search_set(array($str, $results, $charset, $sort_field,
$this->threading || $this->search_sorted ? true : false)); $this->threading || $this->search_sorted ? true : false));
return $results;
} }

@ -60,11 +60,12 @@ $RCMAIL->storage->folder_sync($mbox_name);
// initialize searching result if search_filter is used // initialize searching result if search_filter is used
if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') { if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') {
$search_request = md5($mbox_name.$_SESSION['search_filter']); $search_request = md5($mbox_name.$_SESSION['search_scope'].$_SESSION['search_filter']);
$RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCUBE_CHARSET, rcmail_sort_column()); $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCUBE_CHARSET, rcmail_sort_column());
$_SESSION['search'] = $RCMAIL->storage->get_search_set(); $_SESSION['search'] = $RCMAIL->storage->get_search_set();
$_SESSION['search_request'] = $search_request; $_SESSION['search_request'] = $search_request;
$OUTPUT->set_env('search_request', $search_request); $OUTPUT->set_env('search_request', $search_request);
$OUTPUT->set_env('search_filter', $_SESSION['search_filter']);
} }
// fetch message headers // fetch message headers

@ -41,7 +41,7 @@ $scope = rcube_utils::get_input_value('_scope', rcube_utils::INPUT_GET);
$subject = array(); $subject = array();
$filter = trim($filter); $filter = trim($filter);
$search_request = md5($mbox.$filter.$str); $search_request = md5($mbox.$scope.$filter.$str);
// add list filter string // add list filter string
$search_str = $filter && $filter != 'ALL' ? $filter : ''; $search_str = $filter && $filter != 'ALL' ? $filter : '';
@ -105,7 +105,13 @@ if (!empty($subject)) {
foreach ($subject as $sub) { foreach ($subject as $sub) {
$search_str .= ' ' . $sub . ' ' . rcube_imap_generic::escape($search); $search_str .= ' ' . $sub . ' ' . rcube_imap_generic::escape($search);
} }
}
$search_str = trim($search_str);
$sort_column = rcmail_sort_column();
// execute IMAP search
if ($search_str) {
// search all, current or subfolders folders // search all, current or subfolders folders
if ($scope == 'all') { if ($scope == 'all') {
$mboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail', null, true); $mboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail', null, true);
@ -116,14 +122,8 @@ if (!empty($subject)) {
if ($mbox != 'INBOX' && $mboxes[0] == 'INBOX') if ($mbox != 'INBOX' && $mboxes[0] == 'INBOX')
array_shift($mboxes); array_shift($mboxes);
} }
}
$search_str = trim($search_str);
$sort_column = rcmail_sort_column();
// execute IMAP search $result = $RCMAIL->storage->search($mboxes, $search_str, $imap_charset, $sort_column);
if ($search_str) {
$RCMAIL->storage->search($mboxes, $search_str, $imap_charset, $sort_column);
} }
// Get the headers // Get the headers
@ -162,10 +162,14 @@ else if ($err_code = $RCMAIL->storage->get_error_code()) {
} }
else { else {
$OUTPUT->show_message('searchnomatch', 'notice'); $OUTPUT->show_message('searchnomatch', 'notice');
$OUTPUT->set_env('multifolder_listing', (bool)$result->multi);
if ($result->multi && $scope == 'all')
$OUTPUT->command('select_folder', '');
} }
// update message count display // update message count display
$OUTPUT->set_env('search_request', $search_str ? $search_request : ''); $OUTPUT->set_env('search_request', $search_str ? $search_request : '');
$OUTPUT->set_env('search_filter', $_SESSION['search_filter']);
$OUTPUT->set_env('threading', $RCMAIL->storage->get_threading()); $OUTPUT->set_env('threading', $RCMAIL->storage->get_threading());
$OUTPUT->set_env('messagecount', $count); $OUTPUT->set_env('messagecount', $count);
$OUTPUT->set_env('pagecount', ceil($count/$RCMAIL->storage->get_pagesize())); $OUTPUT->set_env('pagecount', ceil($count/$RCMAIL->storage->get_pagesize()));

Loading…
Cancel
Save