Hi,<br>
<br>
Haven't tried it yet, but I think the code in Catalyst should look like:<br>
<br>
my $edited = $c-&gt;model('DB::User')-&gt;find({id=&gt;$target_user_id});<br>
my $ancestor = $c-&gt;model('DB::User')-&gt;find({id=&gt;$edited-&gt;{parent_id}});<br>
my $found = 0;<br>
while ($found==false &amp;&amp; $ancestor) {<br>
&nbsp; if ($ancestor == $c.user.user_id)<br>
&nbsp;&nbsp;&nbsp; $found= true;<br>
&nbsp; $ancestor = $c-&gt;model('DB::User')-&gt;find({id=&gt;$edited-&gt;{parent_id}});<br>
}<br>
return $found;<br>
<br>
You can push the ancestors into a list if you want to have a list of users who can edit $target_user_id. But I am not really sure if you can make a top-to-bottom approach with this one. (I assume top-to-bottom means searching from all ancestors instead of the user that you want to edit)<br>
<br>
Sindharta<br>
<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;">      <meta content="text/html;charset=ISO-2022-JP" http-equiv="Content-Type"><title></title>     <font face="Helvetica, Arial, sans-serif"><br>
 Yes this seems fine but how to code this in Catalyst? :) <br>
 And another thing - if I want to list users that certain this_user can edit,<br>
 I would need to go through the whole list and check for each user if <br>
 "this_user" is one of the (grand)parents. <br>
 <br>
 Your approach is bottom-to-top and I now I am also looking for top-to-bottom...<br>
 I think I can manage to write one of these functions by myself if someone<br>
 would just give me an example how to write one of these.. <br>
 </font><br>
 <a class="moz-txt-link-abbreviated" href="mailto:sindharta_tanuwijaya@yahoo.co.jp">sindharta_tanuwijaya@yahoo.co.jp</a> wrote: <blockquote cite="mid:20080603021257.79691.qmail@web3105.mail.kcd.yahoo.co.jp" type="cite">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 <a class="moz-txt-link-rfc2396E" href="mailto:jakac@iprom.si">&lt;jakac@iprom.si&gt;</a></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: <a class="moz-txt-link-abbreviated" href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>
 Listinfo: <a class="moz-txt-link-freetext" href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
 Searchable archive: <a class="moz-txt-link-freetext" href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
 Dev site: <a class="moz-txt-link-freetext" href="http://dev.catalyst.perl.org/">http://dev.catalyst.perl.org/</a><br>
   </blockquote>   <br>
   <div style="line-height: 0pt; width: 0pt; height: 5px; clear: both;">&nbsp;</div>   <div> </div>   <hr size="1"><a moz-do-not-send="true" href="http://pr.mail.yahoo.co.jp/toolbar/" target="new">Power up the Internet with Yahoo! Toolbar.</a><br>
   <pre wrap=""><hr size="4" width="90%"><br>
_______________________________________________<br>
List: <a class="moz-txt-link-abbreviated" href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a class="moz-txt-link-freetext" href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a class="moz-txt-link-freetext" href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a class="moz-txt-link-freetext" href="http://dev.catalyst.perl.org/">http://dev.catalyst.perl.org/</a><br>
  </pre> </blockquote> _______________________________________________<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>