Source for file display_messages.php

Documentation is available at display_messages.php

  1. <?php
  2.  
  3. /**
  4.  * display_messages.php
  5.  *
  6.  * This contains all messages, including information, error, and just
  7.  * about any other message you can think of.
  8.  *
  9.  * @copyright 1999-2020 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: display_messages.php 14845 2020-01-07 08:09:34Z pdontthink $
  12.  * @package squirrelmail
  13.  */
  14.  
  15.  
  16. /**
  17.  * Displays error message and URL to message listing
  18.  *
  19.  * Fifth argument ($color array) is removed in 1.5.2.
  20.  * @param string $message error message
  21.  * @param string $mailbox mailbox name
  22.  * @param integer $sort sort order
  23.  * @param integer $startMessage first message
  24.  * @since 1.0
  25.  */
  26. function error_message($message, $mailbox, $sort, $startMessage) {
  27.     $urlMailbox = urlencode($mailbox);
  28.     $link = array (
  29.         'URL'   => sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox",
  30.         'TEXT'  => sprintf (_("Click here to return to %s"),
  31.                             strtoupper($mailbox) == 'INBOX' ? _("INBOX") : sm_encode_html_special_chars(imap_utf7_decode_local($mailbox))) 
  32.                    );
  33.     error_box($message, $link);
  34. }
  35.  
  36. /**
  37.  * Displays error message
  38.  * 
  39.  * Second argument ($color array) is changed to boolean $return_output as of 1.5.2.
  40.  *
  41.  * @param string $message error message
  42.  * @param boolean $return_output When TRUE, output is returned to caller
  43.  *                                instead of being sent to browser (OPTIONAL;
  44.  *                                default = FALSE)
  45.  * @since 1.0
  46.  */
  47. function plain_error_message($message, $return_output=FALSE) {
  48.     return error_box($message, NULL, $return_output);
  49. }
  50.  
  51. /**
  52.  * Displays error when user is logged out
  53.  * 
  54.  * Error strings can be overriden by logout_error hook
  55.  * @param string $errString error message
  56.  * @param string $errTitle title of page with error message
  57.  * @since 1.2.6
  58.  */
  59. function logout_error( $errString, $errTitle = '' ) {
  60.            $hide_sm_attributions, $squirrelmail_language, $oTemplate, $base_uri;
  61.  
  62.     $login_link = array (
  63.                             'URI'   => $base_uri . 'src/login.php',
  64.                             'FRAME' => $frame_top
  65.                         );
  66.                         
  67.     /* As of 1.5.2, plugin parameters are combined into one array; 
  68.        plugins on this hook must be updated */
  69.     $temp = array(&$errString, &$errTitle, &$login_link);
  70.     do_hook('logout_error', $temp);
  71.  
  72.     if ( $errTitle == '' ) {
  73.         $errTitle = $errString;
  74.     }
  75.     set_up_language($squirrelmail_language, true);
  76.  
  77.     displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
  78.  
  79.     /* If they don't have a logo, don't bother.. */
  80.     $logo_str = '';
  81.     if (isset($org_logo) && $org_logo) {
  82.  
  83.         if (isset($org_logo_width) && is_numeric($org_logo_width) &&
  84.          $org_logo_width>0) {
  85.             $width = $org_logo_width;
  86.         } else {
  87.             $width = '';
  88.         }
  89.         if (isset($org_logo_height) && is_numeric($org_logo_height) &&
  90.          $org_logo_height>0) {
  91.             $height = $org_logo_height;
  92.         } else {
  93.             $height = '';
  94.         }
  95.  
  96.         $logo_str = create_image($org_logo, sprintf(_("%s Logo"), $org_name),
  97.                                  $width, $height, '', 'sqm_loginImage');
  98.  
  99.     }
  100.     
  101.     $sm_attribute_str = '';
  102.     if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
  103.         $sm_attribute_str = _("SquirrelMail Webmail") . "\n" 
  104.                           . _("By the SquirrelMail Project Team");
  105.     }
  106.  
  107.     $oTemplate->assign('logo_str', $logo_str);
  108.     $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
  109.     $oTemplate->assign('login_link', $login_link);
  110.     $oTemplate->assign('errorMessage', $errString);
  111.     $oTemplate->display('error_logout.tpl');
  112.  
  113.     $oTemplate->display('footer.tpl');
  114. }
  115.  
  116. /**
  117.  * Displays error message
  118.  * 
  119.  * Since 1.4.1 function checks if page header is already displayed.
  120.  * 
  121.  * Since 1.4.3 and 1.5.1, this function contains the error_box hook.
  122.  * Use plain_error_message() and make sure that page header is created,
  123.  * if you want compatibility with 1.4.0 and older.
  124.  *
  125.  * In 1.5.2 second function argument is changed. Older functions used it
  126.  * for $color array, new function uses it for optional link data. Function
  127.  * will ignore color array and use standard colors instead.
  128.  *
  129.  * The $return_output argument was added in 1.5.2
  130.  *
  131.  * @param string $string Error message to be displayed
  132.  * @param array $link Optional array containing link details to be displayed.
  133.  *   Array uses three keys. 'URL' key is required and should contain link URL.
  134.  *   'TEXT' key is optional and should contain link name. 'FRAME' key is
  135.  *   optional and should contain link target attribute.
  136.  * @param boolean $return_output When TRUE, output is returned to caller
  137.  *                                instead of being sent to browser (OPTIONAL;
  138.  *                                default = FALSE)
  139.  *
  140.  * @since 1.3.2
  141.  */
  142. function error_box($string, $link=NULL, $return_output=FALSE) {
  143.     global $pageheader_sent, $oTemplate, $org_title;
  144.  
  145.     $err = _("ERROR");
  146.     do_hook('error_box', $string);
  147.     if ( !isset($org_title) ) $org_title = 'SquirrelMail';
  148.  
  149.     // check if the page header has been sent; if not, send it!
  150.     //
  151.     // (however, if $return_output is turned on, the output of this
  152.     // should be being used in some other page, so we don't have
  153.     // to worry about page headers in that case)
  154.     //
  155.     if (!$return_output && empty($pageheader_sent)) {
  156.         displayHtmlHeader($org_title . ': '.$err);
  157.         $pageheader_sent = TRUE;
  158.         echo create_body();  // this is template-safe (see create_body() function)
  159.     }
  160.  
  161.     // Double check the link for everything we need
  162.     if (!is_null($link)) {
  163.         // safety check for older code
  164.         if (isset($link['URL'])) {
  165.             if (!isset($link['FRAME'])) $link['FRAME'] = '';
  166.             if (!isset($link['TEXT'])) $link['TEXT'] = $link['URL'];
  167.         } else {
  168.             // somebody used older error_box() code
  169.             $link=null;
  170.         }
  171.     }
  172.     
  173.     /** ERROR is pre-translated to avoid multiple translation calls. **/
  174.     $oTemplate->assign('error', $err);
  175.     $oTemplate->assign('errorMessage', $string);
  176.     $oTemplate->assign('link', $link);
  177.     $output = $oTemplate->fetch('error_box.tpl');
  178.  
  179.     if ($return_output) return $output;
  180.     echo $output;
  181. }
  182.  
  183. /**
  184.  * Adds message that informs about non fatal error that can happen while saving preferences
  185.  * @param string $message error message
  186.  * @since 1.5.1 and 1.4.5
  187.  */
  188. function error_option_save($message) {
  189.     global $optpage_save_error;
  190.  
  191.     if (! is_array($optpage_save_error) )
  192.         $optpage_save_error=array();
  193.  
  194.     $optpage_save_error=array_merge($optpage_save_error,array($message));
  195. }

Documentation generated on Mon, 13 Jan 2020 04:22:24 +0100 by phpDocumentor 1.4.3