Make use of mailbox cache because flag info is updated in the mailbox cache
[squirrelmail.git] / functions / display_messages.php
index f0c79f254c31a4fa4a8561f14910f7ebef8edb2e..c1c54c46231e479167739b0f0d7919b1d290ec38 100644 (file)
 
 /**
  * Displays error message and URL to message listing
+ *
+ * Fifth argument ($color array) is removed in 1.5.2.
  * @param string $message error message
  * @param string $mailbox mailbox name
  * @param integer $sort sort order
  * @param integer $startMessage first message
- * @param array $color color theme
  * @since 1.0
  */
 function error_message($message, $mailbox, $sort, $startMessage) {
     $urlMailbox = urlencode($mailbox);
-    $link = array   (
-                        'URL'   => sqm_baseuri()."src/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox",
-                        'TEXT'  => sprintf (_("Click here to return to %s"), strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)) 
-                    );
+    $link = array (
+        'URL'   => sqm_baseuri()."src/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox",
+        'TEXT'  => sprintf (_("Click here to return to %s"),
+                            strtoupper($mailbox) == 'INBOX' ? _("INBOX") : htmlspecialchars(imap_utf7_decode_local($mailbox))) 
+                   );
     error_box($message, $link);
 }
 
 /**
  * Displays error message
+ * 
+ * Second argument ($color array) is removed in 1.5.2.
  * @param string $message error message
- * @param array $color color theme
  * @since 1.0
  */
 function plain_error_message($message) {
@@ -55,7 +58,14 @@ function logout_error( $errString, $errTitle = '' ) {
 
     $base_uri = sqm_baseuri();
 
-    list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
+    $login_link = array (
+                            'URI'   => $base_uri . 'src/login.php',
+                            'FRAME' => $frame_top
+                        );
+                        
+    /* As of 1.5.2, plugin parameters are combined into one array; 
+       plugins on this hook must be updated */
+    do_hook('logout_error', $temp=array(&$errString, &$errTitle, &$login_link));
 
     if ( $errTitle == '' ) {
         $errTitle = $errString;
@@ -91,11 +101,6 @@ function logout_error( $errString, $errTitle = '' ) {
                             _("By the SquirrelMail Project Team")."<br />\n";
     }
 
-    $login_link = array (
-                            'URL'   => $base_uri . 'src/login.php',
-                            'FRAME' => $frame_top
-                        );
-                        
     $oTemplate->assign('logo_str', $logo_str);
     $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
     $oTemplate->assign('login_link', $login_link);
@@ -109,24 +114,31 @@ function logout_error( $errString, $errTitle = '' ) {
  * Displays error message
  * 
  * Since 1.4.1 function checks if page header is already displayed.
- * Since 1.4.3 and 1.5.1 function contains error_box hook.
+ * 
+ * Since 1.4.3 and 1.5.1, this function contains the error_box hook.
  * Use plain_error_message() and make sure that page header is created,
  * if you want compatibility with 1.4.0 and older.
+ *
+ * In 1.5.2 second function argument is changed. Older functions used it
+ * for $color array, new function uses it for optional link data. Function 
+ * will ignore color array and use standard colors instead.
+ *
  * @param string $string Error message to be displayed
- * @param mixed $link Optional array containing link details to be displayed
+ * @param array $link Optional array containing link details to be displayed.
+ *  Array uses three keys. 'URL' key is required and should contain link URL.
+ *  'TEXT' key is optional and should contain link name. 'FRAME' key is 
+ *  optional and should contain link target attribute.
+ *
  * @since 1.3.2
  */
 function error_box($string, $link=NULL) {
     global $pageheader_sent, $oTemplate;
 
     $err = _("ERROR");
-    $ret = concat_hook_function('error_box', $string);
-    if($ret != '') {
-        $string = $ret;
-    }
+    do_hook('error_box', $string);
 
     /* check if the page header has been sent; if not, send it! */
-    if(!isset($pageheader_sent) && !$pageheader_sent) {
+    if (!isset($pageheader_sent) && !$pageheader_sent) {
         displayHtmlHeader('SquirrelMail: '.$err);
         $pageheader_sent = TRUE;
         echo "<body>\n\n";
@@ -134,10 +146,14 @@ function error_box($string, $link=NULL) {
 
     // Double check the link for everything we need
     if (!is_null($link)) {
-        if (!isset($link['FRAME']))
-            $link['FRAME'] = '';
-        if (!isset($link['TEXT']))
-            $link['TEXT'] = $link['URL'];
+        // safety check for older code
+        if (isset($link['URL'])) {
+            if (!isset($link['FRAME'])) $link['FRAME'] = '';
+            if (!isset($link['TEXT'])) $link['TEXT'] = $link['URL'];
+        } else {
+            // somebody used older error_box() code
+            $link=null;
+        }
     }
     
     /** ERROR is pre-translated to avoid multiple translation calls. **/