Explicitly disable caching for left_main and right_main pages (#2983134)
[squirrelmail.git] / src / left_main.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * left_main.php
5 *
35586184 6 * This is the code for the left bar. The left bar shows the folders
7 * available, and has cookie information.
8 *
1977ab55 9 * @copyright 1999-2010 The SquirrelMail Project Team
4b4abf93 10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
30967a1e 11 * @version $Id$
8f6f9ba5 12 * @package squirrelmail
1c52ba77 13 */
35586184 14
ebd2391c 15/** This is the left_main page */
16define('PAGE_NAME', 'left_main');
17
99491db0 18/* Disable browser caching */
19header('Cache-Control: no-cache, no-store, must-revalidate');
20header('Pragma: no-cache');
21header('Expires: ' . gmdate(DATE_RFC1123, time()-1));
22
30967a1e 23/**
202bcbcc 24 * Include the SquirrelMail initialization file.
30967a1e 25 */
202bcbcc 26require('../include/init.php');
86725763 27
28/* SquirrelMail required files. */
202bcbcc 29require_once(SM_PATH . 'functions/imap_general.php');
b6d26135 30require_once(SM_PATH . 'functions/date.php');
a9cce2ae 31require_once(SM_PATH . 'functions/template/folder_list_util.php');
29997535 32
95e93571 33/* These constants are used for folder stuff. */
34define('SM_BOX_UNCOLLAPSED', 0);
35define('SM_BOX_COLLAPSED', 1);
a6d2e0de 36
f38b7cf0 37/* get globals */
f38b7cf0 38sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
a32985a5 39
f38b7cf0 40sqgetGlobalVar('fold', $fold, SQ_GET);
41sqgetGlobalVar('unfold', $unfold, SQ_GET);
f38b7cf0 42/* end globals */
95e93571 43
44// open a connection on the imap port (143)
3cbf882e 45// why hide the output?
906f7e9f 46$imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, true);
95e93571 47
f43c35f8 48/**
3cbf882e 49 * Using stristr since very old preferences may contain "None" and "none".
f43c35f8 50 */
3cbf882e 51if (!empty($left_refresh) &&
d68323ff 52 !stristr($left_refresh, 'none')){
99491db0 53 $xtra = "\n<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
95e93571 54} else {
55 $xtra = '';
56}
57
f23f6a3a 58/**
6373ad12 59 * Include extra javascript files needed by template
60 */
3e6ee6ca 61$js_includes = $oTemplate->get_javascript_includes(TRUE);
6373ad12 62foreach ($js_includes as $js_file) {
63 $xtra .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
ccc4580f 64}
202bcbcc 65
a462b928 66// get mailbox list and cache it
67$mailboxes=sqimap_get_mailboxes($imapConnection,false,$show_only_subscribed_folders);
68
2c576f57 69displayHtmlHeader( $org_title, $xtra );
b087d199 70$oErrorHandler->setDelayedErrors(true);
a462b928 71
852abae7 72sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION);
95e93571 73/* If requested and not yet complete, attempt to autocreate folders. */
74if ($auto_create_special && !isset($auto_create_done)) {
a3439b27 75 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
3bf08e48 76 $folders_created = false;
95e93571 77 foreach( $autocreate as $folder ) {
fc8be6ae 78 if ($folder != '' && $folder != SMPREF_NONE) {
d388a958 79 /**
80 * If $show_only_subscribed_folders is true, don't use
81 * $mailboxes array for checking if mailbox exists.
82 * Mailbox list contains only subscribed folders.
83 * sqimap_mailbox_create() will fail, if folder exists.
84 */
85 if ($show_only_subscribed_folders) {
86 $mailbox_cache = false;
87 } else {
88 $mailbox_cache = $mailboxes;
89 }
90 if ( !sqimap_mailbox_exists($imapConnection, $folder, $mailbox_cache)) {
95e93571 91 sqimap_mailbox_create($imapConnection, $folder, '');
3bf08e48 92 $folders_created = true;
852abae7 93 } else {
7b1f03c9 94 // check for subscription is useless and expensive, just
95 // surpress the NO response. Unless we're on Mecury, which
96 // will just subscribe a folder again if it's already
97 // subscribed.
98 if ( strtolower($imap_server_type) != 'mercury32' ||
99 !sqimap_mailbox_is_subscribed($imapConnection, $folder) ) {
100 sqimap_subscribe($imapConnection, $folder, false);
3bf08e48 101 $folders_created = true;
7b1f03c9 102 }
2d367c68 103 }
ebf18afa 104 }
2d367c68 105 }
a6d2e0de 106
95e93571 107 /* Let the world know that autocreation is complete! Hurrah! */
90de1755 108 $auto_create_done = TRUE;
a32985a5 109 sqsession_register($auto_create_done, 'auto_create_done');
3bf08e48 110 // reload mailbox list
111 if ($folders_created)
112 $mailboxes=sqimap_get_mailboxes($imapConnection,true,$show_only_subscribed_folders);
95e93571 113}
dcc1cc82 114
29997535 115$clock = '';
95e93571 116if ($date_format != 6) {
117 /* First, display the clock. */
118 if ($hour_format == 1) {
3208c2a5 119 $hr = 'H:i';
95e93571 120 if ($date_format == 4) {
121 $hr .= ':s';
a6d2e0de 122 }
95e93571 123 } else {
124 if ($date_format == 4) {
125 $hr = 'g:i:s a';
126 } else {
127 $hr = 'g:i a';
2d367c68 128 }
129 }
130
95e93571 131 switch( $date_format ) {
e4f5158a 132 case 0:
134e4174 133 $clk = date('Y-m-d '.$hr. ' T', time());
134 break;
95e93571 135 case 1:
136 $clk = date('m/d/y '.$hr, time());
137 break;
138 case 2:
139 $clk = date('d/m/y '.$hr, time());
140 break;
141 case 4:
142 case 5:
143 $clk = date($hr, time());
144 break;
145 default:
67eb95d7 146 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
2d367c68 147 }
95e93571 148 $clk = str_replace(' ','&nbsp;',$clk);
149
5edfad3d 150//FIXME don't build HTML here - do it in template
29997535 151 $clock = '<small><span style="white-space: nowrap;">'
f8a1ed5a 152 . str_replace(' ', '&nbsp;', _("Last Refresh"))
3cbf882e 153 . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n";
95e93571 154}
155
95e93571 156if ( $collapse_folders ) {
157 /* If directed, collapse or uncollapse a folder. */
158 if (isset($fold)) {
159 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED);
160 } else if (isset($unfold)) {
161 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED);
162 }
163}
164
c5a52f46 165/* Get unseen/total display prefs */
166$unseen_type = getPref( $data_dir , $username , 'unseen_type' );
167$unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
168
3cbf882e 169if (empty($unseen_type)) {
170 if (!empty($default_unseen_type)) {
c5a52f46 171 $unseen_type = $default_unseen_type;
172 } else {
173 $unseen_type = 1;
174 }
175}
176
3cbf882e 177if (empty($unseen_notify)) {
178 if (!empty($default_unseen_notify)) {
c5a52f46 179 $unseen_notify = $default_unseen_notify;
180 } else {
181 $unseen_notify = 0;
182 }
183}
29997535 184
a462b928 185/**
186 * pass $mailboxes now instead of $imapconnection - sqimap_get_mailboxes() has been separated from
187 * sqimap_mailbox_tree() so that the cached mailbox list can be used elsewhere in left_main and beyond
188 */
189$boxes = sqimap_mailbox_tree($imapConnection,$mailboxes,$show_only_subscribed_folders);
29997535 190$mailbox_structure = getBoxStructure($boxes);
191
192$oTemplate->assign('clock', $clock);
29997535 193$oTemplate->assign('mailboxes', $mailbox_structure);
29997535 194
6373ad12 195/*
196 * Build an array to pass user prefs to the template in order to avoid using
197 * globals, which are dirty, filthy things in templates. :)
198 */
199$settings = array();
535ca371 200#$settings['imapConnection'] = $imapConnection;
3e6ee6ca 201$settings['templateID'] = $sTemplateID;
6373ad12 202$settings['unreadNotificationEnabled'] = $unseen_notify!=1;
203$settings['unreadNotificationAllFolders'] = $unseen_notify == 3;
204$settings['unreadNotificationDisplayTotal'] = $unseen_type == 2;
205$settings['unreadNotificationCummulative'] = $unseen_cum==1;
206$settings['useSpecialFolderColor'] = $use_special_folder_color;
207$settings['messageRecyclingEnabled'] = $move_to_trash;
208$settings['collapsableFoldersEnabled'] = $collapse_folders==1;
209$oTemplate->assign('settings', $settings);
210
f99c4469 211//access keys
212//
213$oTemplate->assign('accesskey_folders_refresh', $accesskey_folders_refresh);
214$oTemplate->assign('accesskey_folders_purge_trash', $accesskey_folders_purge_trash);
215$oTemplate->assign('accesskey_folders_inbox', $accesskey_folders_inbox);
216
6373ad12 217$oTemplate->display('left_main.tpl');
dcc1cc82 218
29997535 219sqimap_logout($imapConnection);
5c4ff7bf 220$oTemplate->display('footer.tpl');