Tuesday, November 1, 2011

Re: ACL is not working for groups

awesome response time :) thanks!

On Nov 1, 11:05 am, sixthpoint <sixthpo...@gmail.com> wrote:
> I am having this exact same error, let me know if you find a solution.
>
> On Oct 31, 12:23 pm, warLog <thisras...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I want to utilise the concept of groups in ACL. I am very new to
> > cakephp, and messed up with ACL. My database tables are as follows:
> > CREATE TABLE IF NOT EXISTS `gcfa_groups` (
> >   `id` int(11) NOT NULL AUTO_INCREMENT,
> >   `name` varchar(255) NOT NULL,
> >   PRIMARY KEY (`id`)
> > );
>
> > CREATE TABLE IF NOT EXISTS `gcfa_users` (
> >   `id` int(11) NOT NULL AUTO_INCREMENT,
> >   `password` varchar(50) NOT NULL,
> >   `active` tinyint(4) NOT NULL DEFAULT '1',
> >   `email` varchar(255) DEFAULT NULL,
> >   `group_id` int(11) NOT NULL,
> >   `name` varchar(100) NOT NULL,
> >   PRIMARY KEY (`id`)
> > );
>
> > id is being used as username.
>
> > My model files are as follows:
> > class User extends AppModel {
> >         var $name = 'User';
>
> >         var $hasMany = array('UserBank', 'UserNominee', 'Payment');
> >         var $belongsTo = array(
> >                                         'Group' => array('className' => 'Group',
> >                                                                 'foreignKey' => 'group_id'
> >                                         )
> >                                 );
> >         public $actsAs = array('Acl' => array('type' => 'requester'));
>
> >         public function parentNode() {
> >                 if (!$this->id && empty($this->data)) {
> >                 return null;
> >             }
> >             $data = $this->data;
> >             if (empty($this->data) || empty($this->data['User']['group_id']))
> > {
> >                 $data = $this->read();
> >             }
>
> >             if (!$data['User']['group_id']) {
> >                 return null;
> >             } else {
> >                 $this->Group->id = $data['User']['group_id'];
> >                         $groupNode = $this->Group->node();
> >                         return array('Group' => array('id' => $groupNode[0]['Aro']
> > ['foreign_key']));
> >             }
> >         }
>
> >         public function bindNode($object) {
> >                 if (!empty($object[$this->alias]['group_id'])) {
> >                         return array('model' => 'Group', 'foreign_key' => $object[$this->alias]['group_id']);
>
> >                 }
> >         }
>
> >         function isAuthorized($user, $controller, $action) {
> >                 return true;
> >         }
>
> > }
>
> > class Group extends AppModel {
> >         public $displayField = 'name';
> >         var $hasMany = array('User');
>
> >         public $actsAs = array('Acl' => array('requester'));
>
> >         public function parentNode() {
> >                 return null;
> >         }
>
> > }
>
> > I just baked the controller and view files for these models using
> > shell. I have setup my ACL as follows:
> > id      parent_id       model   foreign_key     alias   lft     rght
> > 1       NULL    Group   1       SuperUser       1       2
> > 2       NULL    Group   2       Administrator   3       4
> > 3       NULL    Group   3       Manager                 5       6
> > 4       NULL    Group   4       Author          7       8
>
> > Whenever I am going to edit any user it is giving me error :
> > Warning (512): AclNode::node() - Couldn't find Aro node identified by
> > "Array
> > (
> >     [Aro0.model] => User
> >     [Aro0.foreign_key] => 2
> > )
> > " [CORE/Cake/Model/AclNode.php, line 179]
>
> > Do I need to make separate entry of every user in aros table? If yes,
> > then what is the use of groups in this case? If I want to bypass this
> > creation of new entry in acos table, is it possible? I think if I am
> > able to override AclBehaviour::afterSave method then I can do that.
> > I dont want to create a separate entry for every user in the ACL.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: