added new hook info to docs
[squirrelmail.git] / src / right_main.php
CommitLineData
59177427 1<?php
21c3249f 2 /**
a09387f4 3 ** right_main.php
21c3249f 4 **
3bcede49 5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
21c3249f 8 ** This is where the mailboxes are listed. This controls most of what
9 ** goes on in SquirrelMail.
10 **
11 **/
12
441f2d33 13 if (!isset($i18n_php))
14 include("../functions/i18n.php");
dc54c9f2 15
2a32fc83 16 session_start();
17
10455998 18 if(!isset($logged_in) || !isset($username) || !isset($key)) {
19 include ("../themes/default_theme.php");
20 include ("../functions/display_messages.php");
21 printf('<html><BODY TEXT="%s" BGCOLOR="%s" LINK="%s" VLINK="%s" ALINK="%s">',
22 $color[8], $color[4], $color[7], $color[7], $color[7]);
23 plain_error_message(_("You need a valid user and password to access this page!")
24 . "<br><a href=\"../src/login.php\">"
25 . _("Click here to log back in.") . "</a>.", $color);
26 echo "</body></html>";
21c3249f 27 exit;
28 }
44139266 29
d068c0ec 30 if (!isset($config_php))
31 include("../config/config.php");
32 if (!isset($imap_php))
33 include("../functions/imap.php");
34 if (!isset($strings_php))
35 include("../functions/strings.php");
36 if (!isset($date_php))
37 include("../functions/date.php");
38 if (!isset($page_header_php))
39 include("../functions/page_header.php");
40 if (!isset($array_php))
41 include("../functions/array.php");
42 if (!isset($mime_php))
43 include("../functions/mime.php");
44 if (!isset($mailbox_display_php))
45 include("../functions/mailbox_display.php");
46 if (!isset($display_messages_php))
47 include("../functions/display_messages.php");
44139266 48?>
59177427 49<?php
21c3249f 50 /////////////////////////////////////////////////////////////////////////////////
51 //
52 // incoming variables from URL:
53 // $sort Direction to sort by date
54 // values: 0 - descending order
55 // values: 1 - ascending order
56 // $startMessage Message to start at
57 // $mailbox Full Mailbox name
58 //
59 // incoming from cookie:
60 // $username duh
61 // $key pass
62 //
63 /////////////////////////////////////////////////////////////////////////////////
64
21c3249f 65 // open a connection on the imap port (143)
e1469126 66 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
21c3249f 67
f3d17401 68 /** If it was a successful login, lets load their preferences **/
69 include("../src/load_prefs.php");
f3d17401 70
5c54e435 71 if (isset($newsort) && $newsort != $sort) {
72 setPref($data_dir, $username, "sort", $newsort);
73 }
74
21c3249f 75 // If the page has been loaded without a specific mailbox,
a48fbf9b 76 // send them to the inbox
21c3249f 77 if (!isset($mailbox)) {
e9f8ea4e 78 $mailbox = "INBOX";
e9f8ea4e 79 $startMessage = 1;
21c3249f 80 }
81
813eba2f 82 sqimap_mailbox_select($imapConnection, $mailbox);
f8f9bed9 83 displayPageHeader($color, $mailbox);
21c3249f 84
06ad27a2 85 do_hook("right_main_after_header");
86
a37f3771 87 if ($just_logged_in == 1 && strlen(trim($motd)) > 0) {
04632dbc 88 echo "<center><br>\n";
89 echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n";
90 echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n";
91 echo "$motd\n";
92 echo "</td></tr></table>\n";
93 echo "</td></tr></table>\n";
94 echo "</center><br>\n";
a37f3771 95 }
96
e452ce9b 97 if (isset($newsort)) {
98 $sort = $newsort;
99 session_register("sort");
100 }
101
9f2215a1 102 // Check to see if we can use cache or not. Currently the only time when you wont use it is
103 // when a link on the left hand frame is used. Also check to make sure we actually have the
104 // array in the registered session data. :)
90033b64 105 if ($use_mailbox_cache && session_is_registered("msgs")) {
dc54c9f2 106 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 107 } else {
108 if (session_is_registered("msgs"))
109 unset($msgs);
dc54c9f2 110 if (session_is_registered("msort"))
111 unset($msort);
1108e8bb 112 if (session_is_registered("numMessages"))
113 unset($numMessages);
114
115 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
9f2215a1 116
dc54c9f2 117 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 118
119 if (session_is_registered("msgs") && isset($msgs))
120 session_register("msgs");
dc54c9f2 121 if (session_is_registered("msort") && isset($msort))
122 session_register("msort");
1108e8bb 123 session_register("numMessages");
90033b64 124 }
21c3249f 125
06ad27a2 126 do_hook("right_main_bottom");
813eba2f 127 sqimap_logout ($imapConnection);
21c3249f 128?>
129</FONT>
130</BODY>
131</HTML>