get($name); } if (!isset($value) && $abort) { if ($isThrowException) { throw new CRM_Core_Exception(ts("Could not find valid value for %1", array(1 => $name))); } CRM_Core_Error::fatal(ts("Could not find valid value for %1", array(1 => $name))); } if (!isset($value) && $default) { $value = $default; } // minor hack for action if ($name == 'action' && is_string($value)) { $value = CRM_Core_Action::resolve($value); } if (isset($value) && $store) { $store->set($name, $value); } 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 */ protected 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; } /** * @deprecated * * We should use a function that checks url values. * * This is a replacement for $_REQUEST which includes $_GET/$_POST * but excludes $_COOKIE / $_ENV / $_SERVER. * * @return array */ public 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; } /** * Retrieve a variable from the http request. * * @param string $name * Name of the variable to be retrieved. * @param string $type * Type of the variable (see CRM_Utils_Type for details). * Most common options are: * - 'Integer' * - 'Positive' * - 'CommaSeparatedIntegers' * - 'Boolean' * - 'String' * * @param mixed $defaultValue * Default value of the variable if not present. * @param bool $isRequired * Is the variable required for this function to proceed without an exception. * @param string $method * Where to look for the value - GET|POST|REQUEST * * @return mixed */ public static function retrieveValue($name, $type, $defaultValue = NULL, $isRequired = FALSE, $method = 'REQUEST') { $null = NULL; return CRM_Utils_Request::retrieve((string) $name, (string) $type, $null, (bool) $isRequired, $defaultValue, $method, TRUE); } }