Handling of reqests which miss a parameter section

This commit is contained in:
Andreas Stöckel 2010-06-09 13:46:35 +00:00
parent 506d9753be
commit 084ef11729

View File

@ -31,30 +31,29 @@ class egw_json_request
} }
else else
{ {
if(!is_array($input_data)) if (get_magic_quotes_gpc())
{ {
//Decode the JSON input data into associative arrays $input_data[0] = stripslashes($input_data[0]);
$json = json_decode($input_data, true);
} }
else
{ //Decode the JSON input data into associative arrays
$json = $input_data; if (($json = json_decode($input_data[0], true)) !== false)
}
if(is_array($json))
{ {
$parameters = array();
//Get the request array //Get the request array
if (isset($json['request'])) if (isset($json['request']))
{ {
$request = $json['request']; $request = $json['request'];
//Check whether any parameters were supplied along with the request //Check whether any parameters were supplied along with the request
$parameters = array();
if (isset($request['parameters'])) if (isset($request['parameters']))
$parameters = array_stripslashes($request['parameters']); $parameters = $request['parameters'];
/*$parameters = array_stripslashes($request['parameters']);*/
//Call the supplied callback function along with the menuaction and the passed parameters
$this->handleRequest($menuaction, $parameters);
} }
//Call the supplied callback function along with the menuaction and the passed parameters
$this->handleRequest($menuaction, $parameters);
} }
} }
@ -82,20 +81,20 @@ class egw_json_request
switch($handler) switch($handler)
{ {
/* case '/etemplate/process_exec': case '/etemplate/process_exec':
$menuaction = $appName.'.'.$className.'.'.$functionName; $menuaction = $appName.'.'.$className.'.'.$functionName;
$appName = $className = 'etemplate'; $appName = $className = 'etemplate';
$functionName = 'process_exec'; $functionName = 'process_exec';
$menuaction = 'etemplate.etemplate.process_exec'; $menuaction = 'etemplate.etemplate.process_exec';
$argList = array( $parameters = array(
$argList[0]['etemplate_exec_id'], $argList[0]['etemplate_exec_id'],
$argList[0]['submit_button'], $argList[0]['submit_button'],
$argList[0], $argList[0],
'xajaxResponse', 'xajaxResponse',
); );
//error_log("xajax_doXMLHTTP() /etemplate/process_exec handler: arg0='$menuaction', menuaction='$_GET[menuaction]'"); //error_log("xajax_doXMLHTTP() /etemplate/process_exec handler: arg0='$menuaction', menuaction='$_GET[menuaction]'");
break;*/ break;
case 'etemplate': // eg. ajax code in an eTemplate widget case 'etemplate': // eg. ajax code in an eTemplate widget
$menuaction = ($appName = 'etemplate').'.'.$className.'.'.$functionName; $menuaction = ($appName = 'etemplate').'.'.$className.'.'.$functionName;
break; break;
@ -328,3 +327,35 @@ class egw_json_response
$this->sendResult(); $this->sendResult();
} }
} }
/**
* Deprecated legacy xajax wrapper functions for the new egw_json interface
*/
class xajaxResponse extends egw_json_response
{
public function addScript($script)
{
$this->script($script);
}
public function addAlert($message)
{
$this->alert($message, '');
}
public function addAssign($id, $key, $value)
{
$this->assign($id, $key, $value);
}
public function addRedirect($url)
{
$this->redirect($url);
}
public function getXML()
{
return '';
}
}