开发者

Why Are My CakePHP AROs Not Being Created?

I followed the CakePHP Cookbook's simple ACL application tutorial and for a while all way fine and dandy. When I created a user, my AROs were automagically created too, and without too much effort I was able to give everyone permissions for the correct actions.

My application has become more complex now though. When I create a "Realtor", I create a user for them in the Realtor model's afterSave function, like so:

App::import( 'Component', 'Auth' );
  $this->Auth = new AuthComponent();

  $this->User->create();
  $this->User->set(array(
    'username' => $this->data['Realtor']['email'],
    'password' => $this->Auth->password($this->data['Realtor']['password']),
    'usergroup_id' => 2,
    'realtor_num' => $this->id
  ));
  if ($this->User->save()) {
    $this->save(array('user_id'=>$this->User->id));
  } else { 
    //error 
  }

Unfortunately, while this is successfully creating users, and the data all seems to match up with my expectations, I'm seemingly no longer getting AROs.

My Usergroup model contains the line

var $actsAs = array('Acl' => array('type' => 'requester'));

Beyond that, I have no idea how I would persuade my application to generate an ARO.

Is there anything I could have forgotten, that would help me get my ACL back on track?

EDIT:

I had this in the User model's afterSave which seems to have been causing various kinds of trouble:

function afterSave($created) {
    if (!$created) {
        $parent = $this->parentNode();
        $parent = $this->node($parent);
        $node = $this->node();
        $aro = $node[0];
        $aro['Aro']开发者_如何学C['parent_id'] = $parent[0]['Aro']['id'];
        $this->Aro->save($aro);
    }
}

(courtesy of this article: http://mark-story.com/posts/view/auth-and-acl-automatically-updating-user-aros) I don't know if that would have been fouling up my ARO creation somehow... probably teach me to add in random code snippets without fully understanding what they're doing, at the very least!


Ok I' m newbie
I can't understand your problem but
now I use Acl component with alaxos acl plugin
I try to understand of modified tree traversal algorithm
and set basic data for aro,aco,aro_aco,group table
and some requirement of plugin
I suggest you to use this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜