Merge pull request #4123 from eileenmcnaughton/CRM-15296
[civicrm-core.git] / CRM / Utils / Request.php
index d0386b2d03092e20e2c5fd6d5c9a7ac8cbceee69..eea57653e1d1168c4175d6cb529482e3a8780515 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -57,17 +57,16 @@ class CRM_Utils_Request {
   /**
    * Retrieve a value from the request (GET/POST/REQUEST)
    *
-   * @param $name    name of the variable to be retrieved
-   * @param $type    type of the variable (see CRM_Utils_Type for details)
-   * @param $store   session scope where variable is stored
-   * @param $abort   is this variable required
-   * @param $default default value of the variable if not present
-   * @param $method  where should we look for the variable
+   * @param string $name name of the variable to be retrieved
+   * @param string $type  type of the variable (see CRM_Utils_Type for details)
+   * @param stdClass $store session scope where variable is stored
+   * @param bool $abort is this variable required
+   * @param mixed $default default value of the variable if not present
+   * @param string $method where should we look for the variable
    *
    * @return mixed the value of the variable
    * @access public
    * @static
-   *
    */
   static function retrieve($name, $type, &$store = NULL, $abort = FALSE, $default = NULL, $method = 'REQUEST') {
 
@@ -121,5 +120,28 @@ class CRM_Utils_Request {
 
     return $value;
   }
+
+  /**
+   * This is a replacement for $_REQUEST which includes $_GET/$_POST
+   * but excludes $_COOKIE / $_ENV / $_SERVER.
+   *
+   * @internal param string $method
+   * @return array
+   */
+  static function exportValues() {
+    // For more discussion of default $_REQUEST handling, see:
+    // http://www.php.net/manual/en/reserved.variables.request.php
+    // http://www.php.net/manual/en/ini.core.php#ini.request-order
+    // http://www.php.net/manual/en/ini.core.php#ini.variables-order
+
+    $result = array();
+    if ($_GET) {
+      $result = array_merge($result, $_GET);
+    }
+    if ($_POST) {
+      $result = array_merge($result, $_POST);
+    }
+    return $result;
+  }
 }