Fix visibility on legacy functions
[civicrm-core.git] / CRM / Utils / Request.php
index c08f10b99ba1a198d0b223d1d92d95fa56f06bd9..2748e07d7df8e2c16d361009ff96d2e1a6f7ae9e 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016                                |
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  */
 
 /**
@@ -94,15 +94,15 @@ class CRM_Utils_Request {
     $value = NULL;
     switch ($method) {
       case 'GET':
-        $value = CRM_Utils_Array::value($name, $_GET);
+        $value = self::getValue($name, $_GET);
         break;
 
       case 'POST':
-        $value = CRM_Utils_Array::value($name, $_POST);
+        $value = self::getValue($name, $_POST);
         break;
 
       default:
-        $value = CRM_Utils_Array::value($name, $_REQUEST);
+        $value = self::getValue($name, $_REQUEST);
         break;
     }
 
@@ -136,6 +136,34 @@ class CRM_Utils_Request {
     return $value;
   }
 
+  /**
+   * @param string $name
+   *   Name of the variable to be retrieved.
+   *
+   * @param array $method - '$_GET', '$_POST' or '$_REQUEST'.
+   *
+   * @return mixed
+   *    The value of the variable
+   */
+  public static function getValue($name, $method) {
+    if (isset($method[$name])) {
+      return $method[$name];
+    }
+    // CRM-18384 - decode incorrect keys generated when & is present in url
+    foreach ($method as $key => $value) {
+      if (strpos($key, 'amp;') !== FALSE) {
+        $method[str_replace('amp;', '', $key)] = $method[$key];
+        if (isset($method[$name])) {
+          return $method[$name];
+        }
+        else {
+          continue;
+        }
+      }
+    }
+    return NULL;
+  }
+
   /**
    * This is a replacement for $_REQUEST which includes $_GET/$_POST
    * but excludes $_COOKIE / $_ENV / $_SERVER.