phpDocumentor updates
[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 *
4b4abf93 9 * @copyright &copy; 1999-2005 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
31841a9e 11 * @version $Id$
d6c32258 12 * @package squirrelmail
35586184 13 */
3302d0d4 14
d5f3892b 15/** @ignore */
16if (! defined('SM_PATH')) define('SM_PATH','../');
17
5100f68f 18/**
19 * including plugin functions
20 */
d5f3892b 21include_once(SM_PATH . 'functions/plugin.php');
ebb9eaaf 22
c94b297c 23/**
598294a7 24 * Find out where SquirrelMail lives and try to be smart about it.
25 * The only problem would be when SquirrelMail lives in directories
c94b297c 26 * called "src", "functions", or "plugins", but people who do that need
27 * to be beaten with a steel pipe anyway.
28 *
598294a7 29 * @return string the base uri of SquirrelMail installation.
d5f3892b 30 * @since 1.2.6
c94b297c 31 */
399846ea 32function sqm_baseuri(){
33 global $base_uri, $PHP_SELF;
c94b297c 34 /**
35 * If it is in the session, just return it.
36 */
399846ea 37 if (isset($base_uri)){
38 return $base_uri;
39 }
7e156b3d 40 $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
41 $repl = array('', '', '');
399846ea 42 $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
43 return $base_uri;
44}
45
d5f3892b 46/**
47 * Displays error message and URL to message listing
48 * @param string $message error message
49 * @param string $mailbox mailbox name
50 * @param integer $sort sort order
51 * @param integer $startMessage first message
52 * @param array $color color theme
53 * @since 1.0
54 */
ec5b189b 55function error_message($message, $mailbox, $sort, $startMessage, $color) {
56 $urlMailbox = urlencode($mailbox);
2ea16421 57 $string = '<tr><td align="center">' . $message . '</td></tr>'.
58 '<tr><td align="center">'.
59 '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">".
60 sprintf (_("Click here to return to %s"),
61 strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)).
62 '</a></td></tr>';
fd2611e9 63 error_box($string, $color);
ec5b189b 64}
aa4c3749 65
d5f3892b 66/**
67 * Displays error message
68 * @param string $message error message
69 * @param array $color color theme
70 * @since 1.0
71 */
ec5b189b 72function plain_error_message($message, $color) {
fd2611e9 73 error_box($message, $color);
ec5b189b 74}
b6d8d08d 75
d5f3892b 76/**
77 * Displays error when user is logged out
78 *
79 * Error strings can be overriden by logout_error hook
80 * @param string $errString error message
81 * @param string $errTitle title of page with error message
82 * @since 1.2.6
83 */
9be8198d 84function logout_error( $errString, $errTitle = '' ) {
1f05436e 85 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
d2b6d0be 86 $hide_sm_attributions, $version, $squirrelmail_language,
87 $color, $theme, $theme_default;
35185c82 88
399846ea 89 $base_uri = sqm_baseuri();
26f9a94a 90
91 include_once( SM_PATH . 'functions/page_header.php' );
9be8198d 92 if ( !isset( $org_logo ) ) {
93 // Don't know yet why, but in some accesses $org_logo is not set.
26f9a94a 94 include( SM_PATH . 'config/config.php' );
9be8198d 95 }
96 /* Display width and height like good little people */
97 $width_and_height = '';
e16cb07b 98 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
2ea16421 99 $width_and_height = " width=\"$org_logo_width\"";
9be8198d 100 }
e16cb07b 101 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
2ea16421 102 $width_and_height .= " height=\"$org_logo_height\"";
9be8198d 103 }
104
105 if (!isset($frame_top) || $frame_top == '' ) {
106 $frame_top = '_top';
107 }
108
d2b6d0be 109 // load default theme if possible
110 if (!isset($color) && @file_exists($theme[$theme_default]['PATH']))
111 @include ($theme[$theme_default]['PATH']);
112
9be8198d 113 if ( !isset( $color ) ) {
114 $color = array();
2ea16421 115 $color[0] = '#dcdcdc'; /* light gray TitleBar */
9be8198d 116 $color[1] = '#800000'; /* red */
2ea16421 117 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
118 $color[4] = '#ffffff'; /* white Normal Background */
119 $color[7] = '#0000cc'; /* blue Links */
9be8198d 120 $color[8] = '#000000'; /* black Normal text */
9be8198d 121 }
122
8d42e09a 123 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
124
9be8198d 125 if ( $errTitle == '' ) {
c4ea392c 126 $errTitle = $errString;
9be8198d 127 }
128 set_up_language($squirrelmail_language, true);
1f05436e 129
c4ea392c 130 displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
1f05436e 131
2ea16421 132 echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
133 '<center>';
4cbcaebd 134
135 if (isset($org_logo) && ($org_logo != '')) {
2ea16421 136 echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
137 "\"$width_and_height /><br />\n";
4cbcaebd 138 }
139 echo ( $hide_sm_attributions ? '' :
694d8e25 140 '<small>' . _("SquirrelMail Webmail Application") . '<br />'.
8bc594ba 141 _("By the SquirrelMail Project Team") . "<br /></small>\n" ).
2ea16421 142 '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%">'.
143 '<tr><td>'.
144 '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
145 '<tr><td bgcolor="'.$color[0].'" align="center">'.
146 '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
147 '</td></tr>'.
148 '<tr><td align="center">' . $errString . '</td></tr>'.
149 '<tr><td bgcolor="'.$color[0].'" align="center">'.
150 '<font color="'.$color[2].'"><b>'.
151 '<a href="'.$base_uri.'src/login.php" target="'.$frame_top.'">'.
152 _("Go to the login page") . '</a></b></font></td></tr>'.
153 '</table></td></tr></table></center></body></html>';
9be8198d 154}
155
d5f3892b 156/**
157 * Displays error message
158 *
159 * Since 1.4.1 function checks if page header is already displayed.
160 * Since 1.4.3 and 1.5.1 function contains error_box hook.
161 * Use plain_error_message() and make sure that page header is created,
162 * if you want compatibility with 1.4.0 and older.
163 * @param string $string
164 * @param array $color
165 * @since 1.3.2
166 */
fd2611e9 167function error_box($string, $color) {
b6c283c4 168 global $pageheader_sent;
169
a429618b 170 if ( !isset( $color ) ) {
171 $color = array();
2ea16421 172 $color[0] = '#dcdcdc'; /* light gray TitleBar */
a429618b 173 $color[1] = '#800000'; /* red */
2ea16421 174 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
175 $color[4] = '#ffffff'; /* white Normal Background */
176 $color[7] = '#0000cc'; /* blue Links */
a429618b 177 $color[8] = '#000000'; /* black Normal text */
2ea16421 178 $color[9] = '#ababab'; /* mid-gray Darker version of #0 */
a429618b 179 }
180
b6c283c4 181 $err = _("ERROR");
182
7753dac4 183 $ret = concat_hook_function('error_box', $string);
184 if($ret != '') {
185 $string = $ret;
186 }
8d42e09a 187
b6c283c4 188 /* check if the page header has been sent; if not, send it! */
189 if(!isset($pageheader_sent) && !$pageheader_sent) {
190 /* include this just to be sure */
191 include_once( SM_PATH . 'functions/page_header.php' );
192 displayHtmlHeader('SquirrelMail: '.$err);
193 $pageheader_sent = TRUE;
194 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
195 }
196
2ea16421 197 echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'.
198 '<tr><td>'.
199 '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'.
200 '<tr><td align="center" bgcolor="'.$color[0].'">'.
201 '<font color="'.$color[2].'"><b>' . $err . ':</b></font>'.
202 '</td></tr><tr><td>'.
203 '<table cellpadding="1" cellspacing="5" align="center" border="0">'.
204 '<tr>' . html_tag( 'td', $string."\n", 'left') . '</tr></table>'.
205 '</td></tr></table></td></tr></table>';
fd2611e9 206}
6c92ca88 207
288df1a0 208/**
209 * Adds message that informs about non fatal error that can happen while saving preferences
210 * @param string $message error message
b31af6df 211 * @since 1.5.1 and 1.4.5
288df1a0 212 */
213function error_option_save($message) {
214 global $optpage_save_error;
215
216 if (! is_array($optpage_save_error) )
91e0dccc 217 $optpage_save_error=array();
288df1a0 218
219 $optpage_save_error=array_merge($optpage_save_error,array($message));
220}
6c92ca88 221// vim: et ts=4
f8a1ed5a 222?>