Add display of unsubscribed folders to DIMP.
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 11 Jun 2009 08:35:19 +0000 (02:35 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 11 Jun 2009 09:18:22 +0000 (03:18 -0600)
Thank you insomnia.

imp/ajax.php
imp/docs/CHANGES
imp/js/src/DimpBase.js
imp/lib/DIMP.php
imp/lib/Imap/Tree.php
imp/templates/index/index-dimp.inc
imp/themes/screen-dimp.css
imp/themes/silver/screen-dimp.css

index 7ddc147..55c60dd 100644 (file)
@@ -279,7 +279,11 @@ case 'FlagAll':
 
 case 'ListFolders':
     $imptree = IMP_Imap_Tree::singleton();
-    $result = DIMP::getFolderResponse($imptree, array('a' => $imptree->folderList(IMP_Imap_Tree::FLIST_CONTAINER | IMP_Imap_Tree::FLIST_VFOLDER), 'c' => array(), 'd' => array()));
+    $mask = IMP_Imap_Tree::FLIST_CONTAINER | IMP_Imap_Tree::FLIST_VFOLDER | IMP_Imap_Tree::FLIST_ELT;
+    if (Horde_Util::getPost('unsub')) {
+        $mask |= IMP_Imap_Tree::FLIST_UNSUB;
+    }
+    $result = DIMP::getFolderResponse($imptree, array('a' => $imptree->folderList($mask), 'c' => array(), 'd' => array()));
 
     $quota = _getQuota();
     if (!is_null($quota)) {
index 01cccf2..c275c16 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-git
 --------
 
+[mms] Add display of unsubscribed folders 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 cc8fba1..f229922 100644 (file)
@@ -10,7 +10,7 @@
 var DimpBase = {
     // Vars used and defaulting to null/false:
     //   cfolderaction, folder, folderswitch, offset, pollPE, pp, sfolder,
-    //   uid, viewport
+    //   showunsub, uid, viewport
     // message_list_template set via templates/javascript/mailbox.js
     bcache: $H(),
     cacheids: {},
@@ -712,6 +712,10 @@ var DimpBase = {
             this.togglePreviewPane();
             break;
 
+        case 'mboxsubtoggle':
+            this.toggleSubscribed();
+            break;
+
         case 'oa_blacklist':
         case 'oa_whitelist':
             this.blacklist(id == 'oa_blacklist');
@@ -1950,6 +1954,10 @@ var DimpBase = {
             ftype = ob.s ? 'special' : 'folder';
         }
 
+        if (ob.un) {
+            cname += ' unsubFolder';
+        }
+
         div = new Element('DIV', { className: 'iconDiv' });
         if (ob.i) {
             div.setStyle({ backgroundImage: 'url("' + ob.i + '")' });
@@ -2087,6 +2095,21 @@ var DimpBase = {
         nf.setStyle({ height: (document.viewport.getHeight() - nf.cumulativeOffset()[1]) + 'px' });
     },
 
+    toggleSubscribed: function()
+    {
+        this.showunsub = !this.showunsub;
+        $('mboxsubtoggle').setText(this.showunsub ? DIMP.text.hide_unsub : DIMP.text.show_unsub);
+        $('foldersLoading').show();
+        $('foldersSidebar').hide();
+
+        // TODO - Only do for unsub -> sub switch
+        [ $('specialfolders').childElements(), $('dropbase').nextSiblings() ].flatten().each(function(elt) {
+            this.deleteFolderElt(elt.readAttribute('id'), true);
+        }, this);
+
+        DimpCore.doAction('ListFolders', { unsub: Number(this.showunsub) }, null, this._folderLoadCallback.bind(this));
+    },
+
     /* Flag actions for message list. */
     _getFlagSelection: function(opts)
     {
index 43ef02c..649a770 100644 (file)
@@ -100,6 +100,7 @@ class DIMP
              "<head>\n";
 
         // TODO: Make dimp work with IE 8 standards mode
+        //       Needs prototypejs 1.6.0.4
         if ($GLOBALS['browser']->isBrowser('msie') &&
             ($GLOBALS['browser']->getMajor() == 8)) {
             echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />' . "\n";
@@ -223,6 +224,7 @@ class DIMP
             'empty_folder' => _("Permanently delete all messages in %s?"),
             'getmail' => Horde::highlightAccessKey(addslashes(_("_Get Mail")), Horde::getAccessKey(_("_Get Mail"), true)),
             'hide_preview' => _("Hide Preview"),
+            'hide_unsub' => _("Hide Unsubscribed"),
             'hidealog' => _("Hide Alerts Log"),
             'listmsg_wait' => _("The server is still generating the message list."),
             'listmsg_timeout' => _("The server was unable to generate the message list."),
@@ -241,6 +243,7 @@ class DIMP
             'rename_prompt' => _("Rename folder to:"),
             'search' => _("Search"),
             'show_preview' => _("Show Preview"),
+            'show_unsub' => _("Show Unsubscribed"),
             'showalog' => Horde::highlightAccessKey(addslashes(_("_Alerts Log")), Horde::getAccessKey(_("_Alerts Log"), true)),
             'verify' => _("Verifying..."),
             'vp_empty' => _("There are no messages in this mailbox."),
@@ -298,11 +301,10 @@ class DIMP
     {
         $GLOBALS['notification']->notify(array('listeners' => 'status'));
         $msgs = $GLOBALS['imp_notify']->getStack(true);
-        if (!count($msgs)) {
-            return '';
-        }
 
-        return 'DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')';
+        return count($msgs)
+            ? 'DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')'
+            : '';
     }
 
     /**
@@ -313,7 +315,7 @@ class DIMP
      * @param array $changes     An array with three sub arrays - to be used
      *                           instead of the return from
      *                           $imptree->eltDiff():
-     *                           'a' - a list of folders to add
+     *                           'a' - a list of folders/objects to add
      *                           'c' - a list of changed folders
      *                           'd' - a list of folders to delete
      *
@@ -333,7 +335,7 @@ class DIMP
         if (!empty($changes['a'])) {
             $result['a'] = array();
             foreach ($changes['a'] as $val) {
-                $result['a'][] = DIMP::_createFolderElt($imptree->element($val));
+                $result['a'][] = DIMP::_createFolderElt(is_array($val) ? $val : $imptree->element($val));
             }
         }
 
@@ -376,6 +378,8 @@ class DIMP
      * 's' (special) = Is this a "special" element? [boolean] [DEFAULT: no]
      * 't' (title) = The title value. [string] [DEFAULT: 'm' val]
      * 'u' (unseen) = The number of unseen messages. [integer]
+     * 'un' (unsubscribed) = Is this folder unsubscribed? [boolean]
+     *                       [DEFAULT: no]
      * 'v' (virtual) = Is this a virtual folder? [boolean] [DEFAULT: no]
      * </pre>
      */
@@ -399,6 +403,9 @@ class DIMP
         if ($elt['vfolder']) {
             $ob->v = 1;
         }
+        if (!$elt['sub']) {
+            $ob->un = 1;
+        }
 
         $tmp = IMP::getLabel($ob->m);
         if ($tmp != $ob->m) {
index 85322a7..7422d20 100644 (file)
@@ -54,8 +54,9 @@ class IMP_Imap_Tree
     /* Defines used with folderList(). */
     const FLIST_CONTAINER = 1;
     const FLIST_UNSUB = 2;
-    const FLIST_OB = 4;
-    const FLIST_VFOLDER = 8;
+    const FLIST_VFOLDER = 4;
+    const FLIST_OB = 8;
+    const FLIST_ELT = 16;
 
     /* Add a percent to folder key since it allows us to sort by name but
      * never conflict with an IMAP mailbox of the same name (since '%' is an
@@ -1698,12 +1699,14 @@ class IMP_Imap_Tree
      * <pre>
      * IMP_Imap_Tree::FLIST_CONTAINER - Show container elements.
      * IMP_Imap_Tree::FLIST_UNSUB - Show unsubscribed elements.
-     * IMP_Imap_Tree::FLIST_OB - Return full tree object.
      * IMP_Imap_Tree::FLIST_VFOLDER - Show Virtual Folders.
+     * IMP_Imap_Tree::FLIST_OB - Return full tree object.
+     * IMP_Imap_Tree::FLIST_ELT - Return element object.
      * </pre>
      * @param string $base  Return all mailboxes below this element.
      *
-     * @return array  An array of IMAP mailbox names.
+     * @return array  Either an array of IMAP mailbox names or an array of
+     *                objects (if FLIST_OB ot FLIST_ELT is specified).
      */
     public function folderList($mask = 0, $base = null)
     {
@@ -1741,7 +1744,9 @@ class IMP_Imap_Tree
                      !$this->isContainer($mailbox)) &&
                     (($mask & self::FLIST_VFOLDER) ||
                      !$this->isVFolder($mailbox))) {
-                    $ret_array[] = ($mask & self::FLIST_OB) ? $mailbox : $mailbox['v'];
+                    $ret_array[] = ($mask & self::FLIST_OB)
+                        ? $mailbox
+                        : (($mask & self::FLIST_ELT) ? $this->element($mailbox['v']) : $mailbox['v']);
                 }
             } while (($mailbox = $this->next(self::NEXT_SHOWCLOSED)));
         }
@@ -1802,7 +1807,7 @@ class IMP_Imap_Tree
     /**
      * Return extended information on an element.
      *
-     * @param string $name  The name of the tree element.
+     * @param mixed $name  The name of the tree element or a tree element.
      *
      * @return array  Returns the element with extended information, or false
      *                if not found.  The information returned is as follows:
@@ -1823,6 +1828,7 @@ class IMP_Imap_Tree
      * 'polled' - (boolean) Show polled information?
      * 'recent' - (integer) The number of new messages in the element (if
      *            polled).
+     * 'sub' - (boolean) Is folder subscribed to?
      * 'special' - (integer) A mask indicating if this is a "special" element.
      * 'specialvfolder' - (boolean) Is this a "special" virtual folder?
      * 'unseen' - (integer) The number of unseen messages in the element (if
@@ -1836,7 +1842,9 @@ class IMP_Imap_Tree
     {
         static $elt;
 
-        $mailbox = $this->get($mailbox);
+        if (!is_array($mailbox)) {
+            $mailbox = $this->get($mailbox);
+        }
         if (!$mailbox) {
             return false;
         }
@@ -1860,6 +1868,7 @@ class IMP_Imap_Tree
             'recent' => 0,
             'special' => 0,
             'specialvfolder' => false,
+            'sub' => $this->isSubscribed($mailbox),
             'user_icon' => false,
             'value' => $mailbox['v'],
             'vfolder' => false,
index 74d259e..350e4db 100644 (file)
@@ -389,6 +389,9 @@ function _simpleButton($id, $text, $image, $imagedir = null)
 
 <div class="context" id="ctx_otheractions" style="display:none">
  <a id="previewtoggle" class="sep"><span class="contextImg"></span><?php echo ($prefs->getValue('dimp_show_preview') ? _("Hide Preview") : _("Show Preview")); ?></a>
+<?php if ($conf['user']['allow_folders']): ?>
+ <a id="mboxsubtoggle" class="sep"><span class="contextImg"></span><?php echo _("Show Unsubscribed") ?></a>
+<?php endif; ?>
 <?php if (!empty($flag_list)): ?>
  <a id="oa_setflag"><span class="contextImg"></span><?php echo _("Mark as") ?></a>
  <a id="oa_unsetflag" class="sep"><span class="contextImg"></span><?php echo _("Unmark as") ?></a>
index eba2247..85e733b 100644 (file)
@@ -333,7 +333,7 @@ div.vpRow.flagDeleted {
     height: 100%;
     background-repeat: no-repeat;
 }
-#sidebarPanel div.base {
+#sidebarPanel div.base, #mboxsubtoggle span.contextImg {
     background-image: url("graphics/folder.png");
 }
 #sidebarPanel div.col {
@@ -360,10 +360,13 @@ div.vpRow.flagDeleted {
 #sidebarPanel div.trash {
     background-image: url("graphics/folder_trash.png");
 }
-#sidebarPanel #normalfolders {
+#normalfolders {
     overflow-x: hidden;
 }
-#sidebarPanel #myfolders {
+#normalfolders li.unsubFolder {
+    font-style: italic;
+}
+#myfolders {
     display: none;
 }
 #sidebarPanel .over a, #sidebarPanel li.folder:hover, #sidebarPanel li.custom:hover, #sidebarPanel li.servicelink:hover {
index b9bf39a..c8f8e51 100644 (file)
@@ -1,4 +1,4 @@
-#sidebarPanel div.base {
+#sidebarPanel div.base, #mboxsubtoggle span.contextImg {
     background-image: url("graphics/folder.png");
 }
 #sidebarPanel div.col {