Honor subscribe preference in DIMP
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 12 Jun 2009 16:45:30 +0000 (10:45 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 12 Jun 2009 16:45:30 +0000 (10:45 -0600)
imp/ajax.php
imp/js/src/DimpBase.js
imp/templates/index/index-dimp.inc

index 033a244..a68eb62 100644 (file)
@@ -314,10 +314,12 @@ 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));
+    if ($prefs->getValue('subscribe')) {
+        $imp_folder = IMP_Folder::singleton();
+        $result = Horde_Util::getPost('sub')
+            ? $imp_folder->subscribe(array($mbox))
+            : $imp_folder->unsubscribe(array($mbox));
+    }
     break;
 
 case 'ViewPort':
index f7d3882..8608e75 100644 (file)
@@ -761,11 +761,15 @@ var DimpBase = {
 
             if (baseelt.readAttribute('mbox') == 'INBOX') {
                 elts.invoke('hide');
-                $('ctx_folder_sub', 'ctx_folder_unsub').invoke('hide');
+                if ($('ctx_folder_sub')) {
+                    $('ctx_folder_sub', 'ctx_folder_unsub').invoke('hide');
+                }
             } else {
-                tmp = baseelt.hasClassName('unsubFolder');
-                [ $('ctx_folder_sub') ].invoke(tmp ? 'show' : 'hide');
-                [ $('ctx_folder_unsub') ].invoke(tmp ? 'hide' : 'show');
+                if ($('ctx_folder_sub')) {
+                    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) {
index a379754..a50a7ec 100644 (file)
@@ -4,6 +4,7 @@ $hordeimg = $registry->getImageDir('horde');
 
 $usetrash = $prefs->getValue('use_trash');
 $show_text = in_array($prefs->getValue('menu_view'), array('both', 'text'));
+$use_sub = $prefs->getValue('subscribe');
 $loading_text = _("Loading...");
 
 $has_blacklist = $registry->hasMethod('mail/blacklistFrom');
@@ -337,8 +338,10 @@ 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>
+<?php if ($use_sub): ?>
  <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>
+<?php endif; ?>
 </div>
 
 <div class="context" id="ctx_container" style="display:none">
@@ -391,7 +394,7 @@ 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']): ?>
+<?php if ($conf['user']['allow_folders'] && $use_sub): ?>
  <a id="mboxsubtoggle" class="sep"><span class="contextImg"></span><?php echo _("Show Unsubscribed") ?></a>
 <?php endif; ?>
 <?php if (!empty($flag_list)): ?>