summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/js/app.js2
-rw-r--r--program/steps/mail/func.inc24
-rw-r--r--program/steps/mail/list.inc22
-rw-r--r--program/steps/mail/search.inc39
4 files changed, 36 insertions, 51 deletions
diff --git a/program/js/app.js b/program/js/app.js
index e276f6f96..675372107 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -6422,7 +6422,7 @@ function rcube_webmail()
this.env.status_col = n;
if (list) {
- list.hide_column('folder', !(this.env.search_request || this.env.search_id));
+ list.hide_column('folder', !(this.env.search_request || this.env.search_id) || this.env.search_scope == 'base');
list.init_header();
}
};
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index fd321e294..3487ec73f 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -363,7 +363,7 @@ function rcmail_message_list($attrib)
/**
* return javascript commands to add rows to the message list
*/
-function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null)
+function rcmail_js_message_list($a_headers, $insert_top=false, $a_show_cols=null)
{
global $RCMAIL, $OUTPUT;
@@ -382,6 +382,14 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
$head_replace = true;
}
+ // add 'folder' column to list on multi-folder searches
+ $search_set = $RCMAIL->storage->get_search_set();
+ $multifolder = $search_set && $search_set[1]->multi;
+ if ($multifolder && !in_array('folder', $a_show_cols)) {
+ $a_show_cols[] = 'folder';
+ $head_replace = true;
+ }
+
$mbox = $RCMAIL->storage->get_folder();
// make sure 'threads' and 'subject' columns are present
@@ -390,8 +398,6 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
if (!in_array('threads', $a_show_cols))
array_unshift($a_show_cols, 'threads');
- $_SESSION['list_attrib']['columns'] = $a_show_cols;
-
// Make sure there are no duplicated columns (#1486999)
$a_show_cols = array_unique($a_show_cols);
@@ -412,6 +418,10 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
$OUTPUT->command('set_message_coltypes', $a_show_cols, $thead, $smart_col);
+ if ($multifolder) {
+ $OUTPUT->command('select_folder', '');
+ }
+
if (empty($a_headers)) {
return;
}
@@ -428,6 +438,14 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
if (empty($header))
continue;
+ // make message UIDs unique by appending the folder name
+ if ($multifolder) {
+ $header->uid .= '-'.$header->folder;
+ $header->flags['skip_mbox_check'] = true;
+ if ($header->parent_uid)
+ $header->parent_uid .= '-'.$header->folder;
+ }
+
$a_msg_cols = array();
$a_msg_flags = array();
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index a77d60f32..18f771d8b 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -42,6 +42,7 @@ if ($sort = rcube_utils::get_input_value('_sort', rcube_utils::INPUT_GET)) {
// is there a set of columns for this request?
if ($cols = rcube_utils::get_input_value('_cols', rcube_utils::INPUT_GET)) {
+ $_SESSION['list_attrib']['columns'] = $cols;
if (!in_array('list_cols', $dont_override)) {
$save_arr['list_cols'] = explode(',', $cols);
}
@@ -75,24 +76,6 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'])
&& $_SESSION['search_request'] == $_REQUEST['_search']
) {
$_SESSION['search'] = $RCMAIL->storage->get_search_set();
-
- // multi-folder search
- if ($_SESSION['search'][1]->multi) {
- if (empty($cols))
- $cols = $_SESSION['list_attrib']['columns'] ? $_SESSION['list_attrib']['columns'] : (array)$CONFIG['list_cols'];
- if (!in_array('folder', $cols))
- $cols[] = 'folder'; // Add 'folder' column to list
-
- // make message UIDs unique by appending the folder name
- foreach ($a_headers as $i => $header) {
- $header->uid .= '-'.$header->folder;
- $header->flags['skip_mbox_check'] = true;
- if ($header->parent_uid)
- $header->parent_uid .= '-'.$header->folder;
- }
-
- $OUTPUT->command('select_folder', '');
- }
}
// remove old search data
else if (empty($_REQUEST['_search']) && isset($_SESSION['search'])) {
@@ -119,7 +102,8 @@ $OUTPUT->set_env('exists', $exists);
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count), $mbox_name);
// add message rows
-rcmail_js_message_list($a_headers, FALSE, $cols);
+rcmail_js_message_list($a_headers, false, $cols);
+
if (isset($a_headers) && count($a_headers)) {
if ($search_request) {
$OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index e13bc2ce5..e17552f7d 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -104,21 +104,21 @@ if (!empty($subject)) {
foreach ($subject as $sub) {
$search_str .= ' ' . $sub . ' ' . rcube_imap_generic::escape($search);
}
+
+ // search all, current or subfolders folders
+ if ($scope == 'all') {
+ $mboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail');
+ }
+ else if ($scope == 'sub') {
+ $mboxes = $RCMAIL->storage->list_folders_subscribed($mbox, '*', 'mail');
+ if ($mbox != 'INBOX' && $mboxes[0] == 'INBOX')
+ array_shift($mboxes);
+ }
}
$search_str = trim($search_str);
$sort_column = rcmail_sort_column();
-// search all, current or subfolders folders
-if ($scope == 'all') {
- $mboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail');
-}
-else if ($scope == 'sub') {
- $mboxes = $RCMAIL->storage->list_folders_subscribed($mbox, '*', 'mail');
- if ($mbox != 'INBOX' && $mboxes[0] == 'INBOX')
- array_shift($mboxes);
-}
-
// execute IMAP search
if ($search_str) {
$RCMAIL->storage->search($mboxes, $search_str, $imap_charset, $sort_column);
@@ -140,26 +140,9 @@ if ($search_str) {
$_SESSION['search_request'] = $search_request;
$_SESSION['search_scope'] = $scope;
-// Add 'folder' column to list
-if ($_SESSION['search'][1]->multi) {
- $a_show_cols = $_SESSION['list_attrib']['columns'] ? $_SESSION['list_attrib']['columns'] : (array)$CONFIG['list_cols'];
- if (!in_array('folder', $a_show_cols))
- $a_show_cols[] = 'folder';
-
- // make message UIDs unique by appending the folder name
- foreach ($result_h as $i => $header) {
- $header->uid .= '-'.$header->folder;
- $header->flags['skip_mbox_check'] = true;
- if ($header->parent_uid)
- $header->parent_uid .= '-'.$header->folder;
- }
-
- $OUTPUT->command('select_folder', '');
-}
-
// Make sure we got the headers
if (!empty($result_h)) {
- rcmail_js_message_list($result_h, false, $a_show_cols);
+ rcmail_js_message_list($result_h, false);
if ($search_str) {
$OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL->storage->count(NULL, 'ALL')));
}