Adding template for error box.
[squirrelmail.git] / functions / display_messages.php
CommitLineData
59177427 1<?php
2ba13803 2
35586184 3/**
4 * display_messages.php
5 *
35586184 6 * This contains all messages, including information, error, and just
7 * about any other message you can think of.
8 *
47ccfad4 9 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
31841a9e 11 * @version $Id$
d6c32258 12 * @package squirrelmail
35586184 13 */
3302d0d4 14
d5f3892b 15/** @ignore */
16if (! defined('SM_PATH')) define('SM_PATH','../');
17
5100f68f 18/**
19 * including plugin functions
20 */
d5f3892b 21include_once(SM_PATH . 'functions/plugin.php');
ebb9eaaf 22
c94b297c 23/**
d5f3892b 24 * Displays error message and URL to message listing
25 * @param string $message error message
26 * @param string $mailbox mailbox name
27 * @param integer $sort sort order
28 * @param integer $startMessage first message
29 * @param array $color color theme
30 * @since 1.0
31 */
ec5b189b 32function error_message($message, $mailbox, $sort, $startMessage, $color) {
33 $urlMailbox = urlencode($mailbox);
2ea16421 34 $string = '<tr><td align="center">' . $message . '</td></tr>'.
35 '<tr><td align="center">'.
36 '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">".
37 sprintf (_("Click here to return to %s"),
38 strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)).
39 '</a></td></tr>';
fd2611e9 40 error_box($string, $color);
ec5b189b 41}
aa4c3749 42
d5f3892b 43/**
44 * Displays error message
45 * @param string $message error message
46 * @param array $color color theme
47 * @since 1.0
48 */
ec5b189b 49function plain_error_message($message, $color) {
fd2611e9 50 error_box($message, $color);
ec5b189b 51}
b6d8d08d 52
d5f3892b 53/**
54 * Displays error when user is logged out
55 *
56 * Error strings can be overriden by logout_error hook
57 * @param string $errString error message
58 * @param string $errTitle title of page with error message
59 * @since 1.2.6
60 */
9be8198d 61function logout_error( $errString, $errTitle = '' ) {
1f05436e 62 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
d2b6d0be 63 $hide_sm_attributions, $version, $squirrelmail_language,
64 $color, $theme, $theme_default;
35185c82 65
399846ea 66 $base_uri = sqm_baseuri();
26f9a94a 67
68 include_once( SM_PATH . 'functions/page_header.php' );
9be8198d 69 if ( !isset( $org_logo ) ) {
70 // Don't know yet why, but in some accesses $org_logo is not set.
26f9a94a 71 include( SM_PATH . 'config/config.php' );
9be8198d 72 }
73 /* Display width and height like good little people */
74 $width_and_height = '';
e16cb07b 75 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
2ea16421 76 $width_and_height = " width=\"$org_logo_width\"";
9be8198d 77 }
e16cb07b 78 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
2ea16421 79 $width_and_height .= " height=\"$org_logo_height\"";
9be8198d 80 }
81
82 if (!isset($frame_top) || $frame_top == '' ) {
83 $frame_top = '_top';
84 }
85
d2b6d0be 86 // load default theme if possible
87 if (!isset($color) && @file_exists($theme[$theme_default]['PATH']))
88 @include ($theme[$theme_default]['PATH']);
89
9be8198d 90 if ( !isset( $color ) ) {
91 $color = array();
2ea16421 92 $color[0] = '#dcdcdc'; /* light gray TitleBar */
9be8198d 93 $color[1] = '#800000'; /* red */
2ea16421 94 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
95 $color[4] = '#ffffff'; /* white Normal Background */
96 $color[7] = '#0000cc'; /* blue Links */
9be8198d 97 $color[8] = '#000000'; /* black Normal text */
9be8198d 98 }
99
8d42e09a 100 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
101
9be8198d 102 if ( $errTitle == '' ) {
c4ea392c 103 $errTitle = $errString;
9be8198d 104 }
105 set_up_language($squirrelmail_language, true);
1f05436e 106
c4ea392c 107 displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
1f05436e 108
2ea16421 109 echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
f265009a 110 '<div style="text-align: center;">';
4cbcaebd 111
112 if (isset($org_logo) && ($org_logo != '')) {
2ea16421 113 echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
114 "\"$width_and_height /><br />\n";
4cbcaebd 115 }
116 echo ( $hide_sm_attributions ? '' :
694d8e25 117 '<small>' . _("SquirrelMail Webmail Application") . '<br />'.
8bc594ba 118 _("By the SquirrelMail Project Team") . "<br /></small>\n" ).
0e61edf7 119 '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%" align="center">'.
2ea16421 120 '<tr><td>'.
121 '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
122 '<tr><td bgcolor="'.$color[0].'" align="center">'.
123 '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
124 '</td></tr>'.
125 '<tr><td align="center">' . $errString . '</td></tr>'.
126 '<tr><td bgcolor="'.$color[0].'" align="center">'.
127 '<font color="'.$color[2].'"><b>'.
128 '<a href="'.$base_uri.'src/login.php" target="'.$frame_top.'">'.
129 _("Go to the login page") . '</a></b></font></td></tr>'.
f265009a 130 '</table></td></tr></table></div></body></html>';
9be8198d 131}
132
d5f3892b 133/**
134 * Displays error message
135 *
136 * Since 1.4.1 function checks if page header is already displayed.
137 * Since 1.4.3 and 1.5.1 function contains error_box hook.
138 * Use plain_error_message() and make sure that page header is created,
139 * if you want compatibility with 1.4.0 and older.
140 * @param string $string
141 * @param array $color
142 * @since 1.3.2
143 */
fd2611e9 144function error_box($string, $color) {
2be6e3fc 145 global $pageheader_sent, $oTemplate;
a429618b 146
b6c283c4 147 $err = _("ERROR");
7753dac4 148 $ret = concat_hook_function('error_box', $string);
149 if($ret != '') {
150 $string = $ret;
151 }
8d42e09a 152
b6c283c4 153 /* check if the page header has been sent; if not, send it! */
154 if(!isset($pageheader_sent) && !$pageheader_sent) {
155 /* include this just to be sure */
156 include_once( SM_PATH . 'functions/page_header.php' );
157 displayHtmlHeader('SquirrelMail: '.$err);
158 $pageheader_sent = TRUE;
2be6e3fc 159 echo "<body>\n\n";
b6c283c4 160 }
161
2be6e3fc 162 /** ERROR is pre-translated to avoid multiple translation calls. **/
163 $oTemplate->assign('error', $err);
164 $oTemplate->assign('errorMessage', $string);
165 $oTemplate->display('error_box.tpl');
fd2611e9 166}
6c92ca88 167
288df1a0 168/**
169 * Adds message that informs about non fatal error that can happen while saving preferences
170 * @param string $message error message
b31af6df 171 * @since 1.5.1 and 1.4.5
288df1a0 172 */
173function error_option_save($message) {
174 global $optpage_save_error;
175
176 if (! is_array($optpage_save_error) )
91e0dccc 177 $optpage_save_error=array();
288df1a0 178
179 $optpage_save_error=array_merge($optpage_save_error,array($message));
180}
a9a7cda1 181?>