Hi, i’m using YiiUser managment to control acces to models actions.
Because my app is simple and doesn’t have many users I can live with this approach.
So i only add this to ALL of my model controllers :
public function filters() {
return array(
'accessControl',
);
}
public function accessRules() {
return array(
array('allow',
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow',
'actions'=>array('minicreate', 'admin' ,'create','update','copy','export'),
'users'=>array('@'),
'expression'=>'$user->hasRole("admin")'
),
array('allow',
'actions'=>array('admin','delete','copy'),
'users'=>array('admin'),
),
array('deny',
'users'=>array('*'),
),
);
}
As you can see I add this line :
'expression'=>'$user->hasRole("admin")'
So I have to change every controller.
What I want is something more flexible, so I only add one line with this parameters:
-
user (if empty is current logged)
-
Model
-
action requested
So the function return an array or something to allow/deny the action.
Is there any way to achieve this ?
Best regards
Nicolas