6 * This contains all messages, including information, error, and just
7 * about any other message you can think of.
9 * @copyright © 1999-2007 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
17 * Displays error message and URL to message listing
19 * Fifth argument ($color array) is removed in 1.5.2.
20 * @param string $message error message
21 * @param string $mailbox mailbox name
22 * @param integer $sort sort order
23 * @param integer $startMessage first message
26 function error_message($message, $mailbox, $sort, $startMessage) {
27 $urlMailbox = urlencode($mailbox);
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)))
33 error_box($message, $link);
37 * Displays error message
39 * Second argument ($color array) is removed in 1.5.2.
40 * @param string $message error message
43 function plain_error_message($message) {
48 * Displays error when user is logged out
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
55 function logout_error( $errString, $errTitle = '' ) {
56 global $frame_top, $org_logo, $org_logo_width, $org_logo_height, $org_name,
57 $hide_sm_attributions, $squirrelmail_language, $oTemplate;
59 $base_uri = sqm_baseuri();
62 'URI' => $base_uri . 'src/login.php',
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));
70 if ( $errTitle == '' ) {
71 $errTitle = $errString;
73 set_up_language($squirrelmail_language, true);
75 displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
77 /* If they don't have a logo, don't bother.. */
79 if (isset($org_logo) && $org_logo) {
80 /* Display width and height like good little people */
81 $width_and_height = '';
82 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
84 $width_and_height = " width=\"$org_logo_width\"";
86 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
88 $width_and_height .= " height=\"$org_logo_height\"";
91 $logo_str = '<img src="'.$org_logo.'" ' .
92 'alt="'. sprintf(_("%s Logo"), $org_name).'" ' .
94 'class="sqm_loginImage" ' .
98 $sm_attribute_str = '';
99 if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
100 $sm_attribute_str = _("SquirrelMail Webmail Application") . "\n"
101 . _("By the SquirrelMail Project Team");
104 $oTemplate->assign('logo_str', $logo_str);
105 $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
106 $oTemplate->assign('login_link', $login_link);
107 $oTemplate->assign('errorMessage', $errString);
108 $oTemplate->display('error_logout.tpl');
110 $oTemplate->display('footer.tpl');
114 * Displays error message
116 * Since 1.4.1 function checks if page header is already displayed.
118 * Since 1.4.3 and 1.5.1, this function contains the error_box hook.
119 * Use plain_error_message() and make sure that page header is created,
120 * if you want compatibility with 1.4.0 and older.
122 * In 1.5.2 second function argument is changed. Older functions used it
123 * for $color array, new function uses it for optional link data. Function
124 * will ignore color array and use standard colors instead.
126 * @param string $string Error message to be displayed
127 * @param array $link Optional array containing link details to be displayed.
128 * Array uses three keys. 'URL' key is required and should contain link URL.
129 * 'TEXT' key is optional and should contain link name. 'FRAME' key is
130 * optional and should contain link target attribute.
134 function error_box($string, $link=NULL) {
135 global $pageheader_sent, $oTemplate;
138 do_hook('error_box', $string);
140 /* check if the page header has been sent; if not, send it! */
141 if (!isset($pageheader_sent) && !$pageheader_sent) {
142 displayHtmlHeader('SquirrelMail: '.$err);
143 $pageheader_sent = TRUE;
147 // Double check the link for everything we need
148 if (!is_null($link)) {
149 // safety check for older code
150 if (isset($link['URL'])) {
151 if (!isset($link['FRAME'])) $link['FRAME'] = '';
152 if (!isset($link['TEXT'])) $link['TEXT'] = $link['URL'];
154 // somebody used older error_box() code
159 /** ERROR is pre-translated to avoid multiple translation calls. **/
160 $oTemplate->assign('error', $err);
161 $oTemplate->assign('errorMessage', $string);
162 $oTemplate->assign('link', $link);
163 $oTemplate->display('error_box.tpl');
167 * Adds message that informs about non fatal error that can happen while saving preferences
168 * @param string $message error message
169 * @since 1.5.1 and 1.4.5
171 function error_option_save($message) {
172 global $optpage_save_error;
174 if (! is_array($optpage_save_error) )
175 $optpage_save_error=array();
177 $optpage_save_error=array_merge($optpage_save_error,array($message));