mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 11:32:40 +00:00
Fixing bug for related records not being returned when using $recursive > 1.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5902 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
28d6ef1688
commit
8d6599c34b
19 changed files with 492 additions and 359 deletions
|
@ -52,8 +52,8 @@ class AclBehavior extends ModelBehavior {
|
|||
if (is_string($config)) {
|
||||
$config = array('type' => $config);
|
||||
}
|
||||
$this->settings[$model->name] = am(array('type' => 'requester'), $config);
|
||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
$this->settings[$model->currentModel] = am(array('type' => 'requester'), $config);
|
||||
$type = $this->__typeMaps[$this->settings[$model->currentModel]['type']];
|
||||
|
||||
if (!ClassRegistry::isKeySet($type)) {
|
||||
uses('model' . DS . 'db_acl');
|
||||
|
@ -63,7 +63,7 @@ class AclBehavior extends ModelBehavior {
|
|||
}
|
||||
$model->{$type} =& $object;
|
||||
if (!method_exists($model, 'parentNode')) {
|
||||
trigger_error("Callback parentNode() not defined in {$model->name}", E_USER_WARNING);
|
||||
trigger_error("Callback parentNode() not defined in {$model->currentModel}", E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -73,9 +73,9 @@ class AclBehavior extends ModelBehavior {
|
|||
* @return array
|
||||
*/
|
||||
function node(&$model, $ref = null) {
|
||||
$type = $this->__typeMaps[low($this->settings[$model->name]['type'])];
|
||||
$type = $this->__typeMaps[low($this->settings[$model->currentModel]['type'])];
|
||||
if (empty($ref)) {
|
||||
$ref = array('model' => $model->name, 'foreign_key' => $model->id);
|
||||
$ref = array('model' => $model->currentModel, 'foreign_key' => $model->id);
|
||||
}
|
||||
return $model->{$type}->node($ref);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class AclBehavior extends ModelBehavior {
|
|||
*/
|
||||
function afterSave(&$model, $created) {
|
||||
if ($created) {
|
||||
$type = $this->__typeMaps[low($this->settings[$model->name]['type'])];
|
||||
$type = $this->__typeMaps[low($this->settings[$model->currentModel]['type'])];
|
||||
$parent = $model->parentNode();
|
||||
if (!empty($parent)) {
|
||||
$parent = $this->node($model, $parent);
|
||||
|
@ -97,7 +97,7 @@ class AclBehavior extends ModelBehavior {
|
|||
$model->{$type}->create();
|
||||
$model->{$type}->save(array(
|
||||
'parent_id' => Set::extract($parent, "0.{$type}.id"),
|
||||
'model' => $model->name,
|
||||
'model' => $model->currentModel,
|
||||
'foreign_key' => $model->id
|
||||
));
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class AclBehavior extends ModelBehavior {
|
|||
*
|
||||
*/
|
||||
function afterDelete(&$model) {
|
||||
$type = $this->__typeMaps[low($this->settings[$model->name]['type'])];
|
||||
$type = $this->__typeMaps[low($this->settings[$model->currentModel]['type'])];
|
||||
$node = Set::extract($this->node($model), "0.{$type}.id");
|
||||
if (!empty($node)) {
|
||||
$model->{$type}->delete($node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue