summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/js/app.js11
-rw-r--r--program/js/common.js14
-rw-r--r--program/steps/mail/func.inc9
-rw-r--r--program/steps/mail/search.inc12
4 files changed, 37 insertions, 9 deletions
diff --git a/program/js/app.js b/program/js/app.js
index f03b0c5fb..ab70b024b 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -2616,10 +2616,13 @@ function rcube_webmail()
if (this.message_list) {
this.message_list.clear();
if (this.env.search_mods) {
- var head_arr = new Array();
- for (var n in this.env.search_mods)
- head_arr.push(n);
- addurl += '&_headers='+head_arr.join(',');
+ var mods = this.env.search_mods[this.env.mailbox] ? this.env.search_mods[this.env.mailbox] : this.env.search_mods['*'];
+ if (mods) {
+ var head_arr = new Array();
+ for (var n in mods)
+ head_arr.push(n);
+ addurl += '&_headers='+head_arr.join(',');
+ }
}
} else if (this.contact_list) {
this.contact_list.clear(true);
diff --git a/program/js/common.js b/program/js/common.js
index c66ea7655..70ef4446b 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -490,6 +490,20 @@ function find_in_array()
return -1;
}
+// recursively copy an object
+function rcube_clone_object(obj)
+{
+ var out = {};
+
+ for (var key in obj) {
+ if (obj[key] && typeof obj[key] == 'object')
+ out[key] = clone_object(obj[key]);
+ else
+ out[key] = obj[key];
+ }
+
+ return out;
+}
// make a string URL safe
function urlencode(str)
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 491f79a5e..3dab087b0 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -19,6 +19,11 @@
*/
+// setup some global vars used by mail steps
+$SENT_MBOX = $RCMAIL->config->get('sent_mbox');
+$DRAFTS_MBOX = $RCMAIL->config->get('drafts_mbox');
+$SEARCH_MODS_DEFAULT = array('*' => array('subject'=>1, 'from'=>1), $SENT_MBOX => array('subject'=>1, 'to'=>1), $DRAFTS_MBOX => array('subject'=>1, 'to'=>1));
+
$EMAIL_ADDRESS_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9][a-z0-9\-\.]*\\.[a-z]{2,5})';
// actions that do not require imap connection
@@ -79,7 +84,9 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list')
$OUTPUT->set_env('search_request', $search_request);
}
- $OUTPUT->set_env('search_mods', $_SESSION['search_mods'] ? $_SESSION['search_mods'] : array('subject'=>'subject'));
+ $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT);
+ $OUTPUT->set_env('search_mods', $search_mods);
+
// make sure the message count is refreshed (for default view)
$IMAP->messagecount($mbox_name, 'ALL', true);
}
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index 6a1c8c471..cfdb6fb96 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -72,12 +72,17 @@ else if (preg_match("/^body:.*/i", $str))
else if(trim($str))
{
if ($headers) {
- $headers = explode(',', $headers);
- foreach($headers as $header)
+ foreach(explode(',', $headers) as $header)
switch ($header) {
case 'text': $subject['text'] = 'TEXT'; break;
- default: $subject[$header] = 'HEADER '.$header;
+ default: $subject[$header] = 'HEADER '.strtoupper($header);
}
+
+ // save search modifiers for the current folder to user prefs
+ $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT);
+ $search_mods[$mbox] = array_fill_keys(array_keys($subject), 1);
+ $RCMAIL->user->save_prefs(array('search_mods' => $search_mods));
+ console($search_mods);
} else {
// search in subject by default
$subject['subject'] = 'HEADER SUBJECT';
@@ -90,7 +95,6 @@ if ($subject) {
$search_str .= str_repeat(' OR', count($subject)-1);
foreach ($subject as $sub)
$search_str .= sprintf(" %s {%d}\r\n%s", $sub, strlen($search), $search);
- $_SESSION['search_mods'] = $subject;
}
$search_str = trim($search_str);