From cb7d32ebdd1c783f201e2f3fa6c52f1fafdc6fcf Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 22 Oct 2010 11:24:39 -0400
Subject: [PATCH] List groups in address detail view and allow to subscribe/unsubscribe from there (#1486753)

---
 program/js/app.js |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index 45569ea..4587ce8 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -306,8 +306,18 @@
           this.enable_command('group-create', this.env.address_sources[this.env.source].groups);
         }
 
-        if (this.env.cid)
+        if (this.env.cid) {
           this.enable_command('show', 'edit', true);
+          // register handlers for group assignment via checkboxes
+          if (this.gui_objects.editform) {
+            $('input.groupmember').change(function(){
+              var cmd = this.checked ? 'group-addmembers' : 'group-delmembers';
+              ref.http_post(cmd, '_cid='+urlencode(ref.env.cid)
+                + '&_source='+urlencode(ref.env.source)
+                + '&_gid='+urlencode(this.value));
+            });
+          }
+        }
 
         if ((this.env.action=='add' || this.env.action=='edit') && this.gui_objects.editform) {
           this.enable_command('save', true);
@@ -3713,7 +3723,7 @@
   {
     // exit if no mailbox specified or if selection is empty
     var selection = this.contact_list.get_selection();
-    if (!(selection.length || this.env.cid) || (!this.env.group && !confirm(this.get_label('deletecontactconfirm'))))
+    if (!(selection.length || this.env.cid) || !confirm(this.get_label('deletecontactconfirm')))
       return;
 
     var id, a_cids = [], qs = '';
@@ -3737,10 +3747,7 @@
       qs += '&_search='+this.env.search_request;
 
     // send request to server
-    if (this.env.group)
-      this.http_post('group-delmembers', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+qs);
-    else
-      this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs);
+    this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs);
 
     return true;
   };

--
Gitblit v1.9.1