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 | * |
87d2ad51 |
39 | * Second argument ($color array) is changed to boolean $return_output as of 1.5.2. |
d5f3892b |
40 | * @param string $message error message |
87d2ad51 |
41 | * @param boolean $return_output When TRUE, output is returned to caller |
42 | * instead of being sent to browser (OPTIONAL; |
43 | * default = FALSE) |
d5f3892b |
44 | * @since 1.0 |
45 | */ |
87d2ad51 |
46 | function plain_error_message($message, $return_output=FALSE) { |
47 | return error_box($message, NULL, $return_output); |
ec5b189b |
48 | } |
b6d8d08d |
49 | |
d5f3892b |
50 | /** |
51 | * Displays error when user is logged out |
284a0d8a |
52 | * |
d5f3892b |
53 | * Error strings can be overriden by logout_error hook |
54 | * @param string $errString error message |
55 | * @param string $errTitle title of page with error message |
56 | * @since 1.2.6 |
57 | */ |
9be8198d |
58 | function logout_error( $errString, $errTitle = '' ) { |
284a0d8a |
59 | global $frame_top, $org_logo, $org_logo_width, $org_logo_height, $org_name, |
60 | $hide_sm_attributions, $squirrelmail_language, $oTemplate; |
35185c82 |
61 | |
399846ea |
62 | $base_uri = sqm_baseuri(); |
26f9a94a |
63 | |
5f882853 |
64 | $login_link = array ( |
65 | 'URI' => $base_uri . 'src/login.php', |
66 | 'FRAME' => $frame_top |
67 | ); |
68 | |
d849b570 |
69 | /* As of 1.5.2, plugin parameters are combined into one array; |
70 | plugins on this hook must be updated */ |
1e5ae210 |
71 | $temp = array(&$errString, &$errTitle, &$login_link); |
72 | do_hook('logout_error', $temp); |
8d42e09a |
73 | |
9be8198d |
74 | if ( $errTitle == '' ) { |
c4ea392c |
75 | $errTitle = $errString; |
9be8198d |
76 | } |
77 | set_up_language($squirrelmail_language, true); |
1f05436e |
78 | |
c4ea392c |
79 | displayHtmlHeader( $org_name.' - '.$errTitle, '', false ); |
1f05436e |
80 | |
284a0d8a |
81 | /* If they don't have a logo, don't bother.. */ |
82 | $logo_str = ''; |
83 | if (isset($org_logo) && $org_logo) { |
8f6e76d2 |
84 | |
284a0d8a |
85 | if (isset($org_logo_width) && is_numeric($org_logo_width) && |
86 | $org_logo_width>0) { |
8f6e76d2 |
87 | $width = $org_logo_width; |
88 | } else { |
89 | $width = ''; |
284a0d8a |
90 | } |
91 | if (isset($org_logo_height) && is_numeric($org_logo_height) && |
92 | $org_logo_height>0) { |
8f6e76d2 |
93 | $height = $org_logo_height; |
94 | } else { |
95 | $height = ''; |
284a0d8a |
96 | } |
8f6e76d2 |
97 | |
98 | $logo_str = create_image($org_logo, sprintf(_("%s Logo"), $org_name), |
99 | $width, $height, '', 'sqm_loginImage'); |
100 | |
4cbcaebd |
101 | } |
284a0d8a |
102 | |
103 | $sm_attribute_str = ''; |
104 | if (isset($hide_sm_attributions) && !$hide_sm_attributions) { |
3e6b917e |
105 | $sm_attribute_str = _("SquirrelMail Webmail") . "\n" |
5670da62 |
106 | . _("By the SquirrelMail Project Team"); |
284a0d8a |
107 | } |
108 | |
284a0d8a |
109 | $oTemplate->assign('logo_str', $logo_str); |
110 | $oTemplate->assign('sm_attribute_str', $sm_attribute_str); |
111 | $oTemplate->assign('login_link', $login_link); |
112 | $oTemplate->assign('errorMessage', $errString); |
113 | $oTemplate->display('error_logout.tpl'); |
114 | |
115 | $oTemplate->display('footer.tpl'); |
9be8198d |
116 | } |
117 | |
d5f3892b |
118 | /** |
119 | * Displays error message |
284a0d8a |
120 | * |
d5f3892b |
121 | * Since 1.4.1 function checks if page header is already displayed. |
1b858d86 |
122 | * |
d849b570 |
123 | * Since 1.4.3 and 1.5.1, this function contains the error_box hook. |
d5f3892b |
124 | * Use plain_error_message() and make sure that page header is created, |
125 | * if you want compatibility with 1.4.0 and older. |
1b858d86 |
126 | * |
127 | * In 1.5.2 second function argument is changed. Older functions used it |
128 | * for $color array, new function uses it for optional link data. Function |
129 | * will ignore color array and use standard colors instead. |
d849b570 |
130 | * |
87d2ad51 |
131 | * The $return_output argument was added in 1.5.2 |
132 | * |
284a0d8a |
133 | * @param string $string Error message to be displayed |
1b858d86 |
134 | * @param array $link Optional array containing link details to be displayed. |
135 | * Array uses three keys. 'URL' key is required and should contain link URL. |
136 | * 'TEXT' key is optional and should contain link name. 'FRAME' key is |
137 | * optional and should contain link target attribute. |
87d2ad51 |
138 | * @param boolean $return_output When TRUE, output is returned to caller |
139 | * instead of being sent to browser (OPTIONAL; |
140 | * default = FALSE) |
d849b570 |
141 | * |
d5f3892b |
142 | * @since 1.3.2 |
143 | */ |
87d2ad51 |
144 | function error_box($string, $link=NULL, $return_output=FALSE) { |
f6b68e06 |
145 | global $pageheader_sent, $oTemplate, $org_title; |
a429618b |
146 | |
b6c283c4 |
147 | $err = _("ERROR"); |
d849b570 |
148 | do_hook('error_box', $string); |
f6b68e06 |
149 | if ( !isset($org_title) ) $org_title = 'SquirrelMail'; |
8d42e09a |
150 | |
87d2ad51 |
151 | // check if the page header has been sent; if not, send it! |
152 | // |
153 | // (however, if $return_output is turned on, the output of this |
154 | // should be being used in some other page, so we don't have |
155 | // to worry about page headers in that case) |
156 | // |
157 | if (!$return_output && empty($pageheader_sent)) { |
f6b68e06 |
158 | displayHtmlHeader($org_title . ': '.$err); |
b6c283c4 |
159 | $pageheader_sent = TRUE; |
87d2ad51 |
160 | echo create_body(); // this is template-safe (see create_body() function) |
b6c283c4 |
161 | } |
162 | |
284a0d8a |
163 | // Double check the link for everything we need |
164 | if (!is_null($link)) { |
1b858d86 |
165 | // safety check for older code |
166 | if (isset($link['URL'])) { |
167 | if (!isset($link['FRAME'])) $link['FRAME'] = ''; |
168 | if (!isset($link['TEXT'])) $link['TEXT'] = $link['URL']; |
169 | } else { |
170 | // somebody used older error_box() code |
171 | $link=null; |
172 | } |
284a0d8a |
173 | } |
174 | |
2be6e3fc |
175 | /** ERROR is pre-translated to avoid multiple translation calls. **/ |
176 | $oTemplate->assign('error', $err); |
177 | $oTemplate->assign('errorMessage', $string); |
284a0d8a |
178 | $oTemplate->assign('link', $link); |
87d2ad51 |
179 | $output = $oTemplate->fetch('error_box.tpl'); |
180 | |
181 | if ($return_output) return $output; |
182 | echo $output; |
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)); |
284a0d8a |
197 | } |