I have implemented some user roles (using authmanager), let's say admin, manager and user.
Then i create the new user creation form and there i need the admin to be able to create managers & users, the manager to be able to create only users and the user shouldn't be allowed any user creation.
So, i tried to use Yii::app()->authmanager->getItemChildren()
My questions are:
How can i extend authmanager to add a getItemChildren method for a specified type? (roles are stored with type=2 in db, while actions with type=0)
Is it possible to use CHtml::listData for creating the activeDropDownList? In my tests the attributes i need are private and not public. Any suggestions?
Besides roles, it seems you also need to define operations, such as createUser and createManager. And the ‘admin’ role will have ‘createManager’ and ‘manager’ role as its children, and the ‘manager’ role will have ‘createUser’ as its child.
Then, you can call Yii::app()->user->checkAccess() to check if the current user can perform a specific operation, such as 'createUser'.
For your 2nd question, yes, you can use CHtml::listData, but the object property must be public. If it is private, you have to think of a way to expose it.
My problem is not at the part of restricting access (e.g using Yii::app()->user->checkAccess()) but at the presentation part, meaning i need different drop down boxes for each role (with it's children roles). Of course atm the application only has 3 roles and i could hardcode an if block for each role to provide the desired drop down, but i think that this should be done with an authmanager call (e.g getChildrenRoles('Admin'))