From e538b3dc7d740c5a9213ef352437f249be856d3a Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 13 Nov 2008 05:30:06 -0500
Subject: [PATCH] - Added message status filter + fixes for r2046 (searching with SORT)

---
 program/js/app.js |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index d22b1fb..e7204d0 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -266,7 +266,7 @@
 
         this.set_page_buttons();
         
-        if (this.env.address_sources && !this.env.address_sources[this.env.source].readonly)
+        if (this.env.address_sources && this.env.address_sources[this.env.source] && !this.env.address_sources[this.env.source].readonly)
           this.enable_command('add', true);
         
         if (this.env.cid)
@@ -1414,6 +1414,24 @@
       }
     };
 
+  // list messages of a specific mailbox using filter
+  this.filter_mailbox = function(filter)
+    {
+      var search;
+      if (this.gui_objects.qsearchbox)
+        search = this.gui_objects.qsearchbox.value;
+      
+      this.message_list.clear();
+
+      // reset vars
+      this.env.current_page = 1;
+      this.set_busy(true, 'searching');
+      this.http_request('search', '_filter='+filter
+    	    + (search ? '&_q='+urlencode(search) : '')
+    	    + (this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : ''), true);
+    }
+
+
   // list messages of a specific mailbox
   this.list_mailbox = function(mbox, page, sort)
     {
@@ -2283,7 +2301,7 @@
     };
 
   // send remote request to search mail or contacts
-  this.qsearch = function(value)
+  this.qsearch = function(value, addurl)
     {
     if (value != '')
       {
@@ -2292,12 +2310,18 @@
       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;
 
       // reset vars
       this.env.current_page = 1;
       this.set_busy(true, 'searching');
-      this.http_request('search', '_q='+urlencode(value)+(this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '')+(this.env.source ? '&_source='+urlencode(this.env.source) : ''), true);
+      this.http_request('search', '_q='+urlencode(value)
+    	    +(this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '')
+	    +(this.env.source ? '&_source='+urlencode(this.env.source) : '')
+	    +(addurl ? addurl : ''), true);
       }
     return true;
     };

--
Gitblit v1.9.1