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 | * |
4b4abf93 |
9 | * @copyright © 1999-2005 The SquirrelMail Project Team |
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 */ |
16 | if (! defined('SM_PATH')) define('SM_PATH','../'); |
17 | |
5100f68f |
18 | /** |
19 | * including plugin functions |
20 | */ |
d5f3892b |
21 | include_once(SM_PATH . 'functions/plugin.php'); |
ebb9eaaf |
22 | |
d5f3892b |
23 | /** |
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 |
32 | function 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&startMessage=$startMessage&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 |
49 | function 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 |
61 | function 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". |
110 | '<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" ). |
2ea16421 |
119 | '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%">'. |
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>'. |
130 | '</table></td></tr></table></center></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 |
144 | function error_box($string, $color) { |
b6c283c4 |
145 | global $pageheader_sent; |
146 | |
a429618b |
147 | if ( !isset( $color ) ) { |
148 | $color = array(); |
2ea16421 |
149 | $color[0] = '#dcdcdc'; /* light gray TitleBar */ |
a429618b |
150 | $color[1] = '#800000'; /* red */ |
2ea16421 |
151 | $color[2] = '#cc0000'; /* light red Warning/Error Messages */ |
152 | $color[4] = '#ffffff'; /* white Normal Background */ |
153 | $color[7] = '#0000cc'; /* blue Links */ |
a429618b |
154 | $color[8] = '#000000'; /* black Normal text */ |
2ea16421 |
155 | $color[9] = '#ababab'; /* mid-gray Darker version of #0 */ |
a429618b |
156 | } |
157 | |
b6c283c4 |
158 | $err = _("ERROR"); |
159 | |
7753dac4 |
160 | $ret = concat_hook_function('error_box', $string); |
161 | if($ret != '') { |
162 | $string = $ret; |
163 | } |
8d42e09a |
164 | |
b6c283c4 |
165 | /* check if the page header has been sent; if not, send it! */ |
166 | if(!isset($pageheader_sent) && !$pageheader_sent) { |
167 | /* include this just to be sure */ |
168 | include_once( SM_PATH . 'functions/page_header.php' ); |
169 | displayHtmlHeader('SquirrelMail: '.$err); |
170 | $pageheader_sent = TRUE; |
171 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n"; |
172 | } |
173 | |
2ea16421 |
174 | echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'. |
175 | '<tr><td>'. |
176 | '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'. |
177 | '<tr><td align="center" bgcolor="'.$color[0].'">'. |
178 | '<font color="'.$color[2].'"><b>' . $err . ':</b></font>'. |
179 | '</td></tr><tr><td>'. |
180 | '<table cellpadding="1" cellspacing="5" align="center" border="0">'. |
181 | '<tr>' . html_tag( 'td', $string."\n", 'left') . '</tr></table>'. |
182 | '</td></tr></table></td></tr></table>'; |
fd2611e9 |
183 | } |
6c92ca88 |
184 | |
288df1a0 |
185 | /** |
186 | * Adds message that informs about non fatal error that can happen while saving preferences |
187 | * @param string $message error message |
b31af6df |
188 | * @since 1.5.1 and 1.4.5 |
288df1a0 |
189 | */ |
190 | function error_option_save($message) { |
191 | global $optpage_save_error; |
192 | |
193 | if (! is_array($optpage_save_error) ) |
91e0dccc |
194 | $optpage_save_error=array(); |
288df1a0 |
195 | |
196 | $optpage_save_error=array_merge($optpage_save_error,array($message)); |
197 | } |
6c92ca88 |
198 | // vim: et ts=4 |
a9a7cda1 |
199 | ?> |