Skip to content

Commit

Permalink
removed duplication from ajax route
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardPosselt committed Nov 27, 2012
1 parent 01040a6 commit 460a69d
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions apptemplate/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@
* stored in the DI container
* @param string $methodName: the method that you want to call
* @param array $urlParams: an array with variables extracted from the routes
* @param bool $isAjax: if the request is an ajax request
* @param bool $disableAdminCheck: disables the check for adminuser rights
* @param bool $disableIsInAdminGroupCheck: disables the check for admin group member
*/
function callController($controllerName, $methodName, $urlParams,
function callController($controllerName, $methodName, $urlParams, $isAjax=false,
$disableAdminCheck=true, $disableIsInAdminGroupCheck=true){
$container = createDIContainer();

// run security checks
$security = $container['Security'];
runSecurityChecks($security);
runSecurityChecks($security, $isAjax, $disableAdminCheck, $disableIsInAdminGroupCheck);

// call the controller and render the page
$controller = $container[$controllerName];
Expand Down Expand Up @@ -84,7 +85,7 @@ function runSecurityChecks($security, $isAjax=false, $disableAdminCheck=true,
*/
$this->create('apptemplate_index', '/')->action(
function($params){
callController('IndexController', 'index', $params, true);
callController('IndexController', 'index', $params);
}
);

Expand All @@ -93,12 +94,6 @@ function($params){
*/
$this->create('apptemplate_ajax_setsystemvalue', '/setsystemvalue')->post()->action(
function($params){
$container = createDIContainer();

$security = $container['Security'];
$security->runChecks();

$controller = $container[$controllerName];
$container->setsystemvalue($params);
callController('AjaxController', 'setSystemValue', $params, true);
}
);

0 comments on commit 460a69d

Please sign in to comment.