New Template class implementation
[squirrelmail.git] / src / webmail.php
1 <?php
2 /**
3 * webmail.php -- Displays the main frameset
4 *
5 * This file generates the main frameset. The files that are
6 * shown can be given as parameters. If the user is not logged in
7 * this file will verify username and password.
8 *
9 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @version $Id$
12 * @package squirrelmail
13 */
14
15 /**
16 * Include the SquirrelMail initialization file.
17 */
18 require('../include/init.php');
19
20 if (sqgetGlobalVar('sort', $sort)) {
21 $sort = (int) $sort;
22 }
23
24 if (sqgetGlobalVar('startMessage', $startMessage)) {
25 $startMessage = (int) $startMessage;
26 }
27
28 if (!sqgetGlobalVar('mailbox', $mailbox)) {
29 $mailbox = 'INBOX';
30 }
31
32 sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
33
34 if(!sqgetGlobalVar('mailto', $mailto)) {
35 $mailto = '';
36 }
37
38 // Determine the size of the left frame
39 $left_size = getPref($data_dir, $username, 'left_size');
40 if ($left_size == "") {
41 if (isset($default_left_size)) {
42 $left_size = $default_left_size;
43 }
44 else {
45 $left_size = 200;
46 }
47 }
48
49 // Determine where the navigation frame should be
50 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
51 if (isset($languages[$squirrelmail_language]['DIR']) &&
52 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
53 $temp_location_of_bar = 'right';
54 } else {
55 $temp_location_of_bar = 'left';
56 }
57 if ($location_of_bar == '') {
58 $location_of_bar = $temp_location_of_bar;
59 }
60
61 // Determine the main frame URL
62 /*
63 * There are three ways to call webmail.php
64 * 1. webmail.php
65 * - This just loads the default entry screen.
66 * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
67 * - This loads the frames starting at the given values.
68 * 3. webmail.php?right_frame=folders.php
69 * - Loads the frames with the Folder options in the right frame.
70 *
71 * This was done to create a pure HTML way of refreshing the folder list since
72 * we would like to use as little Javascript as possible.
73 *
74 * The test for // should catch any attempt to include off-site webpages into
75 * our frameset.
76 */
77 if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
78 $right_frame = '';
79 }
80 if ( strpos($right_frame,'?') ) {
81 $right_frame_file = substr($right_frame,0,strpos($right_frame,'?'));
82 } else {
83 $right_frame_file = $right_frame;
84 }
85 switch($right_frame) {
86 case 'right_main.php':
87 $right_frame_url = "right_main.php?mailbox=".urlencode($mailbox)
88 . (!empty($sort)?"&amp;sort=$sort":'')
89 . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
90 break;
91 case 'options.php':
92 $right_frame_url = 'options.php';
93 break;
94 case 'folders.php':
95 $right_frame_url = 'folders.php';
96 break;
97 case 'compose.php':
98 $right_frame_url = 'compose.php?' . $mailto;
99 break;
100 case '':
101 $right_frame_url = 'right_main.php';
102 break;
103 default:
104 $right_frame_url = urlencode($right_frame);
105 break;
106 }
107
108 displayHtmlHeader($org_title, '', false, true);
109 $oErrorHandler->setDelayedErrors(true);
110
111 do_hook('webmail_top');
112
113 $oTemplate->assign('nav_size', $left_size);
114 $oTemplate->assign('nav_on_left', $location_of_bar=='left');
115 $oTemplate->assign('right_frame_url', $right_frame_url);
116
117 $oTemplate->display('webmail.tpl');
118
119 $oTemplate->display('footer.tpl');