From 8d25dbd81f5d3d819136661b64f610f487a7f30d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 11 Jun 2009 02:35:19 -0600 Subject: [PATCH] Add display of unsubscribed folders to DIMP. Thank you insomnia. --- imp/ajax.php | 6 +++++- imp/docs/CHANGES | 1 + imp/js/src/DimpBase.js | 25 ++++++++++++++++++++++++- imp/lib/DIMP.php | 19 +++++++++++++------ imp/lib/Imap/Tree.php | 23 ++++++++++++++++------- imp/templates/index/index-dimp.inc | 3 +++ imp/themes/screen-dimp.css | 9 ++++++--- imp/themes/silver/screen-dimp.css | 2 +- 8 files changed, 69 insertions(+), 19 deletions(-) diff --git a/imp/ajax.php b/imp/ajax.php index 7ddc147eb..55c60dd54 100644 --- a/imp/ajax.php +++ b/imp/ajax.php @@ -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)) { diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 01cccf2cd..c275c1635 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -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 diff --git a/imp/js/src/DimpBase.js b/imp/js/src/DimpBase.js index cc8fba1c4..f229922bf 100644 --- a/imp/js/src/DimpBase.js +++ b/imp/js/src/DimpBase.js @@ -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) { diff --git a/imp/lib/DIMP.php b/imp/lib/DIMP.php index 43ef02cb9..649a770c5 100644 --- a/imp/lib/DIMP.php +++ b/imp/lib/DIMP.php @@ -100,6 +100,7 @@ class DIMP "\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 '' . "\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] * */ @@ -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) { diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index 85322a7cb..7422d200d 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -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 *
      * 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.
      * 
* @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, diff --git a/imp/templates/index/index-dimp.inc b/imp/templates/index/index-dimp.inc index 74d259ede..350e4db01 100644 --- a/imp/templates/index/index-dimp.inc +++ b/imp/templates/index/index-dimp.inc @@ -389,6 +389,9 @@ function _simpleButton($id, $text, $image, $imagedir = null)