How to implement multi-level hierarchies in user management
Implement multi-level hierarchies so that super user have also all rights that sub user have means super user can also manage sub-users jobs.
Suppose in Application there can be N number of user hierarchies...
Super User
Sub User
- Sub User -1
e.g So Sub user is super user for sub user-1 . This way sub user would handle all jobs of开发者_高级运维 his super user.
How to design the database for this.
I think what you might be looking for is a ACL libary.
ACL stands for Access Control List. it uses 2 "sub models" called ARO and ACO.
Aro's are what is "requesting the data" - e.g. the user/group (and can be structured as a tree using nested sets, or a simple recursive tree [parent_id]).
Aco's are what is being requested - a certain model, a page, a function - what ever.
then you combine the two (aco and aro) to create the ACL - basicly saying "this user/group can/can't use this model/page"
According to your tags i see you're looking for a PHP/MySQL solution - so phpGACL might be very helpful to you: http://phpgacl.sourceforge.net/
Its a complete "framework" for managing ACL's which you can easily combine into your application (how ever its structured).
Hope that helped you out a bit - or atleast pointed you in the right direction.
精彩评论