Hide unavailable flags for the current mailbox
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 24 Feb 2010 21:29:06 +0000 (14:29 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 24 Feb 2010 21:36:13 +0000 (14:36 -0700)
imp/js/DimpBase.js
imp/lib/Views/ListMessages.php

index dd91fb1..d45414d 100644 (file)
@@ -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) {
index a47b595..03d3eac 100644 (file)
@@ -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