one more identity action to process
[squirrelmail.git] / functions / display_messages.php
CommitLineData
59177427 1<?php
2ba13803 2
35586184 3/**
4 * display_messages.php
5 *
6c84ba1e 6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This contains all messages, including information, error, and just
10 * about any other message you can think of.
11 *
31841a9e 12 * @version $Id$
d6c32258 13 * @package squirrelmail
35586184 14 */
3302d0d4 15
d5f3892b 16/** @ignore */
17if (! defined('SM_PATH')) define('SM_PATH','../');
18
5100f68f 19/**
20 * including plugin functions
21 */
d5f3892b 22include_once(SM_PATH . 'functions/plugin.php');
ebb9eaaf 23
c94b297c 24/**
598294a7 25 * Find out where SquirrelMail lives and try to be smart about it.
26 * The only problem would be when SquirrelMail lives in directories
c94b297c 27 * called "src", "functions", or "plugins", but people who do that need
28 * to be beaten with a steel pipe anyway.
29 *
598294a7 30 * @return string the base uri of SquirrelMail installation.
d5f3892b 31 * @since 1.2.6
c94b297c 32 */
399846ea 33function sqm_baseuri(){
34 global $base_uri, $PHP_SELF;
c94b297c 35 /**
36 * If it is in the session, just return it.
37 */
399846ea 38 if (isset($base_uri)){
39 return $base_uri;
40 }
7e156b3d 41 $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
42 $repl = array('', '', '');
399846ea 43 $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
44 return $base_uri;
45}
46
d5f3892b 47/**
48 * Displays error message and URL to message listing
49 * @param string $message error message
50 * @param string $mailbox mailbox name
51 * @param integer $sort sort order
52 * @param integer $startMessage first message
53 * @param array $color color theme
54 * @since 1.0
55 */
ec5b189b 56function error_message($message, $mailbox, $sort, $startMessage, $color) {
57 $urlMailbox = urlencode($mailbox);
2ea16421 58 $string = '<tr><td align="center">' . $message . '</td></tr>'.
59 '<tr><td align="center">'.
60 '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">".
61 sprintf (_("Click here to return to %s"),
62 strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)).
63 '</a></td></tr>';
fd2611e9 64 error_box($string, $color);
ec5b189b 65}
aa4c3749 66
d5f3892b 67/**
68 * Displays error message
69 * @param string $message error message
70 * @param array $color color theme
71 * @since 1.0
72 */
ec5b189b 73function plain_error_message($message, $color) {
fd2611e9 74 error_box($message, $color);
ec5b189b 75}
b6d8d08d 76
d5f3892b 77/**
78 * Displays error when user is logged out
79 *
80 * Error strings can be overriden by logout_error hook
81 * @param string $errString error message
82 * @param string $errTitle title of page with error message
83 * @since 1.2.6
84 */
9be8198d 85function logout_error( $errString, $errTitle = '' ) {
1f05436e 86 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
d2b6d0be 87 $hide_sm_attributions, $version, $squirrelmail_language,
88 $color, $theme, $theme_default;
35185c82 89
399846ea 90 $base_uri = sqm_baseuri();
26f9a94a 91
92 include_once( SM_PATH . 'functions/page_header.php' );
9be8198d 93 if ( !isset( $org_logo ) ) {
94 // Don't know yet why, but in some accesses $org_logo is not set.
26f9a94a 95 include( SM_PATH . 'config/config.php' );
9be8198d 96 }
97 /* Display width and height like good little people */
98 $width_and_height = '';
e16cb07b 99 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
2ea16421 100 $width_and_height = " width=\"$org_logo_width\"";
9be8198d 101 }
e16cb07b 102 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
2ea16421 103 $width_and_height .= " height=\"$org_logo_height\"";
9be8198d 104 }
105
106 if (!isset($frame_top) || $frame_top == '' ) {
107 $frame_top = '_top';
108 }
109
d2b6d0be 110 // load default theme if possible
111 if (!isset($color) && @file_exists($theme[$theme_default]['PATH']))
112 @include ($theme[$theme_default]['PATH']);
113
9be8198d 114 if ( !isset( $color ) ) {
115 $color = array();
2ea16421 116 $color[0] = '#dcdcdc'; /* light gray TitleBar */
9be8198d 117 $color[1] = '#800000'; /* red */
2ea16421 118 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
119 $color[4] = '#ffffff'; /* white Normal Background */
120 $color[7] = '#0000cc'; /* blue Links */
9be8198d 121 $color[8] = '#000000'; /* black Normal text */
9be8198d 122 }
123
8d42e09a 124 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
125
9be8198d 126 if ( $errTitle == '' ) {
c4ea392c 127 $errTitle = $errString;
9be8198d 128 }
129 set_up_language($squirrelmail_language, true);
1f05436e 130
c4ea392c 131 displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
1f05436e 132
2ea16421 133 echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
134 '<center>';
4cbcaebd 135
136 if (isset($org_logo) && ($org_logo != '')) {
2ea16421 137 echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
138 "\"$width_and_height /><br />\n";
4cbcaebd 139 }
140 echo ( $hide_sm_attributions ? '' :
694d8e25 141 '<small>' . _("SquirrelMail Webmail Application") . '<br />'.
8bc594ba 142 _("By the SquirrelMail Project Team") . "<br /></small>\n" ).
2ea16421 143 '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%">'.
144 '<tr><td>'.
145 '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
146 '<tr><td bgcolor="'.$color[0].'" align="center">'.
147 '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
148 '</td></tr>'.
149 '<tr><td align="center">' . $errString . '</td></tr>'.
150 '<tr><td bgcolor="'.$color[0].'" align="center">'.
151 '<font color="'.$color[2].'"><b>'.
152 '<a href="'.$base_uri.'src/login.php" target="'.$frame_top.'">'.
153 _("Go to the login page") . '</a></b></font></td></tr>'.
154 '</table></td></tr></table></center></body></html>';
9be8198d 155}
156
d5f3892b 157/**
158 * Displays error message
159 *
160 * Since 1.4.1 function checks if page header is already displayed.
161 * Since 1.4.3 and 1.5.1 function contains error_box hook.
162 * Use plain_error_message() and make sure that page header is created,
163 * if you want compatibility with 1.4.0 and older.
164 * @param string $string
165 * @param array $color
166 * @since 1.3.2
167 */
fd2611e9 168function error_box($string, $color) {
b6c283c4 169 global $pageheader_sent;
170
a429618b 171 if ( !isset( $color ) ) {
172 $color = array();
2ea16421 173 $color[0] = '#dcdcdc'; /* light gray TitleBar */
a429618b 174 $color[1] = '#800000'; /* red */
2ea16421 175 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
176 $color[4] = '#ffffff'; /* white Normal Background */
177 $color[7] = '#0000cc'; /* blue Links */
a429618b 178 $color[8] = '#000000'; /* black Normal text */
2ea16421 179 $color[9] = '#ababab'; /* mid-gray Darker version of #0 */
a429618b 180 }
181
b6c283c4 182 $err = _("ERROR");
183
7753dac4 184 $ret = concat_hook_function('error_box', $string);
185 if($ret != '') {
186 $string = $ret;
187 }
8d42e09a 188
b6c283c4 189 /* check if the page header has been sent; if not, send it! */
190 if(!isset($pageheader_sent) && !$pageheader_sent) {
191 /* include this just to be sure */
192 include_once( SM_PATH . 'functions/page_header.php' );
193 displayHtmlHeader('SquirrelMail: '.$err);
194 $pageheader_sent = TRUE;
195 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
196 }
197
2ea16421 198 echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'.
199 '<tr><td>'.
200 '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'.
201 '<tr><td align="center" bgcolor="'.$color[0].'">'.
202 '<font color="'.$color[2].'"><b>' . $err . ':</b></font>'.
203 '</td></tr><tr><td>'.
204 '<table cellpadding="1" cellspacing="5" align="center" border="0">'.
205 '<tr>' . html_tag( 'td', $string."\n", 'left') . '</tr></table>'.
206 '</td></tr></table></td></tr></table>';
fd2611e9 207}
6c92ca88 208
288df1a0 209/**
210 * Adds message that informs about non fatal error that can happen while saving preferences
211 * @param string $message error message
b31af6df 212 * @since 1.5.1 and 1.4.5
288df1a0 213 */
214function error_option_save($message) {
215 global $optpage_save_error;
216
217 if (! is_array($optpage_save_error) )
91e0dccc 218 $optpage_save_error=array();
288df1a0 219
220 $optpage_save_error=array_merge($optpage_save_error,array($message));
221}
6c92ca88 222// vim: et ts=4
f8a1ed5a 223?>