From 96801eeee12ba3e22bf970be32f1733faa17f635 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 5 Feb 2009 13:55:23 -0700 Subject: [PATCH] Request #7353 - Add imp_hook_display_folder() hook. --- imp/config/conf.xml | 4 ++++ imp/config/hooks.php.dist | 17 +++++++++++++++++ imp/docs/CHANGES | 4 ++-- imp/js/src/DimpBase.js | 2 +- imp/lib/IMAP/Tree.php | 36 +++++++++++++++++++++++++++++++++--- 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/imp/config/conf.xml b/imp/config/conf.xml index 6ab974ecd..f6d2c4923 100644 --- a/imp/config/conf.xml +++ b/imp/config/conf.xml @@ -385,6 +385,10 @@ a custom function to provide additional information/custom formatting of messages in the mailbox message list? If so, make sure you define _imp_hook_msglist_format() in hooks.php.">false + false diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index fcfe918b1..0ce4e90cb 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -377,6 +377,16 @@ // } // } +// This is an example hook function to hide specified IMAP mailboxes in +// folder listings. If the hook returns false, the mailbox will not be +// displayed. + +// if (!function_exists('_imp_hook_display_folder')) { +// function _imp_hook_display_folder($mailbox) { +// return ($mailbox == 'DONOTDISPLAY'); +// } +// } + // This is an example hook function for the IMP spam reporting email option. // This function is called when the message is about to be forwarded - it // will return the email address to forward to. This is handy for spam @@ -478,6 +488,13 @@ if (!empty($GLOBALS['conf']['kolab']['enabled'])) { return $icons; } } + + if (!function_exists('_imp_hook_display_folder')) { + function _imp_hook_display_folder($mailbox) { + $type = Kolab::getMailboxType($mailbox); + return empty($type) || ($type == 'mail'); + } + } } // Sample function for returning the quota. Uses the PECL ssh2 diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index fb577407e..331c9f2bc 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -50,10 +50,10 @@ v5.0-git v4.3.4-cvs ---------- -[jan] Fix rendering of subjects in RTL scripts when using LTR translations - (vilius@lnk.lt, Bug #3511). [mms] Add hook to allow hiding of IMAP folders (Request #7353, Gunnar Wrobel ). +[jan] Fix rendering of subjects in RTL scripts when using LTR translations + (vilius@lnk.lt, Bug #3511). [jan] Fix logging of messages forwarded with attachments (Bug #7911). diff --git a/imp/js/src/DimpBase.js b/imp/js/src/DimpBase.js index ff2707be5..c6673318e 100644 --- a/imp/js/src/DimpBase.js +++ b/imp/js/src/DimpBase.js @@ -1886,7 +1886,7 @@ var DimpBase = { div = new Element('DIV', { className: ob.cl || 'base', id: fid + '_div' }); if (ob.i) { - div.setStyle({ background-image: 'url("' + ob.i + '")' }); + div.setStyle({ backgroundImage: 'url("' + ob.i + '")' }); } if (ob.ch) { div.writeAttribute({ className: 'exp' }); diff --git a/imp/lib/IMAP/Tree.php b/imp/lib/IMAP/Tree.php index c394b024a..56966b7cb 100644 --- a/imp/lib/IMAP/Tree.php +++ b/imp/lib/IMAP/Tree.php @@ -28,6 +28,7 @@ class IMP_IMAP_Tree const ELT_NEED_SORT = 64; const ELT_VFOLDER = 128; const ELT_NONIMAP = 256; + const ELT_INVISIBLE = 512; /* The isOpen() expanded mode constants. */ const OPEN_NONE = 0; @@ -382,7 +383,12 @@ class IMP_IMAP_Tree /* Get the mailbox label. */ $elt['l'] = IMP::getLabel($tmp[$elt['c']]); + if ($_SESSION['imp']['protocol'] != 'pop') { + if (!empty($GLOBALS['conf']['hooks']['display_folder'])) { + $this->_setInvisible($elt, !Horde::callHook('_imp_hook_display_folder', array($elt['v']), 'imp')); + } + if ($elt['c'] != 0) { $elt['p'] = implode(is_null($ns_info) ? $this->_delimiter : $ns_info['delimiter'], array_slice($tmp, 0, $elt['c'])); } @@ -1248,6 +1254,29 @@ class IMP_IMAP_Tree } /** + * Is the element invisible? + * + * @param array $elt A tree element. + * + * @return integer True if the element is marked as invisible. + */ + public function isInvisible($elt) + { + return $elt['a'] & self::ELT_INVISIBLE; + } + + /** + * Set the invisible attribute for an element. + * + * @param array &$elt A tree element. + * @param boolean $bool The setting. + */ + protected function _setInvisible(&$elt, $bool) + { + $this->_setAttribute($elt, self::ELT_INVISIBLE, $bool); + } + + /** * Flag the element as needing its children to be sorted. * * @param array &$elt A tree element. @@ -1401,9 +1430,10 @@ class IMP_IMAP_Tree */ protected function _activeElt($elt) { - return ($this->_showunsub || - ($this->isSubscribed($elt) && !$this->isContainer($elt)) || - $this->hasChildren($elt)); + return (!$this->isInvisible($elt) && + ($this->_showunsub || + ($this->isSubscribed($elt) && !$this->isContainer($elt)) || + $this->hasChildren($elt))); } /** -- 2.11.0