- Fix URL for Read Receipts being incorrect in some cases (#1177518).
[squirrelmail.git] / functions / display_messages.php
index f0c79f254c31a4fa4a8561f14910f7ebef8edb2e..07efba1cbe773e2d0e84bfc31f280b05ae29e450 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) {
@@ -109,11 +112,19 @@ 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.
  * 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) {
@@ -134,10 +145,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. **/