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