Add ability in DIMP to sub/unsub from folders
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 12 Jun 2009 05:38:27 +0000 (23:38 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 12 Jun 2009 16:23:58 +0000 (10:23 -0600)
imp/ajax.php
imp/docs/CHANGES
imp/js/src/DimpBase.js
imp/templates/index/index-dimp.inc
imp/themes/screen-dimp.css

index 55c60dd..033a244 100644 (file)
@@ -313,6 +313,13 @@ case 'Poll':
     }
     break;
 
+case 'Subscribe':
+    $imp_folder = IMP_Folder::singleton();
+    $result = Horde_Util::getPost('sub')
+        ? $imp_folder->subscribe(array($mbox))
+        : $imp_folder->unsubscribe(array($mbox));
+    break;
+
 case 'ViewPort':
     if (empty($mbox)) {
         break;
index ac0d4d4..552cfe8 100644 (file)
@@ -2,7 +2,7 @@
 v5.0-git
 --------
 
-[mms] Add display of unsubscribed folders to DIMP.
+[mms] Add full IMAP subscription support to DIMP.
 [mms] Add message information to preview screen (DIMP).
 [mms] Add Alt + PGUP/PGDN shortcut to scroll through preview message (DIMP).
 [jan] Show possible event conflicts in iTip viewer (Request #3991, Gonçalo
index df68d4c..9fa264e 100644 (file)
@@ -675,6 +675,11 @@ var DimpBase = {
             this.modifyPoll(baseelt.up('LI').readAttribute('mbox'), id == 'ctx_folder_poll');
             break;
 
+        case 'ctx_folder_sub':
+        case 'ctx_folder_unsub':
+            this.subscribeFolder(baseelt.up('LI').readAttribute('mbox'), id == 'ctx_folder_sub');
+            break;
+
         case 'ctx_container_create':
             this.createSubFolder(baseelt);
             break;
@@ -756,17 +761,24 @@ var DimpBase = {
 
             if (baseelt.readAttribute('mbox') == 'INBOX') {
                 elts.invoke('hide');
-            } else if (DIMP.conf.fixed_folders &&
-                       DIMP.conf.fixed_folders.indexOf(baseelt.readAttribute('mbox')) != -1) {
-                elts.shift();
-                elts.invoke('hide');
+                $('ctx_folder_sub', 'ctx_folder_unsub').invoke('hide');
             } else {
-                elts.invoke('show');
+                tmp = baseelt.hasClassName('unsubFolder');
+                [ $('ctx_folder_sub') ].invoke(tmp ? 'show' : 'hide');
+                [ $('ctx_folder_unsub') ].invoke(tmp ? 'hide' : 'show');
+
+                if (DIMP.conf.fixed_folders &&
+                    DIMP.conf.fixed_folders.indexOf(baseelt.readAttribute('mbox')) != -1) {
+                    elts.shift();
+                    elts.invoke('hide');
+                } else {
+                    elts.invoke('show');
+                }
             }
 
             tmp = baseelt.hasAttribute('u');
             [ $('ctx_folder_poll') ].invoke(tmp ? 'hide' : 'show');
-            [ $('ctx_folder_nopoll') ].invoke(tmp? 'show' : 'hide');
+            [ $('ctx_folder_nopoll') ].invoke(tmp ? 'show' : 'hide');
             break;
 
         case 'ctx_reply':
@@ -886,7 +898,7 @@ var DimpBase = {
         var p = DIMP.conf.preview_pref = !DIMP.conf.preview_pref;
         $('previewtoggle').setText(p ? DIMP.text.hide_preview : DIMP.text.show_preview);
         [ $('msgList') ].invoke(p ? 'removeClassName' : 'addClassName', 'msglistNoPreview');
-        this._updatePrefs('show_preview', p ? 1 : 0);
+        this._updatePrefs('show_preview', Number(p));
         this.viewport.showSplitPane(p);
         if (p) {
             this.initPreviewPane();
@@ -1071,7 +1083,7 @@ var DimpBase = {
     {
         if (update) {
             DIMP.conf.toggle_pref = !DIMP.conf.toggle_pref;
-            this._updatePrefs('dimp_toggle_headers', elt.id == 'th_expand' ? 1 : 0);
+            this._updatePrefs('dimp_toggle_headers', Number(elt.id == 'th_expand'));
         }
         [ elt.up().select('A'), $('msgHeadersColl', 'msgHeaders') ].flatten().invoke('toggle');
     },
@@ -2114,6 +2126,18 @@ var DimpBase = {
         DimpCore.doAction('ListFolders', { unsub: Number(this.showunsub) }, null, this._folderLoadCallback.bind(this));
     },
 
+    subscribeFolder: function(f, sub)
+    {
+        var fid = this.getFolderId(f);
+        DimpCore.doAction('Subscribe', { view: f, sub: Number(sub) });
+
+        if (this.showunsub) {
+            [ $(fid) ].invoke(sub ? 'removeClassName' : 'addClassName', 'unsubFolder');
+        } else if (!sub) {
+            this.deleteFolderElt(fid);
+        }
+    },
+
     /* Flag actions for message list. */
     _getFlagSelection: function(opts)
     {
@@ -2291,7 +2315,7 @@ var DimpBase = {
 
     modifyPoll: function(folder, add)
     {
-        DimpCore.doAction('ModifyPoll', { view: folder, add: (add) ? 1 : 0 }, null, this.bcache.get('modifyPFC') || this.bcache.set('modifyPFC', this._modifyPollCallback.bind(this)));
+        DimpCore.doAction('ModifyPoll', { view: folder, add: Number(add) }, null, this.bcache.get('modifyPFC') || this.bcache.set('modifyPFC', this._modifyPollCallback.bind(this)));
     },
 
     _modifyPollCallback: function(r)
index 350e4db..a379754 100644 (file)
@@ -337,6 +337,8 @@ function _simpleButton($id, $text, $image, $imagedir = null)
  <a id="ctx_folder_unseen" class="sep"><span class="contextImg"></span><?php echo _("Mark all as New") ?></a>
  <a id="ctx_folder_poll"><span class="contextImg"></span><?php echo _("Check for New Mail") ?></a>
  <a id="ctx_folder_nopoll"><span class="contextImg"></span><?php echo _("Do Not Check for New Mail") ?></a>
+ <a id="ctx_folder_sub"><span class="contextImg"></span><?php echo _("Subscribe") ?></a>
+ <a id="ctx_folder_unsub"><span class="contextImg"></span><?php echo _("Unsubscribe") ?></a>
 </div>
 
 <div class="context" id="ctx_container" style="display:none">
index 85e733b..225893f 100644 (file)
@@ -333,7 +333,7 @@ div.vpRow.flagDeleted {
     height: 100%;
     background-repeat: no-repeat;
 }
-#sidebarPanel div.base, #mboxsubtoggle span.contextImg {
+#sidebarPanel div.base, #mboxsubtoggle span.contextImg, #ctx_folder_sub span.contextImg, #ctx_folder_unsub span.contextImg {
     background-image: url("graphics/folder.png");
 }
 #sidebarPanel div.col {