Problem With User Crud Admin Interface

Hi All…

I have a User Table, Authorization Table and a Roles Table. In the roles table there are two fields : Role Id and Role Name . The table Authoror ex:ization has role id and user id . One user can have more than one roles specified in the role table. Now I want that the user should be able to add only those users which have less priviledge then him. For ex: If I have a user called superadmin then he will be able to add a user with a role admin but admin will not be able to add superadmin. I have successfully created this.

I have created a User Crud with Gii and successfully modified the create user code to achieve my desired functionality. Now I want this same thing to be reflected in the manage users page. I want the user should be able to view and manage only the users that have roles lesser to him. I was trying to toy with admin code in the CRUD controller but it is just sending the User object to the admin’s page .Is there any way to accomplish this thing???

Any help is appreciated

Regards

You can specify relations between your tables in relations() method of your User model and change its search() method according to your needs.

Hi man,

The way I would do that is by using ‘scopes’ http://www.yiiframework.com/doc/api/1.1/CActiveRecord#scopes-detail, you can choose only those Users that are under the role of the User that initiated the session. Thus, admin would be the superadmin role and when fired the appropiate scope (ie managedUsers() ) the users below their role level will be displayed on the admin panel.