Refactoring ACL system to require less model code

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4502 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-02-10 22:59:08 +00:00
parent c87b48e034
commit 2a954b5fbf
4 changed files with 88 additions and 47 deletions

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* Tree behavior class.
* ACL behavior class.
*
* Enables a model object to act as a node-based tree.
* Enables objects to easily tie into an ACL system
*
* PHP versions 4 and 5
*
@ -95,9 +95,17 @@ class AclBehavior extends ModelBehavior {
function afterSave(&$model, $created) {
if ($created) {
$type = $this->__typeMaps[low($this->settings[$model->name]['type'])];
$parent = $this->node($model, $model->parentNode());
if(isset($parent['id'])) {
$parent = $parent['id'];
} else {
$parent = null;
}
$model->{$type}->create();
$model->{$type}->save(array(
'parent_id' => $model->parentNode(),
'parent_id' => $parent,
'model' => $model->name,
'foreign_key' => $model->id
));