Happy New Year
[squirrelmail.git] / templates / default_advanced / left_main.tpl
CommitLineData
93222bea 1<?php
2/**
3 * left_main.tpl
4 *
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/
8 *
9 * It only works on browsers which supports css and javascript.
10 *
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:
93222bea 15 * $settings['iconThemePath'] - Path to the desired icon theme. If
16 * the user has disabled icons, this will be NULL.
4f5c9970 17 * $settings['templateID'] - contains the ID of the current
18 * template set. This may be needed by third
93222bea 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.
37 *
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
62 * mailbox.
63 * $a['CummulativeMessageCount'] = integer of total messages in all
64 * folders in this mailbox, exlcuding
65 * trash folders.
66 * $a['CummulativeUnreadCount'] = integer of total unseen messages
67 * in all folders in this mailbox,
68 * excluding trash folders.
69 *
c4faef33 70 * @copyright 1999-2020 The SquirrelMail Project Team
93222bea 71 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
72 * @version $Id$
73 * @package squirrelmail
74 * @subpackage templates
75 * @author Steve Brown
76 */
77
93222bea 78
79/*
80 * Recursively parse the mailbox structure to build the navigation tree.
81 *
82 * @param array $box Array containing mailbox data
83 * @param array $settings Array containing perferences, etc, passed to template
34446790 84 * @param string $icon_theme_path
93222bea 85 * @param integer $indent_factor Counter used to control indent spacing
86 * @since 1.5.2
87 * @author Steve Brown
88 */
34446790 89function buildMailboxTree ($box, $settings, $icon_theme_path, $parent_node=-1) {
93222bea 90 static $counter;
91
92 // stop condition
93 if (empty($box)) {
94 return '';
95 }
96
93222bea 97 $out = '';
34446790 98 if ($box['IsRoot']) {
93222bea 99 // Determine the path to the correct images
34446790 100 $out .= 'mailboxes = new dTree("mailboxes", "'.$icon_theme_path.'");'."\n";
93222bea 101 $out .= 'mailboxes.config.inOrder = true;'."\n";
102 $counter = -1;
103 } else {
104 $counter++;
105 $name = $box['MailboxName'];
106 $pre = '<span style="white-space: nowrap;">';
107 $end = '';
108
109 // Get unseeen/total message info if needed
110 $unseen_str = '';
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')
116 ) {
117 $unseen = $settings['unreadNotificationCummulative'] ?
118 $box['CummulativeUnreadCount'] :
119 $box['UnreadCount'];
120
b04d1537 121 if (!$box['IsNoSelect'] && ($unseen > 0 || $settings['unreadNotificationDisplayTotal'])) {
93222bea 122 $unseen_str = $unseen;
123
124 // Add the total messages if desired
125 if ($settings['unreadNotificationDisplayTotal']) {
126 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
127 $box['CummulativeMessageCount'] :
128 $box['MessageCount']);
129 }
130
131 $unseen_str = '<span class="'.
132 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
133 '">' . $unseen_str .
134 '</span>';
135 }
136 }
137 }
138
139 /**
140 * Add folder icon.
141 */
142 $img = '';
143 $img_open = '';
144 switch (true) {
145 case $box['IsInbox']:
34446790 146 $img = 'base.png';
147 $img_open = 'base.png';
93222bea 148 break;
149 case $box['IsTrash']:
34446790 150 $img = 'trash.png';
151 $img_open = 'trash.png';
93222bea 152 break;
153 case $box['IsNoSelect']:
154 case $box['IsNoInferiors']:
34446790 155 $img = 'page.png';
156 $img_open = 'page.png';
93222bea 157 break;
158 default:
34446790 159 $img = 'folder.png';
160 $img_open = 'folderopen.png';
93222bea 161 break;
162 }
163
164 $display_folder = true;
165 if (!$settings['messageRecyclingEnabled'] && $box['IsTrash']) {
166 $display_folder = false;
167 }
168
169 if($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
170 // Boxes with unread messages should be emphasized
171 if ($box['UnreadCount'] > 0) {
172 $pre .= '<em>';
173 $end .= '</em>';
174 }
175
176 // Print unread info
177 if ($box['UnreadCount'] > 0) {
178 if (!empty($unseen_str)) {
179 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
180 }
181 }
182 } else {
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) {
187 $pre .= '<em>';
188 $end .= '</em>';
189 }
190 }
191
192 // Display unread info...
193 if (!empty($unseen_str)) {
194 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
195 }
196 }
197
e883b46e 198 // Add any extra output that may have been added by plugins, etc
199 //
200 if (!empty($box['ExtraOutput']))
201 $end .= $box['ExtraOutput'];
202
93222bea 203 $span = '';
204 $spanend = '';
205 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
206 $span = '<span class="leftspecial">';
207 $spanend = '</span>';
208 } elseif ( $box['IsNoSelect'] ) {
209 $span = '<span class="leftnoselect">';
210 $spanend = '</span>';
211 }
212
93222bea 213 $name = str_replace(
214 array(' ','<','>'),
215 array('&nbsp;','&lt;','&gt;'),
216 $box['MailboxName']);
217 $title = $name;
218
219 if ($box['IsNoSelect']) {
220 $url = '';
221 $target = '';
222 } else {
223 $url = $box['ViewLink']['URL'];
224 $target = $box['ViewLink']['Target'];
225 $name = $span . $pre . $name . $end . $spanend;
226 }
227
228 if ($display_folder) {
f99c4469 229
230 if ($box['IsInbox']) {
231 global $accesskey_folders_inbox;
232 $accesskey = $accesskey_folders_inbox;
233 }
234 else $accesskey = '';
235
93222bea 236 $out .= 'mailboxes.add('.$counter.', '.$parent_node.', ' .
237 '"'.addslashes($name).'", "'.$url.'", "'.$title.'", ' .
238 '"'.$target.'", ' .
34446790 239 '"'.getIconPath($icon_theme_path, $img).'", ' .
f99c4469 240 '"'.getIconPath($icon_theme_path, $img_open).'", ' .
241 '"'.$accesskey.'"' .
93222bea 242 ');'."\n";
243 }
244 }
245
246 $parent_node = $counter;
247 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
34446790 248 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $icon_theme_path, $parent_node);
93222bea 249 }
250
251 if ($box['IsRoot']) {
252 $out .= 'document.write(mailboxes);'."\n";
253 }
254
255 return $out;
b71975ad 256//FIXME: somewhere above, need to insert the left_main_after_each_folder hook, or if no plugin hooks allowed in templates, at least the output from that hook (but I think it might be impossible not to have the hook here in this fxn
93222bea 257}
258
259/* retrieve the template vars */
260extract($t);
261
262?>
263<body class="sqm_leftMain">
264<script type="text/javascript">
265<!--
266/**
267 * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily.
268 * See http://www.destroydrop.com/javascripts/tree/
269 *
270 * |---------------------------------------------------|
271 * | dTree 2.05 | www.destroydrop.com/javascript/tree/ |
272 * |---------------------------------------------------|
273 * | Copyright (c) 2002-2003 Geir Landrö |
274 * | |
275 * | This script can be used freely as long as all |
276 * | copyright messages are intact. |
277 * | |
278 * | Updated: 17.04.2003 |
279 * |---------------------------------------------------|
280 **/
281//-->
282</script>
283<div class="sqm_leftMain">
b71975ad 284<?php if (!empty($plugin_output['left_main_before'])) echo $plugin_output['left_main_before']; ?>
93222bea 285<div class="dtree">
286<table class="sqm_wrapperTable" cellspacing="0">
287 <tr>
288 <td>
289 <table cellspacing="0">
290 <tr>
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>
f99c4469 294 <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>
93222bea 295 </td>
296 </tr>
297 </table>
298 </td>
299 </tr>
300</table>
301<p>
f99c4469 302<a href="javascript:mailboxes.openAll()"><?php echo _("Open All") ?></a>
93222bea 303&nbsp;&nbsp;|&nbsp;&nbsp;
f99c4469 304<a href="javascript:mailboxes.closeAll()"><?php echo _("Close All") ?></a>
93222bea 305<?php
306if ($settings['messageRecyclingEnabled']) {
307 echo '<br />';
ce102fcc 308 echo '<a href="empty_trash.php?smtoken=' . sm_generate_security_token() . '"';
f99c4469 309 if ($accesskey_folders_purge_trash != 'NONE')
310 echo ' accesskey="' . $accesskey_folders_purge_trash . '"';
311 echo '>' . _("Purge Trash") . '</a>';
93222bea 312}
313?>
314</p>
315<script type="text/javascript">
316<!--
34446790 317<?php echo buildMailboxTree($mailboxes, $settings, $icon_theme_path); ?>
93222bea 318-->
319</script>
320</div>
34446790 321<?php if (!empty($plugin_output['left_main_after'])) echo $plugin_output['left_main_after']; ?>
4f5c9970 322</div>