display_messages.php 5.9 KB

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