I am developing an application using Yii framework. I am in a situation where I want to create a custom filter. For example, the normal filters are like:
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('view'),
'users'=>array('*'),
),
Now, in the array index for users
you can only put admin
, @
or *
. I wanted to know if it's possible to customize it in a way that not only these 3 parameters are used. In my system, I have a set of user roles (which I have created in the database). There's one user called whose role is 'general'. He can only view some pages. There's another type of user with the role of 'business_admin' whose role can allow him to access his pages as well as the 'general' user's pages.
Could this be implemented by having:
array('allow',
'actions'=>'the_admin_actions',
'users'=>'business_admin',
),
Please help!
That wont work as you need users
to be either ?
*
or @
unless you have an actual username called business_admin
like the defualt Yii config has a hard coded 'admin' username. You can set up RBAC though and then add 'roles' => 'business_admin'
This answer may help you yii RBAC and yii controllers access rules
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.