5 * Basic template to the left main window. The following variables are
6 * avilable in this template:
7 * $clock - formatted string containing last refresh
8 * $mailbox_listing - string containing HTML to display default mailbox
10 * $location_of_bar - string "left" or "right" indicating where the frame
11 * is located. Currently only used in
12 * left_main_advanced.tpl
13 * $left_size - width of left column in pixels. Currently
14 * only used in left_main_advanced. tpl
15 * $imapConnection - IMAP connection handle. Needed to allow plugins to
17 * $icon_theme_path - Path to the desired icon theme. If the user/admin
18 * has disabled icons, this will be NULL.
20 * $unread_notification_enabled - Boolean TRUE if the user wants to see
21 * unread message count on mailboxes
22 * $unread_notification_cummulative - Boolean TRUE if the user has enabled
23 * cummulative message counts.
24 * $unread_notification_allFolders - Boolean TRUE if the user wants to see
25 * unread message count on ALL folders or just the
27 * $unread_notification_displayTotal - Boolean TRUE if the user wants to
28 * see the total number of messages in addition to the
29 * unread message count.
30 * $collapsable_folders_enabled - Boolean TRUE if the user has enabled
31 * collapsable folders.
32 * $use_special_folder_color - Boolean TRUE if the use has chosen to tag
33 * "Special" folders in a different color.
34 * $message_recycling_enabled - Boolean TRUE if messages that get deleted
35 * go to the Trash folder. FALSE if they are
36 * 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 mailbox is tagged "recent"
51 * $a['IsSpecial'] = boolean TRUE if mailbox is tagged "special"
52 * $a['IsRoot'] = boolean TRUE if mailbox is the root mailbox
53 * $a['IsNoSelect'] = boolean TRUE if mailbox is tagged "noselect"
54 * $a['IsInbox'] = boolean TRUE if mailbox is the Inbox.
55 * $a['IsSent'] = boolean TRUE if mailbox is the Sent box
56 * $a['IsTrash'] = boolean TRUE if mailbox is the Trash box
57 * $a['IsDraft'] = boolean TRUE if mailbox is the Draft box
58 * $a['IsNoInferiors'] = boolean TRUE of mailbox is tagged "no
60 * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently
63 * $a['CollapseLink'] = array containg elements needed to
64 * expand/collapse the mailbox. Elements are:
65 * 'Target' = target frame for link
66 * 'URL' = target URL for link
67 * 'Icon' = the icon to use, based on
69 * $a['ChildBoxes'] = array containing this same data structure for
70 * each child folder/mailbox.
71 * $a ['CummulativeMessageCount'] = integer of total messages in all
72 * folders in this mailbox, exlcuding trash
74 * $a ['CummulativeUnreadCount'] = integer of total unseen messages
75 * in all folders in this mailbox, excluding
78 * @copyright © 1999-2006 The SquirrelMail Project Team
79 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
81 * @package squirrelmail
82 * @subpackage templates
85 // include required files
86 include_once(SM_PATH . 'templates/util_global.php');
89 * Recursively parse the mailbox structure to build the navigation tree.
93 function buildMailboxTree ($box, $settings, $indent_factor=0) {
99 $pre = '<span style="white-space: nowrap;">';
101 $indent = str_repeat(' ',$indent_factor);
103 // Get unseeen/total message info if needed
105 if ($settings['unreadNotificationEnabled']) {
106 // We only display the unread count if we on the Inbox or we are told
107 // to display it on all folders AND there is more than 1 unread message
108 if ( $settings['unreadNotificationAllFolders'] ||
109 (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
111 $unseen = $settings['unreadNotificationCummulative'] ?
112 $box['CummulativeUnreadCount'] :
116 $unseen_str = $unseen;
118 // Add the total messages if desired
119 if ($settings['unreadNotificationDisplayTotal']) {
120 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
121 $box['CummulativeMessageCount'] :
122 $box['MessageCount']);
125 $unseen_str = '<span class="'.
126 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
134 * If the box has any children, and collapsable folders have been enabled
135 * we need to output the expand/collapse link.
137 if (sizeof($box['ChildBoxes'])>0 && $settings['collapsableFoldersEnabled']) {
139 '<a href="'.$box['CollapseLink']['URL'].'" ' .
140 'target="'.$box['CollapseLink']['Target'].'" ' .
141 'style="text-decoration:none" ' .
143 $box['CollapseLink']['Icon'] .
147 $pre .= $indent . ' ';
151 * Add folder icon. Template authors may choose to display a different
152 * image based on whatever logic they see fit here.
155 if (!is_null($settings['iconThemePath'])) {
157 case $box['IsInbox']:
158 $folder_icon = getIcon($settings['iconThemePath'], 'inbox.png', '', $box['MailboxName']);
161 $folder_icon = getIcon($settings['iconThemePath'], 'senti.png', '', $box['MailboxName']);
163 case $box['IsTrash']:
164 $folder_icon = getIcon($settings['iconThemePath'], 'delitem.png', '', $box['MailboxName']);
166 case $box['IsDraft']:
167 $folder_icon = getIcon($settings['iconThemePath'], 'draft.png', '', $box['MailboxName']);
169 case $box['IsNoInferiors']:
170 $folder_icon = getIcon($settings['iconThemePath'], 'folder_noinf.png', '', $box['MailboxName']);
173 $folder_icon = getIcon($settings['iconThemePath'], 'folder.png', '', $box['MailboxName']);
176 $folder_icon .= ' ';
178 $pre .= $folder_icon;
181 * The Trash folder should only be displayed if message recycling has
182 * been enabled, i.e. when deleted is a message moved to the trash or
185 $view_link = '<a href="'.$box['ViewLink']['URL'].'" ' .
186 'target="'.$box['ViewLink']['Target'].'" ' .
187 'style="text-decoration:none">';
189 if ($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
192 // Boxes with unread messages should be emphasized
193 if ($box['UnreadCount'] > 0) {
200 if ($box['UnreadCount'] > 0) {
201 if (!empty($unseen_str)) {
202 $end .= ' <small>('.$unseen_str.')</small>';
204 $end .= "\n<small>" .
205 ' [<a href="empty_trash.php">'. _("Purge").'</a>]' .
209 // Add a few other things for all other folders...
210 if (!$box['IsNoSelect']) {
213 // Boxes with unread messages should be emphasized
214 if ($box['UnreadCount'] > 0) {
221 // Display unread info...
222 if (!empty($unseen_str)) {
223 $end .= ' <small>('.$unseen_str.')</small>';
229 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
230 $span = '<span class="leftspecial">';
231 $spanend = '</span>';
232 } elseif ( $box['IsNoSelect'] ) {
233 $span = '<span class="leftnoselect">';
234 $spanend = '</span>';
237 // let plugins fiddle with end of line
238 $end .= concat_hook_function('left_main_after_each_folder',
239 array(isset($numMessages) ? $numMessages : '',
240 $box['MailboxFullName'], $settings['imapConnection']));
245 if (!$box['IsRoot']) {
246 $out = $span . $pre .
249 array(' ','<','>'),
250 $box['MailboxName']) .
251 $end . $spanend . '<br />' . "\n";
255 if (!$box['IsCollapsed'] || $box['IsRoot']) {
256 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
257 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $indent_factor);
264 // Retrieve the template vars
268 * Build an array to pass user prefs to the function that builds the tree in
269 * order to avoid using globals, which are dirty, filthy things in templates. :)
272 $settings['imapConnection'] = $imapConnection;
273 $settings['iconThemePath'] = $icon_theme_path;
274 $settings['unreadNotificationEnabled'] = $unread_notification_enabled;
275 $settings['unreadNotificationAllFolders'] = $unread_notification_allFolders;
276 $settings['unreadNotificationDisplayTotal'] = $unread_notification_displayTotal;
277 $settings['unreadNotificationCummulative'] = $unread_notification_cummulative;
278 $settings['useSpecialFolderColor'] = $use_special_folder_color;
279 $settings['messageRecyclingEnabled'] = $message_recycling_enabled;
280 $settings['collapsableFoldersEnabled'] = $collapsable_folders_enabled;
283 <body class="sqm_leftMain">
284 <div class="sqm_leftMain">
285 <?php do_hook('left_main_before'); ?>
286 <table class="sqm_wrapperTable" cellspacing="0">
289 <table cellspacing="0">
291 <td style="text-align:center">
292 <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
293 <span class="sqm_clock"><?php echo $clock; ?></span>
294 <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span>
299 <?php echo buildMailboxTree($mailboxes, $settings); ?>
303 <?php do_hook('left_main_after'); ?>