<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-2022-JP"
 http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<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>
  <p> </p>
  <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%">
_______________________________________________
List: <a class="moz-txt-link-abbreviated" href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a>
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>
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>
Dev site: <a class="moz-txt-link-freetext" href="http://dev.catalyst.perl.org/">http://dev.catalyst.perl.org/</a>
  </pre>
</blockquote>
</body>
</html>