I searched over the internet and I found nothing. I centralized all of the access rule from all controller in the main Controller.php from components. This is my code:
public function accessRules() {
$controllers = array(' '); $actions = array('index');
if (Yii::app()->user->getState("isAdmin") == true){
array_push($controllers, 'controllerName','ModuleName/ControllerName');
array_push($actions, 'create');
}
if (Yii::app()->user->getState('isNormalUser') == true){
array_push($controllers, 'controllerName2');
}
if (Yii::app()->user->getState("isAdmin") == false && Yii::app()->user->getState("isNormalUser") == false){
return array(
array('deny', // deny all users
'users' => array('*'),
),
);
}else{
$controllers = array_unique($controllers); //remove duplicates
$actions = array_unique($actions);//remove duplicates
return array(
array('allow',
'controllers'=> $controllers,
'actions' => $actions,
),
array('deny', // deny all users
'users' => array('*'),
),
);
}
}
My problem is: In my module if I have a controller(C1) with a function named f1 and another controller (C2) with the same function name f1 and i want to give access only to C1 with f1? How can I do that? I observed that i can make the difference between modules with the same controller name giving the format
ModuleName/ModuleController Is it smth similar to actions ? Thx
Aucun commentaire:
Enregistrer un commentaire