Re: How do I save a field on my User without breaking the ACL?

2010-06-04 Thread stefano
i have the same problem :( any idea??

On May 24, 9:25 pm, Jon Chin port23u...@gmail.com 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 





 filipe.t2...@gmail.com wrote:
  I use $this-User-save($this-data) instead of saveField.

  2010/5/24 Jon Chin port23u...@gmail.com

  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.organd 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 cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.c
   omFor more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en

   Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.c 
  omFor more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en

 Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I save a field on my User without breaking the ACL?

2010-06-04 Thread alaxos
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 ssalvat...@gmail.com wrote:
 i have the same problem :( any idea??

 On May 24, 9:25 pm, Jon Chin port23u...@gmail.com 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 

  filipe.t2...@gmail.com wrote:
   I use $this-User-save($this-data) instead of saveField.

   2010/5/24 Jon Chin port23u...@gmail.com

   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 cake-php@googlegroups.com
   To unsubscribe from this group, send email to
   cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.c
omFor 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 cake-php@googlegroups.com
   To unsubscribe from this group, send email to
   cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.c
omFor 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 cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I save a field on my User without breaking the ACL?

2010-06-04 Thread stefano
try with

$this-data[User][group_id] = $this-Session-
read(Auth.User.group_id);

:)

s.

On May 24, 10:59 am, Jon Chin port23u...@gmail.com wrote:
 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.organd 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 cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I save a field on my User without breaking the ACL?

2010-06-04 Thread alaxos
The point is that Session is not defined in models. So if you do like
this, you will have to do it each time you want to save a User without
the group_id field, in each of your controller's actions.

Doing it directly in the model allows you to care about the presence
of the group_id field only once. But it is done through an extra SQL
query to retrieve the group_id value. We could of course retrieve the
group_id in the model by directly using the $_SESSION variable.

By the way, I have always wondered if it was a design choice to not
have access to the CakeSession object in the model. If anyone has the
answer, I would be happy to read it.

nIcO


On 4 juin, 22:25, stefano ssalvat...@gmail.com wrote:
 try with

 $this-data[User][group_id] = $this-Session-

 read(Auth.User.group_id);

 :)

 s.

 On May 24, 10:59 am, Jon Chin port23u...@gmail.com wrote:

  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 cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


How do I save a field on my User without breaking the ACL?

2010-05-24 Thread Jon Chin
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 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I save a field on my User without breaking the ACL?

2010-05-24 Thread Filipe Teles Rodrigues
I use $this-User-save($this-data) instead of saveField.

2010/5/24 Jon Chin port23u...@gmail.com

 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 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 cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I save a field on my User without breaking the ACL?

2010-05-24 Thread Jon Chin
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 
filipe.t2...@gmail.com wrote:

 I use $this-User-save($this-data) instead of saveField.

 2010/5/24 Jon Chin port23u...@gmail.com

 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 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 cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://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 cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en