Hi !

If you used the code given in the Simple Acl controlled application,
it doesn't work out of the box if you save only one User's field.

The parentNode() function check if the group_id field is not empty,
and if it is, it returns null. This makes the Acl component think the
User doesn't have any parent to store in the Aros.

If you save only one field - without the goup_id field - you will have
to reload the group_id value.

I use the following code:

function parentNode()
{
        if (!$this->id && empty($this->data))
        {
            return null;
        }

        $data = $this->data;

        if (empty($this->data))
        {
            $data = $this->read();
        }
        elseif(isset($this->id) && empty($data['User']['role_id']))
        {
            /*
             * The role_id field was not intended to be saved,
             * but we need it in order to find the parent node in the
Aros
             */
            $data['User']['role_id'] = $this->field('role_id',
array('User.id' => $this->id));
        }

        if (empty($data['User']['role_id']))
        {
            return null;
        }
        else
        {
            return array('Role' => array('id' => $data['User']
['role_id']));
        }
}

Just replace role_id by groupid or whatever name you used.

Regards,
nIcO


On 4 juin, 17:53, stefano <[email protected]> wrote:
> i have the same problem :( any idea??
>
> On May 24, 9:25 pm, Jon Chin <[email protected]> wrote:
>
> > I tried that and have the same result.  Do I need to unbind a relationship
> > or something?
>
> > On Mon, May 24, 2010 at 2:06 PM, Filipe Teles Rodrigues <
>
> > [email protected]> wrote:
> > > I use $this->User->save($this->data) instead of saveField.
>
> > > 2010/5/24 Jon Chin <[email protected]>
>
> > >> I'm using Auth and db ACL, but I have an action that screws up my ACL
> > >> records every time.  I have ACL set up just like the Book instructs.  I'm
> > >> building a "change password" page where I want to just update the 
> > >> password.
> > >>  I run the following commands:
> > >>  $this->User->id = $this->Session->read('Auth.User.id');
> > >> $this->User->saveField('password', $this->data['User']['password']);
> > >> (I've also tried $this->User->save()).  When I execute this, it deletes
> > >> the user's parent_id from the aros table as well as corrupts the 
> > >> tree-ness
> > >> of the ACL tables.  What am I doing wrong?  Thanks in advance.
>
> > >> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > >> others with their CakePHP related questions.
>
> > >> You received this message because you are subscribed to the Google Groups
> > >> "CakePHP" group.
> > >> To post to this group, send email to [email protected]
> > >> To unsubscribe from this group, send email to
> > >> [email protected]<cake-php%[email protected]
> > >>  om>For more options, visit this group at
> > >>http://groups.google.com/group/cake-php?hl=en
>
> > >  Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > > others with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups
> > > "CakePHP" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<cake-php%[email protected]
> > >  om>For more options, visit this group at
> > >http://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected] For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to