Made the webmail_top hook work again for plugins that want to change the URI of the...
[squirrelmail.git] / src / webmail.php
CommitLineData
59177427 1<?php
864b1c33 2/**
15e6162e 3 * webmail.php -- Displays the main frameset
4 *
15e6162e 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 *
4b5049de 9 * @copyright &copy; 1999-2007 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
15e6162e 13 */
21c3249f 14
ebd2391c 15/** This is the webmail page */
16define('PAGE_NAME', 'webmail');
17
30967a1e 18/**
202bcbcc 19 * Include the SquirrelMail initialization file.
30967a1e 20 */
202bcbcc 21require('../include/init.php');
a32985a5 22
ef8d36ad 23if (sqgetGlobalVar('sort', $sort)) {
24 $sort = (int) $sort;
25}
26
27if (sqgetGlobalVar('startMessage', $startMessage)) {
28 $startMessage = (int) $startMessage;
29}
30
a2b193bc 31if (!sqgetGlobalVar('mailbox', $mailbox)) {
ef8d36ad 32 $mailbox = 'INBOX';
33}
34
f38b7cf0 35sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
36
7e2ff844 37if(!sqgetGlobalVar('mailtodata', $mailtodata)) {
38 $mailtourl = 'mailtodata='.urlencode($mailtodata);
39} else {
40 $mailtourl = '';
c67e4479 41}
a32985a5 42
a4467cd7 43// Determine the size of the left frame
44$left_size = getPref($data_dir, $username, 'left_size');
45if ($left_size == "") {
46 if (isset($default_left_size)) {
47 $left_size = $default_left_size;
48 }
49 else {
50 $left_size = 200;
51 }
52}
53
54// Determine where the navigation frame should be
55$location_of_bar = getPref($data_dir, $username, 'location_of_bar');
56if (isset($languages[$squirrelmail_language]['DIR']) &&
57 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
58 $temp_location_of_bar = 'right';
59} else {
60 $temp_location_of_bar = 'left';
61}
62if ($location_of_bar == '') {
63 $location_of_bar = $temp_location_of_bar;
64}
65
6e097501 66// this value may be changed by a plugin, but initialize
67// it first to avoid register_globals headaches
68//
69$right_frame_url = '';
70do_hook('webmail_top', $null);
71
a4467cd7 72// Determine the main frame URL
73/*
74 * There are three ways to call webmail.php
75 * 1. webmail.php
76 * - This just loads the default entry screen.
77 * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
78 * - This loads the frames starting at the given values.
79 * 3. webmail.php?right_frame=folders.php
80 * - Loads the frames with the Folder options in the right frame.
81 *
82 * This was done to create a pure HTML way of refreshing the folder list since
83 * we would like to use as little Javascript as possible.
84 *
85 * The test for // should catch any attempt to include off-site webpages into
86 * our frameset.
6e097501 87 *
88 * Note that plugins are allowed to completely and freely override the URI
89 * used for the "right" (content) frame, and they do so by modifying the
90 * global variable $right_frame_url.
91 *
a4467cd7 92 */
93if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
94 $right_frame = '';
95}
96if ( strpos($right_frame,'?') ) {
97 $right_frame_file = substr($right_frame,0,strpos($right_frame,'?'));
98} else {
99 $right_frame_file = $right_frame;
100}
6e097501 101if (empty($right_frame_url)) {
102 switch($right_frame) {
103 case 'right_main.php':
104 $right_frame_url = "right_main.php?mailbox=".urlencode($mailbox)
105 . (!empty($sort)?"&amp;sort=$sort":'')
106 . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
107 break;
108 case 'options.php':
109 $right_frame_url = 'options.php';
110 break;
111 case 'folders.php':
112 $right_frame_url = 'folders.php';
113 break;
114 case 'compose.php':
115 $right_frame_url = 'compose.php?' . $mailtourl;
116 break;
117 case '':
118 $right_frame_url = 'right_main.php';
119 break;
120 default:
121 $right_frame_url = urlencode($right_frame);
122 break;
123 }
a4467cd7 124}
125
a4467cd7 126$oErrorHandler->setDelayedErrors(true);
127
a4467cd7 128$oTemplate->assign('nav_size', $left_size);
129$oTemplate->assign('nav_on_left', $location_of_bar=='left');
130$oTemplate->assign('right_frame_url', $right_frame_url);
a6f35c16 131
1411972c 132displayHtmlHeader($org_title, '', false, true);
133
a6f35c16 134$oTemplate->display('webmail.tpl');
202bcbcc 135