moving Del/prev lnks around - addded border.
[squirrelmail.git] / src / right_main.php
... / ...
CommitLineData
1<?php
2
3/**
4 * right_main.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
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$
13 * @package squirrelmail
14 */
15
16/** Path for SquirrelMail required files. */
17define('SM_PATH','../');
18
19/* SquirrelMail required files. */
20require_once(SM_PATH . 'include/validate.php');
21require_once(SM_PATH . 'functions/global.php');
22require_once(SM_PATH . 'functions/imap.php');
23require_once(SM_PATH . 'functions/date.php');
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');
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: *
38 * $key pass *
39 * incoming from session: *
40 * $username duh *
41 * *
42 ***********************************************************/
43
44
45/* lets get the global vars we may need */
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);
54sqgetGlobalVar('numMessages' , $numMessages, SQ_SESSION);
55sqgetGlobalVar('session', $session, SQ_GET);
56sqgetGlobalVar('note', $note, SQ_GET);
57sqgetGlobalVar('mail_sent', $mail_sent, SQ_GET);
58sqgetGlobalVar('use_mailbox_cache', $use_mailbox_cache, SQ_GET);
59
60if ( sqgetGlobalVar('startMessage', $temp) ) {
61 $startMessage = (int) $temp;
62}
63if ( sqgetGlobalVar('PG_SHOWNUM', $temp) ) {
64 $PG_SHOWNUM = (int) $temp;
65}
66if ( sqgetGlobalVar('PG_SHOWALL', $temp, SQ_GET) ) {
67 $PG_SHOWALL = (int) $temp;
68}
69if ( sqgetGlobalVar('newsort', $temp, SQ_GET) ) {
70 $newsort = (int) $temp;
71}
72if ( sqgetGlobalVar('checkall', $temp, SQ_GET) ) {
73 $checkall = (int) $temp;
74}
75if ( sqgetGlobalVar('set_thread', $temp, SQ_GET) ) {
76 $set_thread = (int) $temp;
77}
78if ( !sqgetGlobalVar('composenew', $composenew, SQ_GET) ) {
79 $composenew = false;
80}
81/* end of get globals */
82
83
84/* Open a connection on the imap port (143) */
85
86$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
87
88if (isset($PG_SHOWALL)) {
89 if ($PG_SHOWALL) {
90 $PG_SHOWNUM=999999;
91 $show_num=$PG_SHOWNUM;
92 sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM');
93 }
94 else {
95 sqsession_unregister('PG_SHOWNUM');
96 unset($PG_SHOWNUM);
97 }
98}
99else if( isset( $PG_SHOWNUM ) ) {
100 $show_num = $PG_SHOWNUM;
101}
102
103if (isset($newsort) && $newsort != $sort) {
104 setPref($data_dir, $username, 'sort', $newsort);
105}
106
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
127/* decide if we are thread sorting or not */
128if ($allow_thread_sort == TRUE) {
129 if (isset($set_thread)) {
130 if ($set_thread == 1) {
131 setPref($data_dir, $username, "thread_$mailbox", 1);
132 $thread_sort_messages = '1';
133 }
134 elseif ($set_thread == 2) {
135 setPref($data_dir, $username, "thread_$mailbox", 0);
136 $thread_sort_messages = '0';
137 }
138 }
139 else {
140 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
141 }
142}
143else {
144 $thread_sort_messages = 0;
145}
146
147do_hook ('generic_header');
148
149sqimap_mailbox_select($imapConnection, $mailbox);
150
151if ($composenew) {
152 $comp_uri = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox).
153 "&session=$session";
154 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
155} else {
156 displayPageHeader($color, $mailbox);
157}
158do_hook('right_main_after_header');
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}
164if (isset($note)) {
165 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
166}
167
168if ( sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION) ) {
169 if ($just_logged_in == true) {
170 $just_logged_in = false;
171 sqsession_register($just_logged_in, 'just_logged_in');
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 }
186 }
187}
188
189if (isset($newsort)) {
190 $sort = $newsort;
191 sqsession_register($sort, 'sort');
192}
193
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
204if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
205 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
206} else {
207 if (sqsession_is_registered('msgs')) {
208 unset($msgs);
209 }
210
211 if (sqsession_is_registered('msort')) {
212 unset($msort);
213 }
214
215 if (sqsession_is_registered('numMessages')) {
216 unset($numMessages);
217 }
218
219 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
220
221 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
222 $startMessage, $sort, $color, $show_num,
223 $use_mailbox_cache);
224
225 if (sqsession_is_registered('msgs') && isset($msgs)) {
226 sqsession_register($msgs, 'msgs');
227 //$_SESSION['msgs'] = $msgs;
228 }
229
230 if (sqsession_is_registered('msort') && isset($msort)) {
231 sqsession_register($msort, 'msort');
232 //$_SESSION['msort'] = $msort;
233 }
234
235 sqsession_register($numMessages, 'numMessages');
236 //$_SESSION['numMessages'] = $numMessages;
237}
238do_hook('right_main_bottom');
239sqimap_logout ($imapConnection);
240
241echo '</body></html>';
242
243?>