Moving addressbook functions to separate phpdoc subpackage.
[squirrelmail.git] / functions / display_messages.php
CommitLineData
59177427 1<?php
2ba13803 2
35586184 3/**
4 * display_messages.php
5 *
82d304a0 6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
35586184 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$
d6c32258 13 * @package squirrelmail
35586184 14 */
3302d0d4 15
ebb9eaaf 16require_once(SM_PATH . 'functions/plugin.php');
17
18
c94b297c 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 *
d6c32258 25 * @return string the base uri of squirrelmail installation.
c94b297c 26 */
399846ea 27function sqm_baseuri(){
28 global $base_uri, $PHP_SELF;
c94b297c 29 /**
30 * If it is in the session, just return it.
31 */
399846ea 32 if (isset($base_uri)){
33 return $base_uri;
34 }
7e156b3d 35 $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
36 $repl = array('', '', '');
399846ea 37 $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
38 return $base_uri;
39}
40
ec5b189b 41function error_message($message, $mailbox, $sort, $startMessage, $color) {
42 $urlMailbox = urlencode($mailbox);
fd2611e9 43 $string = '<tr><td ALIGN="center">' . $message . '</td></tr>'."\n".
44 '<tr><td ALIGN="center">'.
45 '<A HREF="' . sqm_baseuri()
90d3887e 46 . "src/right_main.php?sort=$sort&amp;startMessage=$startMessage"
fd2611e9 47 . "&amp;mailbox=$urlMailbox\">" .
42c2281a 48 sprintf (_("Click here to return to %s"), strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)) .
fd2611e9 49 '</A></td></tr>';
50 error_box($string, $color);
ec5b189b 51}
aa4c3749 52
ec5b189b 53function plain_error_message($message, $color) {
fd2611e9 54 error_box($message, $color);
ec5b189b 55}
b6d8d08d 56
9be8198d 57function logout_error( $errString, $errTitle = '' ) {
1f05436e 58 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
35185c82 59 $hide_sm_attributions, $version, $squirrelmail_language;
60
399846ea 61 $base_uri = sqm_baseuri();
26f9a94a 62
63 include_once( SM_PATH . 'functions/page_header.php' );
9be8198d 64 if ( !isset( $org_logo ) ) {
65 // Don't know yet why, but in some accesses $org_logo is not set.
26f9a94a 66 include( SM_PATH . 'config/config.php' );
9be8198d 67 }
68 /* Display width and height like good little people */
69 $width_and_height = '';
e16cb07b 70 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
9be8198d 71 $width_and_height = " WIDTH=\"$org_logo_width\"";
72 }
e16cb07b 73 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
9be8198d 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 */
9be8198d 86 $color[4] = '#FFFFFF'; /* white Normal Background */
9be8198d 87 $color[7] = '#0000CC'; /* blue Links */
88 $color[8] = '#000000'; /* black Normal text */
9be8198d 89 }
90
8d42e09a 91 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
92
9be8198d 93 if ( $errTitle == '' ) {
94 $errTitle = $errString;
95 }
96 set_up_language($squirrelmail_language, true);
1f05436e 97
98 displayHtmlHeader( $errTitle, '', false );
99
9be8198d 100 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" .
4cbcaebd 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 ? '' :
9be8198d 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>".
c9062c05 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>".
c94b297c 118 '<a href="' . $base_uri . 'src/login.php" target="' .
119 $frame_top . '">' .
c9062c05 120 _("Go to the login page") . "</a></B></FONT>".
9be8198d 121 '</TD></TR>'.
1f05436e 122 '</TABLE></td></tr></table></center></body></html>';
9be8198d 123}
124
fd2611e9 125function error_box($string, $color) {
b6c283c4 126 global $pageheader_sent;
127
128 $err = _("ERROR");
129
7753dac4 130 $ret = concat_hook_function('error_box', $string);
131 if($ret != '') {
132 $string = $ret;
133 }
8d42e09a 134
b6c283c4 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
36ec6865 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].'">';
472e7acb 148 echo ' <font color="' . $color[2].'"><b>' . $err . ':</b></font>';
36ec6865 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>';
bbc2c67d 155 echo ' </td></tr>';
36ec6865 156 echo ' </table></td></tr>';
157 echo ' </table>';
fd2611e9 158}
6a6ce0a3 159?>