implementing #20
This commit is contained in:
parent
9f1caed052
commit
2346076e72
|
|
@ -8,7 +8,7 @@
|
||||||
+---------------------------------------------------------*/
|
+---------------------------------------------------------*/
|
||||||
|
|
||||||
require_once "config.php";
|
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>";
|
$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>'
|
* @param $valid_parameters array '<parameter name> => '<expected type>'
|
||||||
* where type can be 'int', 'string' (unchecked),
|
* 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) {
|
||||||
$request = $_REQUEST;
|
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();
|
$result = array();
|
||||||
|
|
@ -231,6 +226,14 @@ function civiproxy_sanitise($value, $type) {
|
||||||
error_log("CiviProxy: removed invalid email parameter: " . $value);
|
error_log("CiviProxy: removed invalid email parameter: " . $value);
|
||||||
$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)) {
|
} elseif (is_array($type)) {
|
||||||
// this is a list of valid options
|
// this is a list of valid options
|
||||||
$requested_value = $value;
|
$requested_value = $value;
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ if (isset($rest_allowed_actions['all'])) {
|
||||||
} else {
|
} else {
|
||||||
civiproxy_rest_error("Invalid entity/action.");
|
civiproxy_rest_error("Invalid entity/action.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract parameters and add credentials and action data
|
// extract parameters and add credentials and action data
|
||||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||||
|
|
@ -75,6 +75,18 @@ foreach ($action as $key => $value) {
|
||||||
$parameters[$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
|
// finally execute query
|
||||||
civiproxy_redirect($target_rest, $parameters);
|
civiproxy_redirect($target_rest, $parameters);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue