display_messages.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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) {
  23. $urlMailbox = urlencode($mailbox);
  24. $link = array (
  25. 'URL' => sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox",
  26. 'TEXT' => sprintf (_("Click here to return to %s"), strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox))
  27. );
  28. error_box($message, $link);
  29. }
  30. /**
  31. * Displays error message
  32. * @param string $message error message
  33. * @param array $color color theme
  34. * @since 1.0
  35. */
  36. function plain_error_message($message) {
  37. error_box($message);
  38. }
  39. /**
  40. * Displays error when user is logged out
  41. *
  42. * Error strings can be overriden by logout_error hook
  43. * @param string $errString error message
  44. * @param string $errTitle title of page with error message
  45. * @since 1.2.6
  46. */
  47. function logout_error( $errString, $errTitle = '' ) {
  48. global $frame_top, $org_logo, $org_logo_width, $org_logo_height, $org_name,
  49. $hide_sm_attributions, $squirrelmail_language, $oTemplate;
  50. $base_uri = sqm_baseuri();
  51. list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
  52. if ( $errTitle == '' ) {
  53. $errTitle = $errString;
  54. }
  55. set_up_language($squirrelmail_language, true);
  56. displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
  57. /* If they don't have a logo, don't bother.. */
  58. $logo_str = '';
  59. if (isset($org_logo) && $org_logo) {
  60. /* Display width and height like good little people */
  61. $width_and_height = '';
  62. if (isset($org_logo_width) && is_numeric($org_logo_width) &&
  63. $org_logo_width>0) {
  64. $width_and_height = " width=\"$org_logo_width\"";
  65. }
  66. if (isset($org_logo_height) && is_numeric($org_logo_height) &&
  67. $org_logo_height>0) {
  68. $width_and_height .= " height=\"$org_logo_height\"";
  69. }
  70. $logo_str = '<img src="'.$org_logo.'" ' .
  71. 'alt="'. sprintf(_("%s Logo"), $org_name).'" ' .
  72. $width_and_height .
  73. 'class="sqm_loginImage" ' .
  74. ' /><br />'."\n";
  75. }
  76. $sm_attribute_str = '';
  77. if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
  78. $sm_attribute_str = _("SquirrelMail Webmail Application")."<br />\n" .
  79. _("By the SquirrelMail Project Team")."<br />\n";
  80. }
  81. $login_link = array (
  82. 'URL' => $base_uri . 'src/login.php',
  83. 'FRAME' => $frame_top
  84. );
  85. $oTemplate->assign('logo_str', $logo_str);
  86. $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
  87. $oTemplate->assign('login_link', $login_link);
  88. $oTemplate->assign('errorMessage', $errString);
  89. $oTemplate->display('error_logout.tpl');
  90. $oTemplate->display('footer.tpl');
  91. }
  92. /**
  93. * Displays error message
  94. *
  95. * Since 1.4.1 function checks if page header is already displayed.
  96. * Since 1.4.3 and 1.5.1 function contains error_box hook.
  97. * Use plain_error_message() and make sure that page header is created,
  98. * if you want compatibility with 1.4.0 and older.
  99. * @param string $string Error message to be displayed
  100. * @param mixed $link Optional array containing link details to be displayed
  101. * @since 1.3.2
  102. */
  103. function error_box($string, $link=NULL) {
  104. global $pageheader_sent, $oTemplate;
  105. $err = _("ERROR");
  106. $ret = concat_hook_function('error_box', $string);
  107. if($ret != '') {
  108. $string = $ret;
  109. }
  110. /* check if the page header has been sent; if not, send it! */
  111. if(!isset($pageheader_sent) && !$pageheader_sent) {
  112. displayHtmlHeader('SquirrelMail: '.$err);
  113. $pageheader_sent = TRUE;
  114. echo "<body>\n\n";
  115. }
  116. // Double check the link for everything we need
  117. if (!is_null($link)) {
  118. if (!isset($link['FRAME']))
  119. $link['FRAME'] = '';
  120. if (!isset($link['TEXT']))
  121. $link['TEXT'] = $link['URL'];
  122. }
  123. /** ERROR is pre-translated to avoid multiple translation calls. **/
  124. $oTemplate->assign('error', $err);
  125. $oTemplate->assign('errorMessage', $string);
  126. $oTemplate->assign('link', $link);
  127. $oTemplate->display('error_box.tpl');
  128. }
  129. /**
  130. * Adds message that informs about non fatal error that can happen while saving preferences
  131. * @param string $message error message
  132. * @since 1.5.1 and 1.4.5
  133. */
  134. function error_option_save($message) {
  135. global $optpage_save_error;
  136. if (! is_array($optpage_save_error) )
  137. $optpage_save_error=array();
  138. $optpage_save_error=array_merge($optpage_save_error,array($message));
  139. }