Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

AclBehavior handel plugin name #944

Closed
wants to merge 2 commits into from

3 participants

@zoghal

AclBehavior support of plugin name when model is inside a plugin

@markstory
Owner

Would you normally have models with the same name between plugins + app dir?

I worry that this change will break applications when people upgrade. Any existing dbacl trees will need to be manually migrated or the names stored in the existing database will no longer match the conditions being used.

@zoghal

Basically there is no problem.
This is when we use this behavior in a Plugin models.

To use and access the Plugin models, you need to use Plugin name + model name.
(refrence : http://book.cakephp.org/2.0/en/plugins.html#plugin-models )

In the past, programmers had to manually do it. And this behavior will not be used.
(example : https://github.com/QuickAppsCMS/QuickApps-CMS/blob/1.1/QuickApps/Plugin/User/Model/Role.php )

@ceeram
Collaborator

-1 for this, i dont see the need to add plugin prefixes. You can use the behavior fine with plugin models.

@zoghal zoghal closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 8, 2012
  1. @zoghal

    AclBehavior handel plugin name

    zoghal authored
Commits on Nov 9, 2012
  1. @zoghal

    fix standard and whitespace.

    zoghal authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/Cake/Model/Behavior/AclBehavior.php
View
7 lib/Cake/Model/Behavior/AclBehavior.php
@@ -85,7 +85,10 @@ public function node(Model $model, $ref = null, $type = null) {
}
}
if (empty($ref)) {
- $ref = array('model' => $model->name, 'foreign_key' => $model->id);
+ $ref = array(
+ 'model' => is_null($model->plugin) ? $model->name : $model->plugin . '.' . $model->name,
+ 'foreign_key' => $model->id
+ );
}
return $model->{$type}->node($ref);
}
@@ -109,7 +112,7 @@ public function afterSave(Model $model, $created) {
}
$data = array(
'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null,
- 'model' => $model->name,
+ 'model' => is_null($model->plugin) ? $model->name : $model->plugin . '.' . $model->name,
'foreign_key' => $model->id
);
if (!$created) {
Something went wrong with that request. Please try again.