Hi, <br>
<br>
Maybe an algorithmic approach ?<br>
<br>
--<br>
ancestor = edited.parent;<br>
found = false;<br>
while (found==false and ancestor!=null) {<br>
&nbsp; if (ancestor == current_user)<br>
&nbsp;&nbsp;&nbsp; found= true;<br>
&nbsp; ancestor = ancestor.parent<br>
}<br>
return found;<br>
--<br>
<br>
I came from C++ background rather than Perl, so I am sorry if it looks more like C++ but I hope you got the idea. Not that there's a bit of recursive going on there.<br>
<br>
Sindharta<br>
<br>
<b>jakac &lt;jakac@iprom.si&gt;</b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">     <font face="Helvetica, Arial, sans-serif">Hello!<br>
 <br>
 I need a help on building a model for user that has a permission to edit <br>
 other users that were created by this user or any of his children, grandchildren etc.<br>
 (difficult sentence, I know)<br>
 <br>
 To make this a little more understandable here's my database table:<br>
 <br>
 - user_id <br>
 - username<br>
 - password<br>
 - various other data such as fname, lname, address etc.<br>
 - parent_id<br>
 <br>
 Column "parent_id" has a value of "user_id" that created one user. There is also<br>
 a "superadministrator" with parent_id '0' that can edit everybody.<br>
 <br>
 Now I would like to build a model that I can use in my controllers like:<br>
 <br>
 if ( user_id is child,grandchild,gradgrandchild.... of logged in $c-&gt;user ) {<br>
 &nbsp;&nbsp;&nbsp; # has permisson to edit <br>
 } else {<br>
 &nbsp;&nbsp;&nbsp; # doesn't have a permission to edit<br>
 }<br>
 <br>
 Example:<br>
 - superadmin<br>
 |__- foo<br>
 |__- bar<br>
 |____- john<br>
 |______- doe<br>
 <br>
 In this example:<br>
 - superadmin can edit anybody,<br>
 - bar can edit john &amp; doe<br>
 - john can edit only doe<br>
 - foo can't edit anybody since he has no children<br>
 And there can be unlimited levels of users... <br>
 <br>
 There is no problem with permission to edit first child since I can just compare<br>
 logged in user's ID with edited user's parent_id but when edited user is grandchild,<br>
 grandgrandchild, (grand * n) child of $c-&gt;user then I need some kind of model<br>
 to return true/false value.<br>
 <br>
 I've never done that and I am also new to Catalyst so any help would be appreciated.<br>
 Thank you!<br>
 <br>
 <br>
 JakaC.</font> _______________________________________________<br>
List: Catalyst@lists.scsys.co.uk<br>
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst<br>
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/<br>
Dev site: http://dev.catalyst.perl.org/<br>
</blockquote><br>

<div style="line-height: 0; width: 0; height: 5px; clear: both;">&nbsp;</div>
<p>&#32;



<hr size=1><a href=http://pr.mail.yahoo.co.jp/toolbar/ target="new">Power up the Internet with Yahoo! Toolbar.</a><br>