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 | * |
4b5049de |
9 | * @copyright © 1999-2007 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 | |
d5f3892b |
16 | /** |
17 | * Displays error message and URL to message listing |
5e5a1eed |
18 | * |
19 | * Fifth argument ($color array) is removed in 1.5.2. |
d5f3892b |
20 | * @param string $message error message |
21 | * @param string $mailbox mailbox name |
22 | * @param integer $sort sort order |
23 | * @param integer $startMessage first message |
d5f3892b |
24 | * @since 1.0 |
25 | */ |
284a0d8a |
26 | function error_message($message, $mailbox, $sort, $startMessage) { |
ec5b189b |
27 | $urlMailbox = urlencode($mailbox); |
5e5a1eed |
28 | $link = array ( |
29 | 'URL' => sqm_baseuri()."src/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox", |
30 | 'TEXT' => sprintf (_("Click here to return to %s"), |
31 | strtoupper($mailbox) == 'INBOX' ? _("INBOX") : htmlspecialchars(imap_utf7_decode_local($mailbox))) |
32 | ); |
284a0d8a |
33 | error_box($message, $link); |
ec5b189b |
34 | } |
aa4c3749 |
35 | |
d5f3892b |
36 | /** |
37 | * Displays error message |
5e5a1eed |
38 | * |
39 | * Second argument ($color array) is removed in 1.5.2. |
d5f3892b |
40 | * @param string $message error message |
d5f3892b |
41 | * @since 1.0 |
42 | */ |
284a0d8a |
43 | function plain_error_message($message) { |
44 | error_box($message); |
ec5b189b |
45 | } |
b6d8d08d |
46 | |
d5f3892b |
47 | /** |
48 | * Displays error when user is logged out |
284a0d8a |
49 | * |
d5f3892b |
50 | * Error strings can be overriden by logout_error hook |
51 | * @param string $errString error message |
52 | * @param string $errTitle title of page with error message |
53 | * @since 1.2.6 |
54 | */ |
9be8198d |
55 | function logout_error( $errString, $errTitle = '' ) { |
284a0d8a |
56 | global $frame_top, $org_logo, $org_logo_width, $org_logo_height, $org_name, |
57 | $hide_sm_attributions, $squirrelmail_language, $oTemplate; |
35185c82 |
58 | |
399846ea |
59 | $base_uri = sqm_baseuri(); |
26f9a94a |
60 | |
5f882853 |
61 | $login_link = array ( |
62 | 'URI' => $base_uri . 'src/login.php', |
63 | 'FRAME' => $frame_top |
64 | ); |
65 | |
d849b570 |
66 | /* As of 1.5.2, plugin parameters are combined into one array; |
67 | plugins on this hook must be updated */ |
68 | do_hook('logout_error', $temp=array(&$errString, &$errTitle, &$login_link)); |
8d42e09a |
69 | |
9be8198d |
70 | if ( $errTitle == '' ) { |
c4ea392c |
71 | $errTitle = $errString; |
9be8198d |
72 | } |
73 | set_up_language($squirrelmail_language, true); |
1f05436e |
74 | |
c4ea392c |
75 | displayHtmlHeader( $org_name.' - '.$errTitle, '', false ); |
1f05436e |
76 | |
284a0d8a |
77 | /* If they don't have a logo, don't bother.. */ |
78 | $logo_str = ''; |
79 | if (isset($org_logo) && $org_logo) { |
8f6e76d2 |
80 | |
284a0d8a |
81 | if (isset($org_logo_width) && is_numeric($org_logo_width) && |
82 | $org_logo_width>0) { |
8f6e76d2 |
83 | $width = $org_logo_width; |
84 | } else { |
85 | $width = ''; |
284a0d8a |
86 | } |
87 | if (isset($org_logo_height) && is_numeric($org_logo_height) && |
88 | $org_logo_height>0) { |
8f6e76d2 |
89 | $height = $org_logo_height; |
90 | } else { |
91 | $height = ''; |
284a0d8a |
92 | } |
8f6e76d2 |
93 | |
94 | $logo_str = create_image($org_logo, sprintf(_("%s Logo"), $org_name), |
95 | $width, $height, '', 'sqm_loginImage'); |
96 | |
4cbcaebd |
97 | } |
284a0d8a |
98 | |
99 | $sm_attribute_str = ''; |
100 | if (isset($hide_sm_attributions) && !$hide_sm_attributions) { |
5670da62 |
101 | $sm_attribute_str = _("SquirrelMail Webmail Application") . "\n" |
102 | . _("By the SquirrelMail Project Team"); |
284a0d8a |
103 | } |
104 | |
284a0d8a |
105 | $oTemplate->assign('logo_str', $logo_str); |
106 | $oTemplate->assign('sm_attribute_str', $sm_attribute_str); |
107 | $oTemplate->assign('login_link', $login_link); |
108 | $oTemplate->assign('errorMessage', $errString); |
109 | $oTemplate->display('error_logout.tpl'); |
110 | |
111 | $oTemplate->display('footer.tpl'); |
9be8198d |
112 | } |
113 | |
d5f3892b |
114 | /** |
115 | * Displays error message |
284a0d8a |
116 | * |
d5f3892b |
117 | * Since 1.4.1 function checks if page header is already displayed. |
1b858d86 |
118 | * |
d849b570 |
119 | * Since 1.4.3 and 1.5.1, this function contains the error_box hook. |
d5f3892b |
120 | * Use plain_error_message() and make sure that page header is created, |
121 | * if you want compatibility with 1.4.0 and older. |
1b858d86 |
122 | * |
123 | * In 1.5.2 second function argument is changed. Older functions used it |
124 | * for $color array, new function uses it for optional link data. Function |
125 | * will ignore color array and use standard colors instead. |
d849b570 |
126 | * |
284a0d8a |
127 | * @param string $string Error message to be displayed |
1b858d86 |
128 | * @param array $link Optional array containing link details to be displayed. |
129 | * Array uses three keys. 'URL' key is required and should contain link URL. |
130 | * 'TEXT' key is optional and should contain link name. 'FRAME' key is |
131 | * optional and should contain link target attribute. |
d849b570 |
132 | * |
d5f3892b |
133 | * @since 1.3.2 |
134 | */ |
284a0d8a |
135 | function error_box($string, $link=NULL) { |
2be6e3fc |
136 | global $pageheader_sent, $oTemplate; |
a429618b |
137 | |
b6c283c4 |
138 | $err = _("ERROR"); |
d849b570 |
139 | do_hook('error_box', $string); |
8d42e09a |
140 | |
b6c283c4 |
141 | /* check if the page header has been sent; if not, send it! */ |
d849b570 |
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 | |
284a0d8a |
148 | // Double check the link for everything we need |
149 | if (!is_null($link)) { |
1b858d86 |
150 | // safety check for older code |
151 | if (isset($link['URL'])) { |
152 | if (!isset($link['FRAME'])) $link['FRAME'] = ''; |
153 | if (!isset($link['TEXT'])) $link['TEXT'] = $link['URL']; |
154 | } else { |
155 | // somebody used older error_box() code |
156 | $link=null; |
157 | } |
284a0d8a |
158 | } |
159 | |
2be6e3fc |
160 | /** ERROR is pre-translated to avoid multiple translation calls. **/ |
161 | $oTemplate->assign('error', $err); |
162 | $oTemplate->assign('errorMessage', $string); |
284a0d8a |
163 | $oTemplate->assign('link', $link); |
2be6e3fc |
164 | $oTemplate->display('error_box.tpl'); |
fd2611e9 |
165 | } |
6c92ca88 |
166 | |
288df1a0 |
167 | /** |
168 | * Adds message that informs about non fatal error that can happen while saving preferences |
169 | * @param string $message error message |
b31af6df |
170 | * @since 1.5.1 and 1.4.5 |
288df1a0 |
171 | */ |
172 | function error_option_save($message) { |
173 | global $optpage_save_error; |
174 | |
175 | if (! is_array($optpage_save_error) ) |
91e0dccc |
176 | $optpage_save_error=array(); |
288df1a0 |
177 | |
178 | $optpage_save_error=array_merge($optpage_save_error,array($message)); |
284a0d8a |
179 | } |