block uw mailbox abuse in imap select command instead of applying same
[squirrelmail.git] / functions / display_messages.php
1 <?php
2
3 /**
4 * display_messages.php
5 *
6 * This contains all messages, including information, error, and just
7 * about any other message you can think of.
8 *
9 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @version $Id$
12 * @package squirrelmail
13 */
14
15
16 /**
17 * Displays error message and URL to message listing
18 *
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
24 * @since 1.0
25 */
26 function error_message($message, $mailbox, $sort, $startMessage) {
27 $urlMailbox = urlencode($mailbox);
28 $link = array (
29 'URL' => sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox",
30 'TEXT' => sprintf (_("Click here to return to %s"),
31 strtoupper($mailbox) == 'INBOX' ? _("INBOX") : htmlspecialchars(imap_utf7_decode_local($mailbox)))
32 );
33 error_box($message, $link);
34 }
35
36 /**
37 * Displays error message
38 *
39 * Second argument ($color array) is removed in 1.5.2.
40 * @param string $message error message
41 * @since 1.0
42 */
43 function plain_error_message($message) {
44 error_box($message);
45 }
46
47 /**
48 * Displays error when user is logged out
49 *
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 */
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;
58
59 $base_uri = sqm_baseuri();
60
61 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
62
63 if ( $errTitle == '' ) {
64 $errTitle = $errString;
65 }
66 set_up_language($squirrelmail_language, true);
67
68 displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
69
70 /* If they don't have a logo, don't bother.. */
71 $logo_str = '';
72 if (isset($org_logo) && $org_logo) {
73 /* Display width and height like good little people */
74 $width_and_height = '';
75 if (isset($org_logo_width) && is_numeric($org_logo_width) &&
76 $org_logo_width>0) {
77 $width_and_height = " width=\"$org_logo_width\"";
78 }
79 if (isset($org_logo_height) && is_numeric($org_logo_height) &&
80 $org_logo_height>0) {
81 $width_and_height .= " height=\"$org_logo_height\"";
82 }
83
84 $logo_str = '<img src="'.$org_logo.'" ' .
85 'alt="'. sprintf(_("%s Logo"), $org_name).'" ' .
86 $width_and_height .
87 'class="sqm_loginImage" ' .
88 ' /><br />'."\n";
89 }
90
91 $sm_attribute_str = '';
92 if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
93 $sm_attribute_str = _("SquirrelMail Webmail Application")."<br />\n" .
94 _("By the SquirrelMail Project Team")."<br />\n";
95 }
96
97 $login_link = array (
98 'URL' => $base_uri . 'src/login.php',
99 'FRAME' => $frame_top
100 );
101
102 $oTemplate->assign('logo_str', $logo_str);
103 $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
104 $oTemplate->assign('login_link', $login_link);
105 $oTemplate->assign('errorMessage', $errString);
106 $oTemplate->display('error_logout.tpl');
107
108 $oTemplate->display('footer.tpl');
109 }
110
111 /**
112 * Displays error message
113 *
114 * Since 1.4.1 function checks if page header is already displayed.
115 *
116 * Since 1.4.3 and 1.5.1 function contains error_box hook.
117 * Use plain_error_message() and make sure that page header is created,
118 * if you want compatibility with 1.4.0 and older.
119 *
120 * In 1.5.2 second function argument is changed. Older functions used it
121 * for $color array, new function uses it for optional link data. Function
122 * will ignore color array and use standard colors instead.
123 * @param string $string Error message to be displayed
124 * @param array $link Optional array containing link details to be displayed.
125 * Array uses three keys. 'URL' key is required and should contain link URL.
126 * 'TEXT' key is optional and should contain link name. 'FRAME' key is
127 * optional and should contain link target attribute.
128 * @since 1.3.2
129 */
130 function error_box($string, $link=NULL) {
131 global $pageheader_sent, $oTemplate;
132
133 $err = _("ERROR");
134 $ret = concat_hook_function('error_box', $string);
135 if($ret != '') {
136 $string = $ret;
137 }
138
139 /* check if the page header has been sent; if not, send it! */
140 if(!isset($pageheader_sent) && !$pageheader_sent) {
141 displayHtmlHeader('SquirrelMail: '.$err);
142 $pageheader_sent = TRUE;
143 echo "<body>\n\n";
144 }
145
146 // Double check the link for everything we need
147 if (!is_null($link)) {
148 // safety check for older code
149 if (isset($link['URL'])) {
150 if (!isset($link['FRAME'])) $link['FRAME'] = '';
151 if (!isset($link['TEXT'])) $link['TEXT'] = $link['URL'];
152 } else {
153 // somebody used older error_box() code
154 $link=null;
155 }
156 }
157
158 /** ERROR is pre-translated to avoid multiple translation calls. **/
159 $oTemplate->assign('error', $err);
160 $oTemplate->assign('errorMessage', $string);
161 $oTemplate->assign('link', $link);
162 $oTemplate->display('error_box.tpl');
163 }
164
165 /**
166 * Adds message that informs about non fatal error that can happen while saving preferences
167 * @param string $message error message
168 * @since 1.5.1 and 1.4.5
169 */
170 function error_option_save($message) {
171 global $optpage_save_error;
172
173 if (! is_array($optpage_save_error) )
174 $optpage_save_error=array();
175
176 $optpage_save_error=array_merge($optpage_save_error,array($message));
177 }