implementing #20
This commit is contained in:
parent
9f1caed052
commit
2346076e72
|
|
@ -8,7 +8,7 @@
|
|||
+---------------------------------------------------------*/
|
||||
|
||||
require_once "config.php";
|
||||
$civiproxy_version = '0.5.beta1';
|
||||
$civiproxy_version = '0.5.beta1+dev20';
|
||||
$civiproxy_logo = "<img src='{$proxy_base}/static/images/proxy-logo.png' alt='SYSTOPIA Organisationsberatung'></img>";
|
||||
|
||||
/**
|
||||
|
|
@ -165,17 +165,12 @@ function civiproxy_security_check($target, $quit=TRUE) {
|
|||
*
|
||||
* @param $valid_parameters array '<parameter name> => '<expected type>'
|
||||
* where type can be 'int', 'string' (unchecked),
|
||||
* @param $request provides the request data to use,
|
||||
* defaults to $_REQUEST
|
||||
*/
|
||||
function civiproxy_get_parameters($valid_parameters) {
|
||||
function civiproxy_get_parameters($valid_parameters, $request = NULL) {
|
||||
if ($request === NULL) {
|
||||
$request = $_REQUEST;
|
||||
|
||||
// explode civicrm's json parameter
|
||||
global $evaluate_json_parameter;
|
||||
if (!emtpy($evaluate_json_parameter) && isset($request['json'])) {
|
||||
$json_data = json_decode($request['json']);
|
||||
if (is_array($json_data)) {
|
||||
$request = $request + $json_data;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
|
|
@ -231,6 +226,14 @@ function civiproxy_sanitise($value, $type) {
|
|||
error_log("CiviProxy: removed invalid email parameter: " . $value);
|
||||
$value = '';
|
||||
}
|
||||
} elseif ($type == 'json') {
|
||||
// valid json
|
||||
$json_data = json_decode($value);
|
||||
if ($json_data === NULL) {
|
||||
$value = '';
|
||||
} else {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
} elseif (is_array($type)) {
|
||||
// this is a list of valid options
|
||||
$requested_value = $value;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,18 @@ foreach ($action as $key => $value) {
|
|||
$parameters[$key] = $value;
|
||||
}
|
||||
|
||||
// evaluate the JSON parameter
|
||||
global $evaluate_json_parameter;
|
||||
if ($evaluate_json_parameter) {
|
||||
if (isset($_REQUEST['json'])) {
|
||||
$json_data = json_decode($_REQUEST['json']);
|
||||
if (!empty($json_data)) {
|
||||
$json_parameters = civiproxy_get_parameters($valid_parameters, $json_data);
|
||||
$parameters['json'] = json_encode($json_parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// finally execute query
|
||||
civiproxy_redirect($target_rest, $parameters);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue