<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: ACL with Groups</title>
	<atom:link href="http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/feed/" rel="self" type="application/rss+xml" />
	<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/</link>
	<description>My forays into the Kitchen</description>
	<lastBuildDate>Wed, 04 Nov 2009 22:02:31 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: coskunlar vinc</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-2299</link>
		<dc:creator>coskunlar vinc</dc:creator>
		<pubDate>Tue, 28 Apr 2009 11:07:51 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-2299</guid>
		<description>I think zero will work but it is better to pass null as the parent id, as seen with this condition</description>
		<content:encoded><![CDATA[<p>I think zero will work but it is better to pass null as the parent id, as seen with this condition</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JM</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-2172</link>
		<dc:creator>JM</dc:creator>
		<pubDate>Wed, 21 Jan 2009 01:22:22 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-2172</guid>
		<description>I guess that a many to many relation between users and groups will break the hierarchical rule of &quot;only one parent&quot;, and that is not possible to implement such a solution with aclbehavior (i supose that from a strictly acl point of view it&#039;s possible to have a user in more than one group).

Any input on subject will be welcome.

By the way, congrats for the artcile, it&#039;s nice explained.</description>
		<content:encoded><![CDATA[<p>I guess that a many to many relation between users and groups will break the hierarchical rule of &#8220;only one parent&#8221;, and that is not possible to implement such a solution with aclbehavior (i supose that from a strictly acl point of view it&#8217;s possible to have a user in more than one group).</p>
<p>Any input on subject will be welcome.</p>
<p>By the way, congrats for the artcile, it&#8217;s nice explained.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CakePHP 1.2.0.6311b: Group + ACL + AuthComponent &#171; वीर</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1946</link>
		<dc:creator>CakePHP 1.2.0.6311b: Group + ACL + AuthComponent &#171; वीर</dc:creator>
		<pubDate>Thu, 24 Apr 2008 17:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1946</guid>
		<description>[...] http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/" rel="nofollow">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brade</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1888</link>
		<dc:creator>Brade</dc:creator>
		<pubDate>Fri, 15 Feb 2008 17:16:21 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1888</guid>
		<description>Indeed, this is the revised approach:
&lt;code&gt;if ($this-&gt;Group-&gt;save($this-&gt;data[&#039;Group&#039;])) {
    $this-&gt;Group-&gt;Aro-&gt;set($this-&gt;Group-&gt;Aro-&gt;find(&quot;foreign_key = $id&quot;));
    $this-&gt;Group-&gt;Aro-&gt;saveField(&#039;alias&#039;, $this-&gt;data[&#039;Group&#039;][&#039;name&#039;]);
    $this-&gt;Group-&gt;Aro-&gt;setParent($this-&gt;Group-&gt;Aro-&gt;field(&#039;id&#039;, &#039;foreign_key = &#039; . $this-&gt;data[&#039;Group&#039;][&#039;parent_id&#039;]));&lt;/code&gt;
...where $id is the parameter in the &quot;edit&quot; action.
The &quot;saveField&quot; line isn&#039;t really necessary unless (like me) you want a copy of the group name as the alias, so it makes it easier to use &quot;generatetreelist&quot; on the index page, and have the names of your groups readily available.

Also in my &quot;delete&quot; action I do a check like this to see if a group has children:
&lt;code&gt;} elseif ($children = $this-&gt;Group-&gt;Aro-&gt;children($this-&gt;Group-&gt;Aro-&gt;field(&#039;id&#039;, &quot;foreign_key = $id&quot;), true)) {&lt;/code&gt;
and set a flash message/redirect without deleting.</description>
		<content:encoded><![CDATA[<p>Indeed, this is the revised approach:<br />
<code>if ($this-&gt;Group-&gt;save($this-&gt;data['Group'])) {<br />
    $this-&gt;Group-&gt;Aro-&gt;set($this-&gt;Group-&gt;Aro-&gt;find("foreign_key = $id"));<br />
    $this-&gt;Group-&gt;Aro-&gt;saveField('alias', $this-&gt;data['Group']['name']);<br />
    $this-&gt;Group-&gt;Aro-&gt;setParent($this-&gt;Group-&gt;Aro-&gt;field('id', 'foreign_key = ' . $this-&gt;data['Group']['parent_id']));</code><br />
&#8230;where $id is the parameter in the &#8220;edit&#8221; action.<br />
The &#8220;saveField&#8221; line isn&#8217;t really necessary unless (like me) you want a copy of the group name as the alias, so it makes it easier to use &#8220;generatetreelist&#8221; on the index page, and have the names of your groups readily available.</p>
<p>Also in my &#8220;delete&#8221; action I do a check like this to see if a group has children:<br />
<code>} elseif ($children = $this-&gt;Group-&gt;Aro-&gt;children($this-&gt;Group-&gt;Aro-&gt;field('id', "foreign_key = $id"), true)) {</code><br />
and set a flash message/redirect without deleting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brade</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1887</link>
		<dc:creator>Brade</dc:creator>
		<pubDate>Thu, 14 Feb 2008 23:52:22 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1887</guid>
		<description>Okay, so don&#039;t use my previous code when editing an item with children, because it will delete the children. &gt;=[
I can probably make use of the fact that the Aro object in Group already &quot;actsAs&quot; the TreeBehavior, so I can use some TreeBehavior function to move the node instead of deleting and re-creating. Let&#039;s find out...</description>
		<content:encoded><![CDATA[<p>Okay, so don&#8217;t use my previous code when editing an item with children, because it will delete the children. &gt;=[<br />
I can probably make use of the fact that the Aro object in Group already &#8220;actsAs&#8221; the TreeBehavior, so I can use some TreeBehavior function to move the node instead of deleting and re-creating. Let&#8217;s find out&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brade</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1886</link>
		<dc:creator>Brade</dc:creator>
		<pubDate>Thu, 14 Feb 2008 23:31:20 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1886</guid>
		<description>Mmmkay, so I figured a workaround. Building on Aran&#039;s solution (which is the only way I could get the parentNode to actually save properly), in my &quot;edit&quot; action, I substituted this code:
&lt;code&gt;
if ($this-&gt;Group-&gt;save($this-&gt;data[&#039;Group&#039;])) {
&lt;/code&gt;
with this:
&lt;code&gt;
if ($this-&gt;Group-&gt;save($this-&gt;data[&#039;Group&#039;])) {
    $this-&gt;Group-&gt;behaviors[&#039;Acl&#039;]-&gt;afterDelete($this-&gt;Group);
    $this-&gt;Group-&gt;behaviors[&#039;Acl&#039;]-&gt;afterSave($this-&gt;Group, true);
&lt;/code&gt;
I guess this is cheating a bit. I still don&#039;t know why the Cake auths decided to run the Acl behavior&#039;s afterSave logic only when adding a new record. But this solution seems to work for me right now.</description>
		<content:encoded><![CDATA[<p>Mmmkay, so I figured a workaround. Building on Aran&#8217;s solution (which is the only way I could get the parentNode to actually save properly), in my &#8220;edit&#8221; action, I substituted this code:<br />
<code><br />
if ($this-&gt;Group-&gt;save($this-&gt;data['Group'])) {<br />
</code><br />
with this:<br />
<code><br />
if ($this-&gt;Group-&gt;save($this-&gt;data['Group'])) {<br />
    $this-&gt;Group-&gt;behaviors['Acl']-&gt;afterDelete($this-&gt;Group);<br />
    $this-&gt;Group-&gt;behaviors['Acl']-&gt;afterSave($this-&gt;Group, true);<br />
</code><br />
I guess this is cheating a bit. I still don&#8217;t know why the Cake auths decided to run the Acl behavior&#8217;s afterSave logic only when adding a new record. But this solution seems to work for me right now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brade</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1885</link>
		<dc:creator>Brade</dc:creator>
		<pubDate>Thu, 14 Feb 2008 20:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1885</guid>
		<description>As lemp points out, all of this is useless if you can&#039;t edit a user to change groups. The source code indicates parentNode only runs if you&#039;re adding a new record, which to me seems totally retarded. That&#039;s not your fault, of course, but obviously this Behavior stuff is not going to be nearly as easy as it could (and should) have been.</description>
		<content:encoded><![CDATA[<p>As lemp points out, all of this is useless if you can&#8217;t edit a user to change groups. The source code indicates parentNode only runs if you&#8217;re adding a new record, which to me seems totally retarded. That&#8217;s not your fault, of course, but obviously this Behavior stuff is not going to be nearly as easy as it could (and should) have been.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aran</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1240</link>
		<dc:creator>Aran</dc:creator>
		<pubDate>Thu, 27 Dec 2007 01:13:41 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-1240</guid>
		<description>I had a similar problem as darkangel.  My solution was to modify the Group::parentNode() method from this tutorial.

Instead of:
&lt;code&gt;return $this-&gt;data[&#039;Group&#039;][&#039;parent_id&#039;];&lt;/code&gt;

I had to borrow the code from the User model and make it:
&lt;code&gt;return array(&#039;model&#039; =&gt; &#039;Group&#039;, &#039;foreign_key&#039; =&gt; $data[&#039;Group&#039;][&#039;parent_id&#039;]);&lt;/code&gt;

The Acl behavior&#039;s afterSave() method does a call to Group::parentNode(), and the result is then fed to the node() method.  The node() method needs the array with &#039;model&#039; and &#039;foreign_key&#039; in it in order to work.

Now ... when I add a new group and specify as the parent id, the id of another group in the Groups table, the corresponding id for the Group in the Aros table, will be set as the parent_id of the new Group in the Aros table.</description>
		<content:encoded><![CDATA[<p>I had a similar problem as darkangel.  My solution was to modify the Group::parentNode() method from this tutorial.</p>
<p>Instead of:<br />
<code>return $this-&gt;data['Group']['parent_id'];</code></p>
<p>I had to borrow the code from the User model and make it:<br />
<code>return array('model' =&gt; 'Group', 'foreign_key' =&gt; $data['Group']['parent_id']);</code></p>
<p>The Acl behavior&#8217;s afterSave() method does a call to Group::parentNode(), and the result is then fed to the node() method.  The node() method needs the array with &#8216;model&#8217; and &#8216;foreign_key&#8217; in it in order to work.</p>
<p>Now &#8230; when I add a new group and specify as the parent id, the id of another group in the Groups table, the corresponding id for the Group in the Aros table, will be set as the parent_id of the new Group in the Aros table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: darkangel</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-682</link>
		<dc:creator>darkangel</dc:creator>
		<pubDate>Sun, 25 Nov 2007 12:18:08 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-682</guid>
		<description>(ignore previous comment -- solution found)</description>
		<content:encoded><![CDATA[<p>(ignore previous comment &#8212; solution found)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: darkangel</title>
		<link>http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-660</link>
		<dc:creator>darkangel</dc:creator>
		<pubDate>Fri, 23 Nov 2007 22:14:38 +0000</pubDate>
		<guid isPermaLink="false">http://lemoncake.wordpress.com/2007/07/19/acl-with-groups/#comment-660</guid>
		<description>Hi Geoff,

Thanks for these articles.

Is the result of parentNode() supposed to be entered into the &#039;parent_id&#039; field of the ACL table? It seems NULL is inserted into the table regardless of whether or not I specify a parent.

My function:

&lt;code&gt;
    public function parentNode()
    {
        if (isset($this-&gt;data[&#039;Group&#039;][&#039;parent_id&#039;])) {
            return $this-&gt;data[&#039;Group&#039;][&#039;parent_id&#039;];
        } else {
            return null;
        }
    }
&lt;/code&gt;

Any ideas?

_da.</description>
		<content:encoded><![CDATA[<p>Hi Geoff,</p>
<p>Thanks for these articles.</p>
<p>Is the result of parentNode() supposed to be entered into the &#8216;parent_id&#8217; field of the ACL table? It seems NULL is inserted into the table regardless of whether or not I specify a parent.</p>
<p>My function:</p>
<p><code><br />
    public function parentNode()<br />
    {<br />
        if (isset($this-&gt;data['Group']['parent_id'])) {<br />
            return $this-&gt;data['Group']['parent_id'];<br />
        } else {<br />
            return null;<br />
        }<br />
    }<br />
</code></p>
<p>Any ideas?</p>
<p>_da.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
