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 | * |
70 | * @copyright © 1999-2006 The SquirrelMail Project Team |
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 | |
a9527551 |
78 | /** include required files */ |
93222bea |
79 | include_once(SM_PATH . 'templates/util_global.php'); |
80 | |
81 | /* |
82 | * Recursively parse the mailbox structure to build the navigation tree. |
83 | * |
84 | * @param array $box Array containing mailbox data |
85 | * @param array $settings Array containing perferences, etc, passed to template |
34446790 |
86 | * @param string $icon_theme_path |
93222bea |
87 | * @param integer $indent_factor Counter used to control indent spacing |
88 | * @since 1.5.2 |
89 | * @author Steve Brown |
90 | */ |
34446790 |
91 | function buildMailboxTree ($box, $settings, $icon_theme_path, $parent_node=-1) { |
93222bea |
92 | static $counter; |
93 | |
94 | // stop condition |
95 | if (empty($box)) { |
96 | return ''; |
97 | } |
98 | |
93222bea |
99 | $out = ''; |
34446790 |
100 | if ($box['IsRoot']) { |
93222bea |
101 | // Determine the path to the correct images |
34446790 |
102 | $out .= 'mailboxes = new dTree("mailboxes", "'.$icon_theme_path.'");'."\n"; |
93222bea |
103 | $out .= 'mailboxes.config.inOrder = true;'."\n"; |
104 | $counter = -1; |
105 | } else { |
106 | $counter++; |
107 | $name = $box['MailboxName']; |
108 | $pre = '<span style="white-space: nowrap;">'; |
109 | $end = ''; |
110 | |
111 | // Get unseeen/total message info if needed |
112 | $unseen_str = ''; |
113 | if ($settings['unreadNotificationEnabled']) { |
114 | // We only display the unread count if we on the Inbox or we are told |
115 | // to display it on all folders AND there is more than 1 unread message |
116 | if ( $settings['unreadNotificationAllFolders'] || |
117 | (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox') |
118 | ) { |
119 | $unseen = $settings['unreadNotificationCummulative'] ? |
120 | $box['CummulativeUnreadCount'] : |
121 | $box['UnreadCount']; |
122 | |
b04d1537 |
123 | if (!$box['IsNoSelect'] && ($unseen > 0 || $settings['unreadNotificationDisplayTotal'])) { |
93222bea |
124 | $unseen_str = $unseen; |
125 | |
126 | // Add the total messages if desired |
127 | if ($settings['unreadNotificationDisplayTotal']) { |
128 | $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ? |
129 | $box['CummulativeMessageCount'] : |
130 | $box['MessageCount']); |
131 | } |
132 | |
133 | $unseen_str = '<span class="'. |
134 | ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') . |
135 | '">' . $unseen_str . |
136 | '</span>'; |
137 | } |
138 | } |
139 | } |
140 | |
141 | /** |
142 | * Add folder icon. |
143 | */ |
144 | $img = ''; |
145 | $img_open = ''; |
146 | switch (true) { |
147 | case $box['IsInbox']: |
34446790 |
148 | $img = 'base.png'; |
149 | $img_open = 'base.png'; |
93222bea |
150 | break; |
151 | case $box['IsTrash']: |
34446790 |
152 | $img = 'trash.png'; |
153 | $img_open = 'trash.png'; |
93222bea |
154 | break; |
155 | case $box['IsNoSelect']: |
156 | case $box['IsNoInferiors']: |
34446790 |
157 | $img = 'page.png'; |
158 | $img_open = 'page.png'; |
93222bea |
159 | break; |
160 | default: |
34446790 |
161 | $img = 'folder.png'; |
162 | $img_open = 'folderopen.png'; |
93222bea |
163 | break; |
164 | } |
165 | |
166 | $display_folder = true; |
167 | if (!$settings['messageRecyclingEnabled'] && $box['IsTrash']) { |
168 | $display_folder = false; |
169 | } |
170 | |
171 | if($settings['messageRecyclingEnabled'] && $box['IsTrash']) { |
172 | // Boxes with unread messages should be emphasized |
173 | if ($box['UnreadCount'] > 0) { |
174 | $pre .= '<em>'; |
175 | $end .= '</em>'; |
176 | } |
177 | |
178 | // Print unread info |
179 | if ($box['UnreadCount'] > 0) { |
180 | if (!empty($unseen_str)) { |
181 | $end .= ' <small>('.$unseen_str.')</small>'; |
182 | } |
183 | } |
184 | } else { |
185 | // Add a few other things for all other folders... |
186 | if (!$box['IsNoSelect']) { |
187 | // Boxes with unread messages should be emphasized |
188 | if ($box['UnreadCount'] > 0) { |
189 | $pre .= '<em>'; |
190 | $end .= '</em>'; |
191 | } |
192 | } |
193 | |
194 | // Display unread info... |
195 | if (!empty($unseen_str)) { |
196 | $end .= ' <small>('.$unseen_str.')</small>'; |
197 | } |
198 | } |
199 | |
200 | $span = ''; |
201 | $spanend = ''; |
202 | if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) { |
203 | $span = '<span class="leftspecial">'; |
204 | $spanend = '</span>'; |
205 | } elseif ( $box['IsNoSelect'] ) { |
206 | $span = '<span class="leftnoselect">'; |
207 | $spanend = '</span>'; |
208 | } |
209 | |
210 | /** |
211 | * NOTE: Plugins would horribly break this advanced tree, so we are |
212 | * going to skip that part altogether. |
213 | */ |
214 | |
215 | $name = str_replace( |
216 | array(' ','<','>'), |
217 | array(' ','<','>'), |
218 | $box['MailboxName']); |
219 | $title = $name; |
220 | |
221 | if ($box['IsNoSelect']) { |
222 | $url = ''; |
223 | $target = ''; |
224 | } else { |
225 | $url = $box['ViewLink']['URL']; |
226 | $target = $box['ViewLink']['Target']; |
227 | $name = $span . $pre . $name . $end . $spanend; |
228 | } |
229 | |
230 | if ($display_folder) { |
231 | $out .= 'mailboxes.add('.$counter.', '.$parent_node.', ' . |
232 | '"'.addslashes($name).'", "'.$url.'", "'.$title.'", ' . |
233 | '"'.$target.'", ' . |
34446790 |
234 | '"'.getIconPath($icon_theme_path, $img).'", ' . |
235 | '"'.getIconPath($icon_theme_path, $img_open).'"' . |
93222bea |
236 | ');'."\n"; |
237 | } |
238 | } |
239 | |
240 | $parent_node = $counter; |
241 | for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) { |
34446790 |
242 | $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $icon_theme_path, $parent_node); |
93222bea |
243 | } |
244 | |
245 | if ($box['IsRoot']) { |
246 | $out .= 'document.write(mailboxes);'."\n"; |
247 | } |
248 | |
249 | return $out; |
250 | } |
251 | |
252 | /* retrieve the template vars */ |
253 | extract($t); |
254 | |
255 | ?> |
256 | <body class="sqm_leftMain"> |
257 | <script type="text/javascript"> |
258 | <!-- |
259 | /** |
260 | * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily. |
261 | * See http://www.destroydrop.com/javascripts/tree/ |
262 | * |
263 | * |---------------------------------------------------| |
264 | * | dTree 2.05 | www.destroydrop.com/javascript/tree/ | |
265 | * |---------------------------------------------------| |
266 | * | Copyright (c) 2002-2003 Geir Landrö | |
267 | * | | |
268 | * | This script can be used freely as long as all | |
269 | * | copyright messages are intact. | |
270 | * | | |
271 | * | Updated: 17.04.2003 | |
272 | * |---------------------------------------------------| |
273 | **/ |
274 | //--> |
275 | </script> |
276 | <div class="sqm_leftMain"> |
277 | <?php do_hook('left_main_before'); ?> |
278 | <div class="dtree"> |
279 | <table class="sqm_wrapperTable" cellspacing="0"> |
280 | <tr> |
281 | <td> |
282 | <table cellspacing="0"> |
283 | <tr> |
284 | <td style="text-align:center"> |
285 | <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br /> |
286 | <span class="sqm_clock"><?php echo $clock; ?></span> |
287 | <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span> |
288 | </td> |
289 | </tr> |
290 | </table> |
291 | </td> |
292 | </tr> |
293 | </table> |
294 | <p> |
295 | <a href="javascript:mailboxes.openAll()">Open All</a> |
296 | | |
297 | <a href="javascript:mailboxes.closeAll()">Close All</a> |
298 | <?php |
299 | if ($settings['messageRecyclingEnabled']) { |
300 | echo '<br />'; |
301 | echo '<a href="empty_trash.php">Purge Trash</a>'; |
302 | } |
303 | ?> |
304 | </p> |
305 | <script type="text/javascript"> |
306 | <!-- |
34446790 |
307 | <?php echo buildMailboxTree($mailboxes, $settings, $icon_theme_path); ?> |
93222bea |
308 | --> |
309 | </script> |
310 | </div> |
34446790 |
311 | <?php if (!empty($plugin_output['left_main_after'])) echo $plugin_output['left_main_after']; ?> |
4f5c9970 |
312 | </div> |