3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * class for managing a http request
40 class CRM_Utils_Request
{
43 * We only need one instance of this object. So we use the singleton
44 * pattern and cache the instance in this variable
50 static private $_singleton = NULL;
55 function __construct() {}
58 * Retrieve a value from the request (GET/POST/REQUEST)
60 * @param string $name name of the variable to be retrieved
61 * @param string $type type of the variable (see CRM_Utils_Type for details)
62 * @param stdClass $store session scope where variable is stored
63 * @param bool $abort is this variable required
64 * @param mixed $default default value of the variable if not present
65 * @param string $method where should we look for the variable
67 * @return mixed the value of the variable
71 static function retrieve($name, $type, &$store = NULL, $abort = FALSE, $default = NULL, $method = 'REQUEST') {
73 // hack to detect stuff not yet converted to new style
74 if (!is_string($type)) {
75 CRM_Core_Error
::backtrace();
76 CRM_Core_Error
::fatal(ts("Please convert retrieve call to use new function signature"));
82 $value = CRM_Utils_Array
::value($name, $_GET);
86 $value = CRM_Utils_Array
::value($name, $_POST);
90 $value = CRM_Utils_Array
::value($name, $_REQUEST);
95 (CRM_Utils_Type
::validate($value, $type, $abort, $name) === NULL)
100 if (!isset($value) && $store) {
101 $value = $store->get($name);
104 if (!isset($value) && $abort) {
105 CRM_Core_Error
::fatal(ts("Could not find valid value for %1", array(1 => $name)));
108 if (!isset($value) && $default) {
112 // minor hack for action
113 if ($name == 'action' && is_string($value)) {
114 $value = CRM_Core_Action
::resolve($value);
117 if (isset($value) && $store) {
118 $store->set($name, $value);
125 * This is a replacement for $_REQUEST which includes $_GET/$_POST
126 * but excludes $_COOKIE / $_ENV / $_SERVER.
128 * @internal param string $method
131 static function exportValues() {
132 // For more discussion of default $_REQUEST handling, see:
133 // http://www.php.net/manual/en/reserved.variables.request.php
134 // http://www.php.net/manual/en/ini.core.php#ini.request-order
135 // http://www.php.net/manual/en/ini.core.php#ini.variables-order
139 $result = array_merge($result, $_GET);
142 $result = array_merge($result, $_POST);