If admin has set in config_local.php, then use that. (For LDAP Preferences plugin)
[squirrelmail.git] / src / right_main.php
CommitLineData
59177427 1<?php
895905c0 2
c57b0888 3/**
4 * right_main.php
5 *
76911253 6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
c57b0888 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This is where the mailboxes are listed. This controls most of what
10 * goes on in SquirrelMail.
11 *
12 * $Id$
8f6f9ba5 13 * @package squirrelmail
c57b0888 14 */
15
8f6f9ba5 16/** Path for SquirrelMail required files. */
86725763 17define('SM_PATH','../');
18
19/* SquirrelMail required files. */
08185f2a 20require_once(SM_PATH . 'include/validate.php');
8650e9e1 21require_once(SM_PATH . 'functions/global.php');
86725763 22require_once(SM_PATH . 'functions/imap.php');
23require_once(SM_PATH . 'functions/date.php');
86725763 24require_once(SM_PATH . 'functions/mime.php');
25require_once(SM_PATH . 'functions/mailbox_display.php');
26require_once(SM_PATH . 'functions/display_messages.php');
27require_once(SM_PATH . 'functions/html.php');
c57b0888 28
29/***********************************************************
30 * incoming variables from URL: *
31 * $sort Direction to sort by date *
32 * values: 0 - descending order *
33 * values: 1 - ascending order *
34 * $startMessage Message to start at *
35 * $mailbox Full Mailbox name *
36 * *
37 * incoming from cookie: *
c57b0888 38 * $key pass *
a32985a5 39 * incoming from session: *
40 * $username duh *
41 * *
c57b0888 42 ***********************************************************/
43
a32985a5 44
45/* lets get the global vars we may need */
1e12d1ff 46sqgetGlobalVar('key', $key, SQ_COOKIE);
47sqgetGlobalVar('username', $username, SQ_SESSION);
48sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
49sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
50sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
51
52sqgetGlobalVar('mailbox', $mailbox);
53sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION);
d7048dd4 54sqgetGlobalVar('numMessages' , $numMessages, SQ_SESSION);
1e12d1ff 55sqgetGlobalVar('session', $session, SQ_GET);
56sqgetGlobalVar('note', $note, SQ_GET);
2ffeb7c5 57sqgetGlobalVar('mail_sent', $mail_sent, SQ_GET);
d7048dd4 58sqgetGlobalVar('use_mailbox_cache', $use_mailbox_cache, SQ_GET);
1e12d1ff 59
60if ( sqgetGlobalVar('startMessage', $temp) ) {
61 $startMessage = (int) $temp;
a32985a5 62}
1e12d1ff 63if ( sqgetGlobalVar('PG_SHOWNUM', $temp) ) {
64 $PG_SHOWNUM = (int) $temp;
a32985a5 65}
1e12d1ff 66if ( sqgetGlobalVar('PG_SHOWALL', $temp, SQ_GET) ) {
67 $PG_SHOWALL = (int) $temp;
a32985a5 68}
1e12d1ff 69if ( sqgetGlobalVar('newsort', $temp, SQ_GET) ) {
70 $newsort = (int) $temp;
a32985a5 71}
1e12d1ff 72if ( sqgetGlobalVar('checkall', $temp, SQ_GET) ) {
73 $checkall = (int) $temp;
a32985a5 74}
1e12d1ff 75if ( sqgetGlobalVar('set_thread', $temp, SQ_GET) ) {
76 $set_thread = (int) $temp;
a32985a5 77}
1e12d1ff 78if ( !sqgetGlobalVar('composenew', $composenew, SQ_GET) ) {
8cc72ada 79 $composenew = false;
80}
a32985a5 81/* end of get globals */
82
83
c57b0888 84/* Open a connection on the imap port (143) */
6f223ace 85
c57b0888 86$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
87
cf710efe 88if (isset($PG_SHOWALL)) {
89 if ($PG_SHOWALL) {
90 $PG_SHOWNUM=999999;
91 $show_num=$PG_SHOWNUM;
a32985a5 92 sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM');
cf710efe 93 }
94 else {
a32985a5 95 sqsession_unregister('PG_SHOWNUM');
cf710efe 96 unset($PG_SHOWNUM);
97 }
98}
99else if( isset( $PG_SHOWNUM ) ) {
bdfb67f8 100 $show_num = $PG_SHOWNUM;
101}
102
c57b0888 103if (isset($newsort) && $newsort != $sort) {
104 setPref($data_dir, $username, 'sort', $newsort);
105}
106
e372ee8c 107
108
109/* If the page has been loaded without a specific mailbox, */
110/* send them to the inbox */
111if (!isset($mailbox)) {
112 $mailbox = 'INBOX';
113 $startMessage = 1;
114}
115
116
117if (!isset($startMessage) || ($startMessage == '')) {
118 $startMessage = 1;
119}
120
121/* compensate for the UW vulnerability. */
122if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
123 substr($mailbox, 0, 1) == '/')) {
124 $mailbox = 'INBOX';
125}
126
7c612fdd 127/* decide if we are thread sorting or not */
794d59c0 128if ($allow_thread_sort == TRUE) {
7c612fdd 129 if (isset($set_thread)) {
130 if ($set_thread == 1) {
78cc4b12 131 setPref($data_dir, $username, "thread_$mailbox", 1);
7c612fdd 132 $thread_sort_messages = '1';
133 }
134 elseif ($set_thread == 2) {
78cc4b12 135 setPref($data_dir, $username, "thread_$mailbox", 0);
7c612fdd 136 $thread_sort_messages = '0';
137 }
138 }
139 else {
78cc4b12 140 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
7c612fdd 141 }
142}
143else {
144 $thread_sort_messages = 0;
145}
146
a32985a5 147do_hook ('generic_header');
7c612fdd 148
c57b0888 149sqimap_mailbox_select($imapConnection, $mailbox);
6f223ace 150
8cc72ada 151if ($composenew) {
152 $comp_uri = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox).
0cb19b37 153 "&session=$session";
11af81b9 154 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
6f223ace 155} else {
156 displayPageHeader($color, $mailbox);
157}
c57b0888 158do_hook('right_main_after_header');
2ffeb7c5 159
160/* display a message to the user that their mail has been sent */
161if (isset($mail_sent) && $mail_sent == 'yes') {
162 $note = _("Your Message has been sent.");
163}
c57b0888 164if (isset($note)) {
fab3baa6 165 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
c57b0888 166}
167
f38b7cf0 168if ( sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION) ) {
a32985a5 169 if ($just_logged_in == true) {
170 $just_logged_in = false;
dd2a2e15 171 sqsession_register($just_logged_in, 'just_logged_in');
a32985a5 172
173 if (strlen(trim($motd)) > 0) {
174 echo html_tag( 'table',
175 html_tag( 'tr',
176 html_tag( 'td',
177 html_tag( 'table',
178 html_tag( 'tr',
179 html_tag( 'td', $motd, 'center' )
180 ) ,
181 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
182 )
183 ) ,
184 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
185 }
23d6bd09 186 }
c57b0888 187}
188
7c612fdd 189if (isset($newsort)) {
190 $sort = $newsort;
a32985a5 191 sqsession_register($sort, 'sort');
7c612fdd 192}
193
c57b0888 194/*********************************************************************
195 * Check to see if we can use cache or not. Currently the only time *
196 * when you will not use it is when a link on the left hand frame is *
197 * used. Also check to make sure we actually have the array in the *
198 * registered session data. :) *
199 *********************************************************************/
200if (! isset($use_mailbox_cache)) {
201 $use_mailbox_cache = 0;
202}
203
d7c82551 204if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
c57b0888 205 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
206} else {
d7c82551 207 if (sqsession_is_registered('msgs')) {
c57b0888 208 unset($msgs);
23d6bd09 209 }
210
d7c82551 211 if (sqsession_is_registered('msort')) {
c57b0888 212 unset($msort);
23d6bd09 213 }
a37f3771 214
d7c82551 215 if (sqsession_is_registered('numMessages')) {
c57b0888 216 unset($numMessages);
2016e645 217 }
e452ce9b 218
c57b0888 219 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
23d6bd09 220
c57b0888 221 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
222 $startMessage, $sort, $color, $show_num,
223 $use_mailbox_cache);
23d6bd09 224
d7c82551 225 if (sqsession_is_registered('msgs') && isset($msgs)) {
a32985a5 226 sqsession_register($msgs, 'msgs');
d7048dd4 227 //$_SESSION['msgs'] = $msgs;
c57b0888 228 }
1108e8bb 229
d7c82551 230 if (sqsession_is_registered('msort') && isset($msort)) {
a32985a5 231 sqsession_register($msort, 'msort');
d7048dd4 232 //$_SESSION['msort'] = $msort;
c57b0888 233 }
9f2215a1 234
a32985a5 235 sqsession_register($numMessages, 'numMessages');
d7048dd4 236 //$_SESSION['numMessages'] = $numMessages;
c57b0888 237}
c57b0888 238do_hook('right_main_bottom');
239sqimap_logout ($imapConnection);
23d6bd09 240
dcc1cc82 241echo '</body></html>';
242
243?>