Yii Framework Forum: User creation + authManager + CHtml::listData - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

User creation + authManager + CHtml::listData Rate Topic: -----

#1 User is offline   eval 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 85
  • Joined: 25-November 08
  • Location:Athens - Greece

Posted 13 December 2008 - 02:32 PM

Hello,

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:
1) 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)
2) 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?

Thanks in advance
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,889
  • Joined: 04-October 08
  • Location:DC, USA

Posted 13 December 2008 - 08:37 PM

Why do you want to call getItemChildren()?
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.
0

#3 User is offline   eval 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 85
  • Joined: 25-November 08
  • Location:Athens - Greece

Posted 14 December 2008 - 04:40 AM

Thanks for your answer Qiang.

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'))

Thank you again for your comments.


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users