Monday, August 27, 2012

Re: Cake 2.1 Problem creating Aro records from existent users

Yes me too

On Tuesday, April 3, 2012 8:44:46 AM UTC+8, Arnold wrote:
Hi,

I'm trying to implement ACL for my already created application and
need to create the aro records for my current existent users. On IRC
Ceeram said i just need to load AclBehaviour into my User's model,
find all users and save it (update any field, i guess) and that will
create the ARO row. I triedy but it doesn't works, it return me an
error:

AclNode::node() - Couldn't find Aro node identified by
"Array ( [Aro0.model] => User [Aro0.foreign_key] => 1 )
"

this is my current code:

/ User actsAs... acl => requester

//user model:
// i don't want to have a groups table. i have rol field as ENUM in my
user table for group
public function parentNode() {
                if (!$this->id && empty($this->data)) {
                        return null;
                }
                if (isset($this->data['User']['rol'])) {
                        $groupId = $this->data['User']['rol'];
                } else {
                        $groupId = $this->field('rol');
                }

                if (!$groupId) {
                        return null;
                } else {
                        return $groupId;
                }
        }

//user controller
function init_acl_db(){
                $this->User->recursive = -1;
                $users = $this->User->find('all');
                foreach ($users as $u) {
                        $this->User->create();
                        $this->User->id = $u['User']['id'];
                        $this->User->saveField('modified', date('Y-m-d h:i:s'));
// this returns me this error: AclNode::node() - Couldn't find
Aro node identified by "Array ( [Aro0.model] => User
[Aro0.foreign_key] => 1 ) "

--
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: