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['imapConnection'] - IMAP connection handle. Needed to
16 * allow plugins to read the mailbox.
17 * $settings['iconThemePath'] - Path to the desired icon theme. If
18 * the user has disabled icons, this will be NULL.
19 * $settings['templateDirectory'] - contains the path to the current
20 * template directory. This may be needed by third
21 * party packages that don't integrate easily.
22 * $settings['unreadNotificationEnabled'] - Boolean TRUE if the user
23 * wants to see unread message count on mailboxes
24 * $settings['unreadNotificationCummulative'] - Boolean TRUE if the
25 * user has enabled cummulative message counts.
26 * $settings['unreadNotificationAllFolders'] - Boolean TRUE if the
27 * user wants to see unread message count on ALL
28 * folders or just the Inbox.
29 * $settings['unreadNotificationDisplayTotal'] - Boolean TRUE if the
30 * user wants to see the total number of messages in
31 * addition to the unread message count.
32 * $settings['collapsableFoldersEnabled'] - Boolean TRUE if the user
33 * has enabled collapsable folders.
34 * $settings['useSpecialFolderColor'] - Boolean TRUE if the use has
35 * chosen to tag "Special" folders in a different color
36 * $settings['messageRecyclingEnabled'] - Boolean TRUE if messages
37 * that get deleted go to the Trash folder. FALSE if
38 * they are permanently deleted.
40 * $mailboxes - Associative array of current mailbox structure.
41 * Provided so template authors know what they have to
42 * work with when building a custom mailbox tree.
43 * Array contains the following elements:
44 * $a['MailboxName'] = String containing the name of the mailbox
45 * $a['MailboxFullName'] = String containing full IMAP name of mailbox
46 * $a['MessageCount'] = integer of all messages in the mailbox
47 * $a['UnreadCount'] = integer of unseen message in the mailbox
48 * $a['ViewLink'] = array containing elements needed to view the
49 * mailbox. Elements are:
50 * 'Target' = target frame for link
51 * 'URL' = target URL for link
52 * $a['IsRecent'] = boolean TRUE if the mailbox is tagged "recent"
53 * $a['IsSpecial'] = boolean TRUE if the mailbox is tagged "special"
54 * $a['IsRoot'] = boolean TRUE if the mailbox is the root mailbox
55 * $a['IsNoSelect'] = boolean TRUE if the mailbox is tagged "noselect"
56 * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently collapsed
57 * $a['CollapseLink'] = array containg elements needed to expand/collapse
58 * the mailbox. Elements are:
59 * 'Target' = target frame for link
60 * 'URL' = target URL for link
61 * 'Icon' = the icon to use, based on user prefs
62 * $a['ChildBoxes'] = array containing this same data structure for
63 * each child folder/mailbox of the current
65 * $a['CummulativeMessageCount'] = integer of total messages in all
66 * folders in this mailbox, exlcuding
68 * $a['CummulativeUnreadCount'] = integer of total unseen messages
69 * in all folders in this mailbox,
70 * excluding trash folders.
72 * @copyright © 1999-2006 The SquirrelMail Project Team
73 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
75 * @package squirrelmail
76 * @subpackage templates
80 /** include required files */
81 include_once(SM_PATH . 'templates/util_global.php');
84 * Recursively parse the mailbox structure to build the navigation tree.
86 * @param array $box Array containing mailbox data
87 * @param array $settings Array containing perferences, etc, passed to template
88 * @param integer $indent_factor Counter used to control indent spacing
92 function buildMailboxTree ($box, $settings, $parent_node=-1) {
100 $image_path = $settings['templateDirectory'] . 'images/';
102 if ($box['IsRoot']) {
103 // Determine the path to the correct images
104 $out .= 'mailboxes = new dTree("mailboxes", "'.$image_path.'");'."\n";
105 $out .= 'mailboxes.config.inOrder = true;'."\n";
109 $name = $box['MailboxName'];
110 $pre = '<span style="white-space: nowrap;">';
113 // Get unseeen/total message info if needed
115 if ($settings['unreadNotificationEnabled']) {
116 // We only display the unread count if we on the Inbox or we are told
117 // to display it on all folders AND there is more than 1 unread message
118 if ( $settings['unreadNotificationAllFolders'] ||
119 (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
121 $unseen = $settings['unreadNotificationCummulative'] ?
122 $box['CummulativeUnreadCount'] :
125 if (!$box['IsNoSelect'] && ($unseen > 0 || $settings['unreadNotificationDisplayTotal'])) {
126 $unseen_str = $unseen;
128 // Add the total messages if desired
129 if ($settings['unreadNotificationDisplayTotal']) {
130 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
131 $box['CummulativeMessageCount'] :
132 $box['MessageCount']);
135 $unseen_str = '<span class="'.
136 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
149 case $box['IsInbox']:
150 $img = $image_path . 'base.png';
151 $img_open = $image_path . 'base.png';
153 case $box['IsTrash']:
154 $img = $image_path . 'trash.png';
155 $img_open = $image_path . 'trash.png';
157 case $box['IsNoSelect']:
158 case $box['IsNoInferiors']:
159 $img = $image_path . 'page.png';
160 $img_open = $image_path . 'page.png';
163 $img = $image_path . 'folder.png';
164 $img_open = $image_path . 'folderopen.png';
168 $display_folder = true;
169 if (!$settings['messageRecyclingEnabled'] && $box['IsTrash']) {
170 $display_folder = false;
173 if($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
174 // Boxes with unread messages should be emphasized
175 if ($box['UnreadCount'] > 0) {
181 if ($box['UnreadCount'] > 0) {
182 if (!empty($unseen_str)) {
183 $end .= ' <small>('.$unseen_str.')</small>';
187 // Add a few other things for all other folders...
188 if (!$box['IsNoSelect']) {
189 // Boxes with unread messages should be emphasized
190 if ($box['UnreadCount'] > 0) {
196 // Display unread info...
197 if (!empty($unseen_str)) {
198 $end .= ' <small>('.$unseen_str.')</small>';
204 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
205 $span = '<span class="leftspecial">';
206 $spanend = '</span>';
207 } elseif ( $box['IsNoSelect'] ) {
208 $span = '<span class="leftnoselect">';
209 $spanend = '</span>';
213 * NOTE: Plugins would horribly break this advanced tree, so we are
214 * going to skip that part altogether.
219 array(' ','<','>'),
220 $box['MailboxName']);
223 if ($box['IsNoSelect']) {
227 $url = $box['ViewLink']['URL'];
228 $target = $box['ViewLink']['Target'];
229 $name = $span . $pre . $name . $end . $spanend;
232 if ($display_folder) {
233 $out .= 'mailboxes.add('.$counter.', '.$parent_node.', ' .
234 '"'.addslashes($name).'", "'.$url.'", "'.$title.'", ' .
242 $parent_node = $counter;
243 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
244 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $parent_node);
247 if ($box['IsRoot']) {
248 $out .= 'document.write(mailboxes);'."\n";
254 /* retrieve the template vars */
258 <body class="sqm_leftMain">
259 <script type="text/javascript">
262 * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily.
263 * See http://www.destroydrop.com/javascripts/tree/
265 * |---------------------------------------------------|
266 * | dTree 2.05 | www.destroydrop.com/javascript/tree/ |
267 * |---------------------------------------------------|
268 * | Copyright (c) 2002-2003 Geir Landrö |
270 * | This script can be used freely as long as all |
271 * | copyright messages are intact. |
273 * | Updated: 17.04.2003 |
274 * |---------------------------------------------------|
278 <div class="sqm_leftMain">
279 <?php do_hook('left_main_before'); ?>
281 <table class="sqm_wrapperTable" cellspacing="0">
284 <table cellspacing="0">
286 <td style="text-align:center">
287 <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
288 <span class="sqm_clock"><?php echo $clock; ?></span>
289 <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span>
297 <a href="javascript:mailboxes.openAll()">Open All</a>
298 |
299 <a href="javascript:mailboxes.closeAll()">Close All</a>
301 if ($settings['messageRecyclingEnabled']) {
303 echo '<a href="empty_trash.php">Purge Trash</a>';
307 <script type="text/javascript">
309 <?php echo buildMailboxTree($mailboxes, $settings); ?>
313 <?php do_hook('left_main_after'); ?>