[Catalyst] Users hierarchy

Wade.Stuart at fallon.com Wade.Stuart at fallon.com
Mon Jun 2 17:36:46 BST 2008



jakac <jakac at iprom.si> wrote on 06/02/2008 09:59:37 AM:

> Hello!
>
> I need a help on building a model for user that has a permission to edit
> other users that were created by this user or any of his children,
> grandchildren etc.
> (difficult sentence, I know)
>
> To make this a little more understandable here's my database table:
>
> - user_id
> - username
> - password
> - various other data such as fname, lname, address etc.
> - parent_id
>
> Column "parent_id" has a value of "user_id" that created one user.
> There is also
> a "superadministrator" with parent_id '0' that can edit everybody.
>
> Now I would like to build a model that I can use in my controllers like:
>
> if ( user_id is child,grandchild,gradgrandchild.... of logged in $c->user
) {
>     # has permisson to edit
> } else {
>     # doesn't have a permission to edit
> }
>
> Example:
> - superadmin
> |__- foo
> |__- bar
> |____- john
> |______- doe
>
> In this example:
> - superadmin can edit anybody,
> - bar can edit john & doe
> - john can edit only doe
> - foo can't edit anybody since he has no children
> And there can be unlimited levels of users...
>
> There is no problem with permission to edit first child since I can
> just compare
> logged in user's ID with edited user's parent_id but when edited
> user is grandchild,
> grandgrandchild, (grand * n) child of $c->user then I need some kind of
model
> to return true/false value.
>
> I've never done that and I am also new to Catalyst so any help would
> be appreciated.
> Thank you!
>


Check out Nested Trees,  Joe Celko has some articles about them.  Mojomojo
has a pretty complete implementation of one in dbix:class if I remember.
http://www.dbmsmag.com/9603d06.html
http://www.intelligententerprise.com/001020/celko.jhtml






>
> JakaC. _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/




More information about the Catalyst mailing list