summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-05-02 14:19:24 +0000
committeralecpl <alec@alec.pl>2009-05-02 14:19:24 +0000
commit30b152b1947e773a618bc29bfa3b5b505ceeb1d7 (patch)
treed957132b27c4e0db1ea179fdc30f42cb31b6f2ad /program
parent4e65a3c145006348af29d913463fd683b72fe5c0 (diff)
- Added quick search box menu (#1484304)
Diffstat (limited to 'program')
-rw-r--r--program/js/app.js15
-rw-r--r--program/localization/en_GB/labels.inc2
-rw-r--r--program/localization/en_US/labels.inc2
-rw-r--r--program/localization/pl_PL/labels.inc2
-rw-r--r--program/steps/mail/func.inc1
-rw-r--r--program/steps/mail/search.inc45
6 files changed, 45 insertions, 22 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 8ac0e7256..e8444031d 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -2392,19 +2392,26 @@ function rcube_webmail()
};
// send remote request to search mail or contacts
- this.qsearch = function(value, addurl)
+ this.qsearch = function(value)
{
if (value != '')
{
- if (this.message_list)
+ var addurl = '';
+ if (this.message_list) {
this.message_list.clear();
- else if (this.contact_list) {
+ 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(',');
+ }
+ } else if (this.contact_list) {
this.contact_list.clear(true);
this.show_contentframe(false);
}
if (this.gui_objects.search_filter)
- addurl = '&_filter=' + this.gui_objects.search_filter.value;
+ addurl += '&_filter=' + this.gui_objects.search_filter.value;
// reset vars
this.env.current_page = 1;
diff --git a/program/localization/en_GB/labels.inc b/program/localization/en_GB/labels.inc
index fae87c558..da2709c70 100644
--- a/program/localization/en_GB/labels.inc
+++ b/program/localization/en_GB/labels.inc
@@ -131,6 +131,8 @@ $labels['unknown'] = 'unknown';
$labels['unlimited'] = 'unlimited';
$labels['quicksearch'] = 'Quick search';
$labels['resetsearch'] = 'Reset search';
+$labels['searchmod'] = 'Search modifiers';
+$labels['msgtext'] = 'Entire message';
$labels['openinextwin'] = 'Open in new window';
$labels['compose'] = 'Compose a message';
$labels['savemessage'] = 'Save this draft';
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 7f0538703..87cb08b49 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -161,6 +161,8 @@ $labels['unlimited'] = 'unlimited';
$labels['quicksearch'] = 'Quick search';
$labels['resetsearch'] = 'Reset search';
+$labels['searchmod'] = 'Search modifiers';
+$labels['msgtext'] = 'Entire message';
$labels['openinextwin'] = 'Open in new window';
diff --git a/program/localization/pl_PL/labels.inc b/program/localization/pl_PL/labels.inc
index dba23a8e0..7b8a39d64 100644
--- a/program/localization/pl_PL/labels.inc
+++ b/program/localization/pl_PL/labels.inc
@@ -142,6 +142,8 @@ $labels['unknown'] = 'nieznane';
$labels['unlimited'] = 'bez limitu';
$labels['quicksearch'] = 'Szybkie wyszukiwanie';
$labels['resetsearch'] = 'Wyczyść filtr';
+$labels['searchmod'] = 'Parametry wyszukiwania';
+$labels['msgtext'] = 'Cała wiadomość';
$labels['openinextwin'] = 'Otwórz w nowym oknie';
$labels['compose'] = 'Utwórz wiadomość';
$labels['savemessage'] = 'Zapisz kopię roboczą';
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index f0d7d6f01..537199cc8 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -79,6 +79,7 @@ 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'));
// 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 95ca67a12..8d24460bc 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -28,6 +28,7 @@ $imap_charset = 'UTF-8';
$str = get_input_value('_q', RCUBE_INPUT_GET);
$filter = get_input_value('_filter', RCUBE_INPUT_GET);
$mbox = get_input_value('_mbox', RCUBE_INPUT_GET);
+$headers = get_input_value('_headers', RCUBE_INPUT_GET);
$search_request = md5($mbox.$filter.$str);
// add list filter string
@@ -39,47 +40,55 @@ $_SESSION['search_filter'] = $filter;
if (preg_match("/^from:.*/i", $str))
{
list(,$srch) = explode(":", $str);
- $subject = "HEADER FROM";
- $search = trim($srch);
+ $subject['from'] = "HEADER FROM";
}
else if (preg_match("/^to:.*/i", $str))
{
list(,$srch) = explode(":", $str);
- $subject = "HEADER TO";
- $search = trim($srch);
+ $subject['to'] = "HEADER TO";
}
else if (preg_match("/^cc:.*/i", $str))
{
list(,$srch) = explode(":", $str);
- $subject = "HEADER CC";
- $search = trim($srch);
+ $subject['cc'] = "HEADER CC";
+}
+else if (preg_match("/^bcc:.*/i", $str))
+{
+ list(,$srch) = explode(":", $str);
+ $subject['bcc'] = "HEADER BCC";
}
else if (preg_match("/^subject:.*/i", $str))
{
list(,$srch) = explode(":", $str);
- $subject = "HEADER SUBJECT";
- $search = trim($srch);
+ $subject['subject'] = "HEADER SUBJECT";
}
else if (preg_match("/^body:.*/i", $str))
{
list(,$srch) = explode(":", $str);
- $subject = "TEXT";
- $search = trim($srch);
+ $subject['text'] = "TEXT";
}
// 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 ($headers) {
+ $headers = explode(',', $headers);
+ foreach($headers as $header)
+ switch ($header) {
+ case 'text': $subject['text'] = 'TEXT'; break;
+ default: $subject[$header] = 'HEADER '.$header;
+ }
+ } else {
+ $subject['subject'] = 'HEADER SUBJECT';
+ }
}
-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 = $srch ? trim($srch) : trim($str);
+
+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);