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