From 55e346263751f3100c780b2d3aee268b6fa3232d Mon Sep 17 00:00:00 2001 From: pdontthink Date: Tue, 3 May 2011 06:05:08 +0000 Subject: [PATCH] Allow administrators to configure subfolders of user INBOXes to be treated as special folders by adding $subfolders_of_inbox_are_special to config_local.php git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14107 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/config_local.example.php | 5 +++++ doc/ChangeLog | 3 +++ functions/imap_mailbox.php | 30 ++++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/config/config_local.example.php b/config/config_local.example.php index a34b784d..32413cff 100644 --- a/config/config_local.example.php +++ b/config/config_local.example.php @@ -47,5 +47,10 @@ * 4.3.0. Set to 'CRLF' or 'LF' or, to force line endings to be * unmolested, set to some other string, such as 'NOCHANGE' * + * $subfolders_of_inbox_are_special (boolean) can be set to TRUE + * if any subfolders of the INBOX should be treated as "special" + * (those that are displayed in a different color than other + * "normal" mailboxes). + * */ diff --git a/doc/ChangeLog b/doc/ChangeLog index 98241eac..f63b2c3c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -357,6 +357,9 @@ Version 1.5.2 - SVN (helps forwarded messages avoid spam filters) (Thanks to Petr Kletecka) (#3139004). - Added smtp_auth hook (Thanks to Emmanuel Dreyfus). + - Allow administrators to configure subfolders of user INBOXes to be + treated as special folders by adding $subfolders_of_inbox_are_special + to config_local.php. Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 86f757f3..d7898efe 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -216,8 +216,15 @@ function isBoxBelow( $subbox, $parentbox ) { * Defines special mailboxes: given a mailbox name, it checks if this is a * "special" one: INBOX, Trash, Sent or Draft. * - * Since 1.2.5 function includes special_mailbox hook.
+ * Since 1.2.5 function includes special_mailbox hook. + * * Since 1.4.3 hook supports more than one plugin. + * + * Since 1.4.22/1.5.2, the administrator can add + * $subfolders_of_inbox_are_special = TRUE; + * to config/config_local.php and all subfolders + * of the INBOX will be treated as special. + * * @param string $box mailbox name * @param boolean $include_subs (since 1.5.2) if true, subfolders of system * folders are special. if false, subfolders are not special mailboxes @@ -226,7 +233,9 @@ function isBoxBelow( $subbox, $parentbox ) { * @since 1.2.3 */ function isSpecialMailbox($box,$include_subs=true) { - $ret = ( (strtolower($box) == 'inbox') || + global $subfolders_of_inbox_are_special; + $ret = ( ($subfolders_of_inbox_are_special && isInboxMailbox($box,$include_subs)) || + (!$subfolders_of_inbox_are_special && strtolower($box) == 'inbox') || isTrashMailbox($box,$include_subs) || isSentMailbox($box,$include_subs) || isDraftMailbox($box,$include_subs) ); @@ -237,6 +246,23 @@ function isSpecialMailbox($box,$include_subs=true) { return $ret; } +/** + * Detects if mailbox is the Inbox folder or subfolder of the Inbox + * + * @param string $box The mailbox name to test + * @param boolean $include_subs If true, subfolders of system folders + * are special. If false, subfolders are + * not special mailboxes. + * + * @return boolean Whether this is the Inbox or a child thereof. + * + * @since 1.4.22 + */ +function isInboxMailbox($box, $include_subs=TRUE) { + return ((strtolower($box) == 'inbox') + || ($include_subs && isBoxBelow(strtolower($box), 'inbox'))); +} + /** * Detects if mailbox is a Trash folder or subfolder of Trash * @param string $box mailbox name -- 2.25.1