5 * Basic template to the left main window.
7 * The following variables are avilable in this template:
8 * $clock - formatted string containing last refresh
9 * $settings - Array containing user perferences needed by this
10 * template. Indexes are as follows:
11 * $settings['templateID'] - contains the ID of the current
12 * template set. This may be needed by third
13 * party packages that don't integrate easily.
14 * $settings['unreadNotificationEnabled'] - Boolean TRUE if the user
15 * wants to see unread message count on mailboxes
16 * $settings['unreadNotificationCummulative'] - Boolean TRUE if the
17 * user has enabled cummulative message counts.
18 * $settings['unreadNotificationAllFolders'] - Boolean TRUE if the
19 * user wants to see unread message count on ALL
20 * folders or just the Inbox.
21 * $settings['unreadNotificationDisplayTotal'] - Boolean TRUE if the
22 * user wants to see the total number of messages in
23 * addition to the unread message count.
24 * $settings['collapsableFoldersEnabled'] - Boolean TRUE if the user
25 * has enabled collapsable folders.
26 * $settings['useSpecialFolderColor'] - Boolean TRUE if the use has
27 * chosen to tag "Special" folders in a different color
28 * $settings['messageRecyclingEnabled'] - Boolean TRUE if messages
29 * that get deleted go to the Trash folder. FALSE if
30 * they are permanently deleted.
32 * $mailboxes - Associative array of current mailbox structure.
33 * Provided so template authors know what they have to
34 * work with when building a custom mailbox tree.
35 * Array contains the following elements:
36 * $a['MailboxName'] = String containing the name of the mailbox
37 * $a['MailboxFullName'] = String containing full IMAP name of mailbox
38 * $a['MessageCount'] = integer of all messages in the mailbox
39 * $a['UnreadCount'] = integer of unseen message in the mailbox
40 * $a['ViewLink'] = array containing elements needed to view the
41 * mailbox. Elements are:
42 * 'Target' = target frame for link
43 * 'URL' = target URL for link
44 * $a['IsRecent'] = boolean TRUE if the mailbox is tagged "recent"
45 * $a['IsSpecial'] = boolean TRUE if the mailbox is tagged "special"
46 * $a['IsRoot'] = boolean TRUE if the mailbox is the root mailbox
47 * $a['IsNoSelect'] = boolean TRUE if the mailbox is tagged "noselect"
48 * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently collapsed
49 * $a['CollapseLink'] = array containg elements needed to expand/collapse
50 * the mailbox. Elements are:
51 * 'Target' = target frame for link
52 * 'URL' = target URL for link
53 * 'Icon' = the icon to use, based on user prefs
54 * $a['ChildBoxes'] = array containing this same data structure for
55 * each child folder/mailbox of the current
57 * $a['CummulativeMessageCount'] = integer of total messages in all
58 * folders in this mailbox, exlcuding
60 * $a['CummulativeUnreadCount'] = integer of total unseen messages
61 * in all folders in this mailbox,
62 * excluding trash folders.
64 * @copyright © 1999-2006 The SquirrelMail Project Team
65 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
67 * @package squirrelmail
68 * @subpackage templates
74 * Recursively parse the mailbox structure to build the navigation tree.
78 function buildMailboxTree ($box, $settings, $icon_theme_path, $indent_factor=0) {
84 $pre = '<span style="white-space: nowrap;">';
86 $indent = str_repeat(' ',$indent_factor);
88 // Get unseeen/total message info if needed
90 if ($settings['unreadNotificationEnabled']) {
91 // We only display the unread count if we on the Inbox or we are told
92 // to display it on all folders AND there is more than 1 unread message
93 if ( $settings['unreadNotificationAllFolders'] ||
94 (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
96 $unseen = $settings['unreadNotificationCummulative'] ?
97 $box['CummulativeUnreadCount'] :
100 if (!$box['IsNoSelect'] && ($unseen > 0 || $settings['unreadNotificationDisplayTotal'])) {
101 $unseen_str = $unseen;
103 // Add the total messages if desired
104 if ($settings['unreadNotificationDisplayTotal']) {
105 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
106 $box['CummulativeMessageCount'] :
107 $box['MessageCount']);
110 $unseen_str = '<span class="'.
111 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
119 * If the box has any children, and collapsable folders have been enabled
120 * we need to output the expand/collapse link.
122 if (sizeof($box['ChildBoxes'])>0 && $settings['collapsableFoldersEnabled']) {
124 '<a href="'.$box['CollapseLink']['URL'].'" ' .
125 'target="'.$box['CollapseLink']['Target'].'" ' .
126 'style="text-decoration:none" ' .
128 $box['CollapseLink']['Icon'] .
132 $pre .= $indent . ' ';
136 * Add folder icon. Template authors may choose to display a different
137 * image based on whatever logic they see fit here.
140 if (!is_null($icon_theme_path)) {
142 case $box['IsInbox']:
143 $folder_icon = getIcon($icon_theme_path, 'inbox.png', '', $box['MailboxName']);
146 $folder_icon = getIcon($icon_theme_path, 'senti.png', '', $box['MailboxName']);
148 case $box['IsTrash']:
149 $folder_icon = getIcon($icon_theme_path, 'delitem.png', '', $box['MailboxName']);
151 case $box['IsDraft']:
152 $folder_icon = getIcon($icon_theme_path, 'draft.png', '', $box['MailboxName']);
154 case $box['IsNoInferiors']:
155 $folder_icon = getIcon($icon_theme_path, 'folder_noinf.png', '', $box['MailboxName']);
158 $folder_icon = getIcon($icon_theme_path, 'folder.png', '', $box['MailboxName']);
161 $folder_icon .= ' ';
163 $pre .= $folder_icon;
165 // calculate if access key is needed
167 if ($box['IsInbox']) {
168 global $accesskey_folders_inbox;
169 $accesskey = $accesskey_folders_inbox;
171 else $accesskey = '';
174 * The Trash folder should only be displayed if message recycling has
175 * been enabled, i.e. when deleted is a message moved to the trash or
178 $view_link = '<a href="'.$box['ViewLink']['URL'].'" ' .
179 ($accesskey == '' ? '' : 'accesskey="' . $accesskey . '" ') .
180 'target="'.$box['ViewLink']['Target'].'" ' .
181 'style="text-decoration:none">';
183 if ($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
186 // Boxes with unread messages should be emphasized
187 if ($box['UnreadCount'] > 0) {
194 if ($box['MessageCount'] > 0 || count($box['ChildBoxes'])) {
195 if (!empty($unseen_str)) {
196 $end .= ' <small>('.$unseen_str.')</small>';
198 $end .= "\n<small>" .
199 ' [<a href="empty_trash.php">'. _("Purge").'</a>]' .
203 // Add a few other things for all other folders...
204 if (!$box['IsNoSelect']) {
207 // Boxes with unread messages should be emphasized
208 if ($box['UnreadCount'] > 0) {
215 // Display unread info...
216 if (!empty($unseen_str)) {
217 $end .= ' <small>('.$unseen_str.')</small>';
221 // Add any extra output that may have been added by plugins, etc
223 if (!empty($box['ExtraOutput']))
224 $end .= $box['ExtraOutput'];
228 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
229 $span = '<span class="leftspecial">';
230 $spanend = '</span>';
231 } elseif ( $box['IsNoSelect'] ) {
232 $span = '<span class="leftnoselect">';
233 $spanend = '</span>';
239 if (!$box['IsRoot']) {
240 $out = $span . $pre .
243 array(' ','<','>'),
244 $box['MailboxName']) .
245 $end . $spanend . '<br />' . "\n";
249 if (!$box['IsCollapsed'] || $box['IsRoot']) {
250 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
251 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $icon_theme_path, $indent_factor);
258 // Retrieve the template vars
262 <body class="sqm_leftMain">
263 <div class="sqm_leftMain">
264 <?php if (!empty($plugin_output['left_main_before'])) echo $plugin_output['left_main_before']; ?>
265 <table class="sqm_wrapperTable" cellspacing="0">
268 <table cellspacing="0">
270 <td style="text-align:center">
271 <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
272 <span class="sqm_clock"><?php echo $clock; ?></span>
273 <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" <?php if ($accesskey_folders_refresh != 'NONE') echo 'accesskey="' . $accesskey_folders_refresh . '" '; ?>target="left"><?php echo _("Check Mail"); ?></a>]</small></span>
278 <?php echo buildMailboxTree($mailboxes, $settings, $icon_theme_path); ?>
282 <?php if (!empty($plugin_output['left_main_after'])) echo $plugin_output['left_main_after']; ?>