I am setting up a new app using ACL. I am using Role ,
user can only have 1 role
so User model has:
var $hasOne = array(
'Role' => array(
'className' => 'Role',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => ''
)
);
'Role' => array(
'className' => 'Role',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => ''
)
);
function parentNode() {
if (!$this->id && empty($this->data)) {
return null;
}
$data = $this->data;
if (empty($this->data)) {
$data = $this->read();
}
if (!$data['User']['role_id']) {
return null;
} else {
return array('Role' => array('id' => $data['User']['role_id']));
}
}
if (!$this->id && empty($this->data)) {
return null;
}
$data = $this->data;
if (empty($this->data)) {
$data = $this->read();
}
if (!$data['User']['role_id']) {
return null;
} else {
return array('Role' => array('id' => $data['User']['role_id']));
}
}
but when adding users with different roles ACOS looks wrong:
1, NULL, 'Role', 1, NULL, 1, 10),
(2, NULL, 'Role', 2, NULL, 11, 18),
(3, NULL, 'Role', 3, NULL, 19, 22),
(4, NULL, 'Role', 4, NULL, 23, 24),
(5, NULL, 'Role', 5, NULL, 25, 26),
(6, 2, 'User', 4, NULL, 16, 17), <- foreign key is wrong
(7, 1, 'User', 4, NULL, 8, 9); <- foreign key is wrong
(2, NULL, 'Role', 2, NULL, 11, 18),
(3, NULL, 'Role', 3, NULL, 19, 22),
(4, NULL, 'Role', 4, NULL, 23, 24),
(5, NULL, 'Role', 5, NULL, 25, 26),
(6, 2, 'User', 4, NULL, 16, 17), <- foreign key is wrong
(7, 1, 'User', 4, NULL, 8, 9); <- foreign key is wrong
the foreign keys should be differet no?
Where did I go wrong here?
Dave
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment