13eb9055d4900f5a5b2b063e9708e6392947786e
6 * This is the code for the left bar. The left bar shows the folders
7 * available, and has cookie information.
9 * @copyright © 1999-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
16 * Path for SquirrelMail required files.
19 define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 include_once(SM_PATH
. 'include/validate.php');
23 require_once(SM_PATH
. 'functions/imap.php');
24 require_once(SM_PATH
. 'functions/plugin.php');
25 require_once(SM_PATH
. 'functions/page_header.php');
26 require_once(SM_PATH
. 'functions/html.php');
27 require_once(SM_PATH
. 'functions/date.php');
29 /** add required includes */
30 include_once(SM_PATH
. 'templates/util_global.php');
31 include_once(SM_PATH
. 'templates/util_left_main.php');
33 /* These constants are used for folder stuff. */
34 define('SM_BOX_UNCOLLAPSED', 0);
35 define('SM_BOX_COLLAPSED', 1);
38 sqgetGlobalVar('username', $username, SQ_SESSION
);
39 sqgetGlobalVar('key', $key, SQ_COOKIE
);
40 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
41 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
43 sqgetGlobalVar('fold', $fold, SQ_GET
);
44 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
47 // open a connection on the imap port (143)
48 // why hide the output?
49 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, true);
52 * Using stristr since very old preferences may contain "None" and "none".
54 if (!empty($left_refresh) &&
55 !stristr($left_refresh, 'none')){
56 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
57 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
58 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
64 * Include extra javascript files needed by template
66 $js_includes = $oTemplate->getJavascriptIncludes();
67 foreach ($js_includes as $js_file) {
68 $xtra .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
71 // get mailbox list and cache it
72 $mailboxes=sqimap_get_mailboxes($imapConnection,false,$show_only_subscribed_folders);
74 displayHtmlHeader( 'SquirrelMail', $xtra );
76 sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION
);
77 /* If requested and not yet complete, attempt to autocreate folders. */
78 if ($auto_create_special && !isset($auto_create_done)) {
79 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
80 $folders_created = false;
81 foreach( $autocreate as $folder ) {
82 if (($folder != '') && ($folder != 'none')) {
83 // use $mailboxes array for checking if mailbox exists
84 if ( !sqimap_mailbox_exists($imapConnection, $folder, $mailboxes)) {
85 sqimap_mailbox_create($imapConnection, $folder, '');
86 $folders_created = true;
88 // check for subscription is useless and expensive, just
89 // surpress the NO response. Unless we're on Mecury, which
90 // will just subscribe a folder again if it's already
92 if ( strtolower($imap_server_type) != 'mercury32' ||
93 !sqimap_mailbox_is_subscribed($imapConnection, $folder) ) {
94 sqimap_subscribe($imapConnection, $folder, false);
95 $folders_created = true;
101 /* Let the world know that autocreation is complete! Hurrah! */
102 $auto_create_done = TRUE;
103 sqsession_register($auto_create_done, 'auto_create_done');
104 // reload mailbox list
105 if ($folders_created)
106 $mailboxes=sqimap_get_mailboxes($imapConnection,true,$show_only_subscribed_folders);
110 if ($date_format != 6) {
111 /* First, display the clock. */
112 if ($hour_format == 1) {
114 if ($date_format == 4) {
118 if ($date_format == 4) {
125 switch( $date_format ) {
127 $clk = date('Y-m-d '.$hr. ' T', time());
130 $clk = date('m/d/y '.$hr, time());
133 $clk = date('d/m/y '.$hr, time());
137 $clk = date($hr, time());
140 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
142 $clk = str_replace(' ',' ',$clk);
144 $clock = '<small><span style="white-space: nowrap;">'
145 . str_replace(' ', ' ', _("Last Refresh"))
146 . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n";
149 if ( $collapse_folders ) {
150 /* If directed, collapse or uncollapse a folder. */
152 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
153 } else if (isset($unfold)) {
154 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
158 /* Get unseen/total display prefs */
159 $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
160 $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
162 if (empty($unseen_type)) {
163 if (!empty($default_unseen_type)) {
164 $unseen_type = $default_unseen_type;
170 if (empty($unseen_notify)) {
171 if (!empty($default_unseen_notify)) {
172 $unseen_notify = $default_unseen_notify;
179 * pass $mailboxes now instead of $imapconnection - sqimap_get_mailboxes() has been separated from
180 * sqimap_mailbox_tree() so that the cached mailbox list can be used elsewhere in left_main and beyond
182 $boxes = sqimap_mailbox_tree($imapConnection,$mailboxes,$show_only_subscribed_folders);
183 $mailbox_structure = getBoxStructure($boxes);
185 $oTemplate->assign('clock', $clock);
186 $oTemplate->assign('mailboxes', $mailbox_structure);
189 * Build an array to pass user prefs to the template in order to avoid using
190 * globals, which are dirty, filthy things in templates. :)
193 $settings['imapConnection'] = $imapConnection;
194 $settings['iconThemePath'] = $icon_theme_path;
195 $settings['templateDirectory'] = $sTplDir;
196 $settings['unreadNotificationEnabled'] = $unseen_notify!=1;
197 $settings['unreadNotificationAllFolders'] = $unseen_notify == 3;
198 $settings['unreadNotificationDisplayTotal'] = $unseen_type == 2;
199 $settings['unreadNotificationCummulative'] = $unseen_cum==1;
200 $settings['useSpecialFolderColor'] = $use_special_folder_color;
201 $settings['messageRecyclingEnabled'] = $move_to_trash;
202 $settings['collapsableFoldersEnabled'] = $collapse_folders==1;
203 $oTemplate->assign('settings', $settings);
205 $oTemplate->display('left_main.tpl');
207 sqimap_logout($imapConnection);
208 $oTemplate->display('footer.tpl');