Permit LSaddon to provide ajax callable function

This commit is contained in:
Benjamin Renard 2015-08-12 14:16:25 +02:00
parent b4105c04d6
commit 9a09cf491e
2 changed files with 25 additions and 8 deletions

View file

@ -2353,7 +2353,9 @@ class LSsession {
LSerror :: defineError('LSsession_20',
_("LSsession : Error during password recovery. Contact administrators.(Step : %{step})")
);
// 21 : not yet used
LSerror :: defineError('LSsession_21',
_("LSsession : call function %{func} do not provided from LSaddon %{addon}.")
);
LSerror :: defineError('LSsession_22',
_("LSsession : problem during initialisation.")
);

View file

@ -14,15 +14,30 @@ else {
$data=NULL;
if (!isset($_ERRORS)) {
$class = $_REQUEST['template'];
if (LSsession :: loadLSclass($class)) {
$meth = 'ajax_'.$_REQUEST['action'];
if (method_exists($class,$meth)) {
$class :: $meth($data);
if (isset($_REQUEST['template'])) {
$class = $_REQUEST['template'];
if (LSsession :: loadLSclass($class)) {
$meth = 'ajax_'.$_REQUEST['action'];
if (method_exists($class,$meth)) {
$class :: $meth($data);
}
}
}
elseif (isset($_REQUEST['addon'])) {
$addon = $_REQUEST['addon'];
if (LSsession :: loadLSaddon($addon)) {
$func = 'ajax_'.$_REQUEST['action'];
if (function_exists($func)) {
$func = new ReflectionFunction($func);
if (basename($func->getFileName())=="LSaddons.$addon.php") {
$func->invokeArgs(array(&$data));
}
else {
LSerror :: addErrorCode('LSsession_21',array('func' => $func -> getName(),'addon' => $addon));
}
}
}
}
}
LSsession :: displayAjaxReturn($data);
?>