5 * Displays an experimental mailbox-tree with dhtml behaviour.
6 * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily.
7 * See http://www.destroydrop.com/javascripts/tree/
9 * It only works on browsers which supports css and javascript.
11 * The following variables are avilable in this template:
12 * $clock - formatted string containing last refresh
13 * $settings - Array containing user perferences needed by this
14 * template. Indexes are as follows:
15 * $settings['iconThemePath'] - Path to the desired icon theme. If
16 * the user has disabled icons, this will be NULL.
17 * $settings['templateID'] - contains the ID of the current
18 * template set. This may be needed by third
19 * party packages that don't integrate easily.
20 * $settings['unreadNotificationEnabled'] - Boolean TRUE if the user
21 * wants to see unread message count on mailboxes
22 * $settings['unreadNotificationCummulative'] - Boolean TRUE if the
23 * user has enabled cummulative message counts.
24 * $settings['unreadNotificationAllFolders'] - Boolean TRUE if the
25 * user wants to see unread message count on ALL
26 * folders or just the Inbox.
27 * $settings['unreadNotificationDisplayTotal'] - Boolean TRUE if the
28 * user wants to see the total number of messages in
29 * addition to the unread message count.
30 * $settings['collapsableFoldersEnabled'] - Boolean TRUE if the user
31 * has enabled collapsable folders.
32 * $settings['useSpecialFolderColor'] - Boolean TRUE if the use has
33 * chosen to tag "Special" folders in a different color
34 * $settings['messageRecyclingEnabled'] - Boolean TRUE if messages
35 * that get deleted go to the Trash folder. FALSE if
36 * they are permanently deleted.
38 * $mailboxes - Associative array of current mailbox structure.
39 * Provided so template authors know what they have to
40 * work with when building a custom mailbox tree.
41 * Array contains the following elements:
42 * $a['MailboxName'] = String containing the name of the mailbox
43 * $a['MailboxFullName'] = String containing full IMAP name of mailbox
44 * $a['MessageCount'] = integer of all messages in the mailbox
45 * $a['UnreadCount'] = integer of unseen message in the mailbox
46 * $a['ViewLink'] = array containing elements needed to view the
47 * mailbox. Elements are:
48 * 'Target' = target frame for link
49 * 'URL' = target URL for link
50 * $a['IsRecent'] = boolean TRUE if the mailbox is tagged "recent"
51 * $a['IsSpecial'] = boolean TRUE if the mailbox is tagged "special"
52 * $a['IsRoot'] = boolean TRUE if the mailbox is the root mailbox
53 * $a['IsNoSelect'] = boolean TRUE if the mailbox is tagged "noselect"
54 * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently collapsed
55 * $a['CollapseLink'] = array containg elements needed to expand/collapse
56 * the mailbox. Elements are:
57 * 'Target' = target frame for link
58 * 'URL' = target URL for link
59 * 'Icon' = the icon to use, based on user prefs
60 * $a['ChildBoxes'] = array containing this same data structure for
61 * each child folder/mailbox of the current
63 * $a['CummulativeMessageCount'] = integer of total messages in all
64 * folders in this mailbox, exlcuding
66 * $a['CummulativeUnreadCount'] = integer of total unseen messages
67 * in all folders in this mailbox,
68 * excluding trash folders.
70 * @copyright © 1999-2006 The SquirrelMail Project Team
71 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
73 * @package squirrelmail
74 * @subpackage templates
80 * Recursively parse the mailbox structure to build the navigation tree.
82 * @param array $box Array containing mailbox data
83 * @param array $settings Array containing perferences, etc, passed to template
84 * @param string $icon_theme_path
85 * @param integer $indent_factor Counter used to control indent spacing
89 function buildMailboxTree ($box, $settings, $icon_theme_path, $parent_node=-1) {
99 // Determine the path to the correct images
100 $out .= 'mailboxes = new dTree("mailboxes", "'.$icon_theme_path.'");'."\n";
101 $out .= 'mailboxes.config.inOrder = true;'."\n";
105 $name = $box['MailboxName'];
106 $pre = '<span style="white-space: nowrap;">';
109 // Get unseeen/total message info if needed
111 if ($settings['unreadNotificationEnabled']) {
112 // We only display the unread count if we on the Inbox or we are told
113 // to display it on all folders AND there is more than 1 unread message
114 if ( $settings['unreadNotificationAllFolders'] ||
115 (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
117 $unseen = $settings['unreadNotificationCummulative'] ?
118 $box['CummulativeUnreadCount'] :
121 if (!$box['IsNoSelect'] && ($unseen > 0 || $settings['unreadNotificationDisplayTotal'])) {
122 $unseen_str = $unseen;
124 // Add the total messages if desired
125 if ($settings['unreadNotificationDisplayTotal']) {
126 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
127 $box['CummulativeMessageCount'] :
128 $box['MessageCount']);
131 $unseen_str = '<span class="'.
132 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
145 case $box['IsInbox']:
147 $img_open = 'base.png';
149 case $box['IsTrash']:
151 $img_open = 'trash.png';
153 case $box['IsNoSelect']:
154 case $box['IsNoInferiors']:
156 $img_open = 'page.png';
160 $img_open = 'folderopen.png';
164 $display_folder = true;
165 if (!$settings['messageRecyclingEnabled'] && $box['IsTrash']) {
166 $display_folder = false;
169 if($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
170 // Boxes with unread messages should be emphasized
171 if ($box['UnreadCount'] > 0) {
177 if ($box['UnreadCount'] > 0) {
178 if (!empty($unseen_str)) {
179 $end .= ' <small>('.$unseen_str.')</small>';
183 // Add a few other things for all other folders...
184 if (!$box['IsNoSelect']) {
185 // Boxes with unread messages should be emphasized
186 if ($box['UnreadCount'] > 0) {
192 // Display unread info...
193 if (!empty($unseen_str)) {
194 $end .= ' <small>('.$unseen_str.')</small>';
200 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
201 $span = '<span class="leftspecial">';
202 $spanend = '</span>';
203 } elseif ( $box['IsNoSelect'] ) {
204 $span = '<span class="leftnoselect">';
205 $spanend = '</span>';
209 * NOTE: Plugins would horribly break this advanced tree, so we are
210 * going to skip that part altogether.
215 array(' ','<','>'),
216 $box['MailboxName']);
219 if ($box['IsNoSelect']) {
223 $url = $box['ViewLink']['URL'];
224 $target = $box['ViewLink']['Target'];
225 $name = $span . $pre . $name . $end . $spanend;
228 if ($display_folder) {
229 $out .= 'mailboxes.add('.$counter.', '.$parent_node.', ' .
230 '"'.addslashes($name).'", "'.$url.'", "'.$title.'", ' .
232 '"'.getIconPath($icon_theme_path, $img).'", ' .
233 '"'.getIconPath($icon_theme_path, $img_open).'"' .
238 $parent_node = $counter;
239 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
240 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $icon_theme_path, $parent_node);
243 if ($box['IsRoot']) {
244 $out .= 'document.write(mailboxes);'."\n";
250 /* retrieve the template vars */
254 <body class="sqm_leftMain">
255 <script type="text/javascript">
258 * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily.
259 * See http://www.destroydrop.com/javascripts/tree/
261 * |---------------------------------------------------|
262 * | dTree 2.05 | www.destroydrop.com/javascript/tree/ |
263 * |---------------------------------------------------|
264 * | Copyright (c) 2002-2003 Geir Landrö |
266 * | This script can be used freely as long as all |
267 * | copyright messages are intact. |
269 * | Updated: 17.04.2003 |
270 * |---------------------------------------------------|
274 <div class="sqm_leftMain">
275 <?php /* FIXME: no hooks in templates! */ global $null; do_hook('left_main_before', $null); ?>
277 <table class="sqm_wrapperTable" cellspacing="0">
280 <table cellspacing="0">
282 <td style="text-align:center">
283 <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
284 <span class="sqm_clock"><?php echo $clock; ?></span>
285 <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span>
293 <a href="javascript:mailboxes.openAll()">Open All</a>
294 |
295 <a href="javascript:mailboxes.closeAll()">Close All</a>
297 if ($settings['messageRecyclingEnabled']) {
299 echo '<a href="empty_trash.php">Purge Trash</a>';
303 <script type="text/javascript">
305 <?php echo buildMailboxTree($mailboxes, $settings, $icon_theme_path); ?>
309 <?php if (!empty($plugin_output['left_main_after'])) echo $plugin_output['left_main_after']; ?>