mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-04 10:32:40 +00:00
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:
parent
c87b48e034
commit
2a954b5fbf
4 changed files with 88 additions and 47 deletions
|
@ -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
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue