Add posibility of link in error box.
[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 * @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 */
25 function error_message($message, $mailbox, $sort, $startMessage, $color) {
26 $urlMailbox = urlencode($mailbox);
27 $string = '<tr><td align="center">' . $message . '</td></tr>'.
28 '<tr><td align="center">'.
29 '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">".
30 sprintf (_("Click here to return to %s"),
31 strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)).
32 '</a></td></tr>';
33 error_box($string, $color);
34 }
35
36 /**
37 * Displays error message
38 * @param string $message error message
39 * @param array $color color theme
40 * @since 1.0
41 */
42 function plain_error_message($message, $color) {
43 error_box($message, $color);
44 }
45
46 /**
47 * Displays error when user is logged out
48 *
49 * Error strings can be overriden by logout_error hook
50 * @param string $errString error message
51 * @param string $errTitle title of page with error message
52 * @since 1.2.6
53 */
54 function logout_error( $errString, $errTitle = '' ) {
55 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
56 $hide_sm_attributions, $version, $squirrelmail_language,
57 $color, $theme, $theme_default;
58
59 $base_uri = sqm_baseuri();
60
61 /* Display width and height like good little people */
62 $width_and_height = '';
63 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
64 $width_and_height = " width=\"$org_logo_width\"";
65 }
66 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
67 $width_and_height .= " height=\"$org_logo_height\"";
68 }
69
70 if (!isset($frame_top) || $frame_top == '' ) {
71 $frame_top = '_top';
72 }
73
74 // load default theme if possible
75 if (!isset($color) && @file_exists($theme[$theme_default]['PATH']))
76 @include ($theme[$theme_default]['PATH']);
77
78 if ( !isset( $color ) ) {
79 $color = array();
80 $color[0] = '#dcdcdc'; /* light gray TitleBar */
81 $color[1] = '#800000'; /* red */
82 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
83 $color[4] = '#ffffff'; /* white Normal Background */
84 $color[7] = '#0000cc'; /* blue Links */
85 $color[8] = '#000000'; /* black Normal text */
86 }
87
88 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
89
90 if ( $errTitle == '' ) {
91 $errTitle = $errString;
92 }
93 set_up_language($squirrelmail_language, true);
94
95 displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
96
97 echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
98 '<div style="text-align: center;">';
99
100 if (isset($org_logo) && ($org_logo != '')) {
101 echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
102 "\"$width_and_height /><br />\n";
103 }
104 echo ( $hide_sm_attributions ? '' :
105 '<small>' . _("SquirrelMail Webmail Application") . '<br />'.
106 _("By the SquirrelMail Project Team") . "<br /></small>\n" ).
107 '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%" align="center">'.
108 '<tr><td>'.
109 '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
110 '<tr><td bgcolor="'.$color[0].'" align="center">'.
111 '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
112 '</td></tr>'.
113 '<tr><td align="center">' . $errString . '</td></tr>'.
114 '<tr><td bgcolor="'.$color[0].'" align="center">'.
115 '<font color="'.$color[2].'"><b>'.
116 '<a href="'.$base_uri.'src/login.php" target="'.$frame_top.'">'.
117 _("Go to the login page") . '</a></b></font></td></tr>'.
118 '</table></td></tr></table></div></body></html>';
119 }
120
121 /**
122 * Displays error message
123 *
124 * Since 1.4.1 function checks if page header is already displayed.
125 * Since 1.4.3 and 1.5.1 function contains error_box hook.
126 * Use plain_error_message() and make sure that page header is created,
127 * if you want compatibility with 1.4.0 and older.
128 * @param string $string
129 * @param array $color
130 * @since 1.3.2
131 */
132 function error_box($string, $color) {
133 global $pageheader_sent, $oTemplate;
134
135 $err = _("ERROR");
136 $ret = concat_hook_function('error_box', $string);
137 if($ret != '') {
138 $string = $ret;
139 }
140
141 /* check if the page header has been sent; if not, send it! */
142 if(!isset($pageheader_sent) && !$pageheader_sent) {
143 displayHtmlHeader('SquirrelMail: '.$err);
144 $pageheader_sent = TRUE;
145 echo "<body>\n\n";
146 }
147
148 /** ERROR is pre-translated to avoid multiple translation calls. **/
149 $oTemplate->assign('error', $err);
150 $oTemplate->assign('errorMessage', $string);
151 $oTemplate->display('error_box.tpl');
152 }
153
154 /**
155 * Adds message that informs about non fatal error that can happen while saving preferences
156 * @param string $message error message
157 * @since 1.5.1 and 1.4.5
158 */
159 function error_option_save($message) {
160 global $optpage_save_error;
161
162 if (! is_array($optpage_save_error) )
163 $optpage_save_error=array();
164
165 $optpage_save_error=array_merge($optpage_save_error,array($message));
166 }