From 18a6430b96d99100b2f06a10d06739d17a8ad8f3 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 24 Feb 2010 14:29:06 -0700 Subject: [PATCH] Hide unavailable flags for the current mailbox --- imp/js/DimpBase.js | 9 ++++++++- imp/lib/Views/ListMessages.php | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index dd91fb192..d45414db0 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -529,7 +529,7 @@ var DimpBase = { }.bindAsEventListener(this)); container.observe('ViewPort:contentComplete', function(e) { - var ssc, tmp, + var flags, ssc, tmp, ham = spam = 'show', l = this.viewport.getMetaData('label'); @@ -608,6 +608,13 @@ var DimpBase = { } this.setSortColumns(ssc); + + /* Context menu: generate the list of settable flags for this + * mailbox. */ + flags = this.viewport.getMetaData('flags'); + $('ctx_flag').childElements().each(function(c) { + [ c ].invoke(flags.include(c.readAttribute('flag')) ? 'show' : 'hide'); + }); }.bindAsEventListener(this)); container.observe('ViewPort:deselect', function(e) { diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index a47b595f2..03d3eac4f 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -114,11 +114,18 @@ class IMP_Views_ListMessages if ($args['initial'] || !is_null($args['sortdir'])) { $md->sortdir = intval($sortpref['dir']); } - if ($args['initial'] && IMP::isSpecialFolder($mbox)) { - $md->special = 1; - } - if ($args['initial'] && $is_search) { - $md->search = 1; + + /* Actions only done on 'initial' request. */ + if ($args['initial']) { + if (IMP::isSpecialFolder($mbox)) { + $md->special = 1; + } + if ($is_search) { + $md->search = 1; + } + + /* Generate flag array. */ + $md->flags = array_keys($GLOBALS['injector']->getInstance('IMP_Imap_Flags')->getList(array('imap' => true, 'mailbox' => $is_search ? null : $mbox))); } /* These entries may change during a session, so always need to -- 2.11.0