phpdoc updates
[squirrelmail.git] / functions / display_messages.php
1 <?php
2
3 /**
4 * display_messages.php
5 *
6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This contains all messages, including information, error, and just
10 * about any other message you can think of.
11 *
12 * $Id$
13 * @package squirrelmail
14 */
15
16 require_once(SM_PATH . 'functions/plugin.php');
17
18
19 /**
20 * Find out where squirrelmail lives and try to be smart about it.
21 * The only problem would be when squirrelmail lives in directories
22 * called "src", "functions", or "plugins", but people who do that need
23 * to be beaten with a steel pipe anyway.
24 *
25 * @return string the base uri of squirrelmail installation.
26 */
27 function sqm_baseuri(){
28 global $base_uri, $PHP_SELF;
29 /**
30 * If it is in the session, just return it.
31 */
32 if (isset($base_uri)){
33 return $base_uri;
34 }
35 $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
36 $repl = array('', '', '');
37 $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
38 return $base_uri;
39 }
40
41 function error_message($message, $mailbox, $sort, $startMessage, $color) {
42 $urlMailbox = urlencode($mailbox);
43 $string = '<tr><td ALIGN="center">' . $message . '</td></tr>'."\n".
44 '<tr><td ALIGN="center">'.
45 '<A HREF="' . sqm_baseuri()
46 . "src/right_main.php?sort=$sort&amp;startMessage=$startMessage"
47 . "&amp;mailbox=$urlMailbox\">" .
48 sprintf (_("Click here to return to %s"), strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)) .
49 '</A></td></tr>';
50 error_box($string, $color);
51 }
52
53 function plain_error_message($message, $color) {
54 error_box($message, $color);
55 }
56
57 function logout_error( $errString, $errTitle = '' ) {
58 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
59 $hide_sm_attributions, $version, $squirrelmail_language;
60
61 $base_uri = sqm_baseuri();
62
63 include_once( SM_PATH . 'functions/page_header.php' );
64 if ( !isset( $org_logo ) ) {
65 // Don't know yet why, but in some accesses $org_logo is not set.
66 include( SM_PATH . 'config/config.php' );
67 }
68 /* Display width and height like good little people */
69 $width_and_height = '';
70 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
71 $width_and_height = " WIDTH=\"$org_logo_width\"";
72 }
73 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
74 $width_and_height .= " HEIGHT=\"$org_logo_height\"";
75 }
76
77 if (!isset($frame_top) || $frame_top == '' ) {
78 $frame_top = '_top';
79 }
80
81 if ( !isset( $color ) ) {
82 $color = array();
83 $color[0] = '#DCDCDC'; /* light gray TitleBar */
84 $color[1] = '#800000'; /* red */
85 $color[2] = '#CC0000'; /* light red Warning/Error Messages */
86 $color[4] = '#FFFFFF'; /* white Normal Background */
87 $color[7] = '#0000CC'; /* blue Links */
88 $color[8] = '#000000'; /* black Normal text */
89 }
90
91 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
92
93 if ( $errTitle == '' ) {
94 $errTitle = $errString;
95 }
96 set_up_language($squirrelmail_language, true);
97
98 displayHtmlHeader( $errTitle, '', false );
99
100 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" .
101 '<CENTER>';
102
103 if (isset($org_logo) && ($org_logo != '')) {
104 echo "<IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) .
105 "\"$width_and_height><BR>\n";
106 }
107 echo ( $hide_sm_attributions ? '' :
108 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
109 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
110 "<table cellspacing=1 cellpadding=0 bgcolor=\"$color[1]\" width=\"70%\"><tr><td>".
111 "<TABLE WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
112 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
113 "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") .
114 '</B></FONT></TD></TR>'.
115 '<TR><TD ALIGN="center">' . $errString . '</TD></TR>'.
116 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
117 "<FONT COLOR=\"$color[2]\"><B>".
118 '<a href="' . $base_uri . 'src/login.php" target="' .
119 $frame_top . '">' .
120 _("Go to the login page") . "</a></B></FONT>".
121 '</TD></TR>'.
122 '</TABLE></td></tr></table></center></body></html>';
123 }
124
125 function error_box($string, $color) {
126 global $pageheader_sent;
127
128 $err = _("ERROR");
129
130 $ret = concat_hook_function('error_box', $string);
131 if($ret != '') {
132 $string = $ret;
133 }
134
135 /* check if the page header has been sent; if not, send it! */
136 if(!isset($pageheader_sent) && !$pageheader_sent) {
137 /* include this just to be sure */
138 include_once( SM_PATH . 'functions/page_header.php' );
139 displayHtmlHeader('SquirrelMail: '.$err);
140 $pageheader_sent = TRUE;
141 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
142 }
143
144 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
145 echo ' <tr><td>';
146 echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
147 echo ' <tr><td ALIGN="center" bgcolor="'.$color[0].'">';
148 echo ' <font color="' . $color[2].'"><b>' . $err . ':</b></font>';
149 echo ' </td></tr>';
150 echo ' <tr><td>';
151 echo ' <table cellpadding="1" cellspacing="5" align="center" border="0">';
152 echo ' <tr>' . html_tag( 'td', $string."\n", 'left')
153 . '</tr>';
154 echo ' </table>';
155 echo ' </td></tr>';
156 echo ' </table></td></tr>';
157 echo ' </table>';
158 }
159 ?>