Skip to content
Browse files

updating AclBehavior docs, adding info about setting up as both

  • Loading branch information...
1 parent 5a22982 commit f150c906240ab57398af852f9915b48f80381d2d @ceeram ceeram committed
Showing with 23 additions and 7 deletions.
  1. +1 −1 en/appendices/new-features-in-cakephp-2-1.rst
  2. +22 −6 en/core-libraries/behaviors/acl.rst
View
2 en/appendices/new-features-in-cakephp-2-1.rst
@@ -159,7 +159,7 @@ In the above example the view will not be rendered if the client sent the
header `If-Modified-Since`, and the response will have a 304 status.
Helpers
-====
+=======
HtmlHelper
-----------
View
28 en/core-libraries/behaviors/acl.rst
@@ -10,7 +10,7 @@ transparently.
To use the new behavior, you can add it to the $actsAs property of
your model. When adding it to the actsAs array you choose to make
the related Acl entry an ARO or an ACO. The default is to create
-AROs::
+ACOs::
<?php
class User extends AppModel {
@@ -25,6 +25,14 @@ behavior in ACO mode use::
public $actsAs = array('Acl' => array('type' => 'controlled'));
}
+For User and Group models it is common to have both ACO and ARO nodes,
+to achieve this use::
+
+ <?php
+ class User extends AppModel {
+ public $actsAs = array('Acl' => array('type' => 'both'));
+ }
+
You can also attach the behavior on the fly like so::
<?php
@@ -63,13 +71,11 @@ belongsTo Group::
$data = $this->data;
if (empty($this->data)) {
$data = $this->read();
- }
+ }
if (!$data['User']['group_id']) {
return null;
} else {
- $this->Group->id = $data['User']['group_id'];
- $groupNode = $this->Group->node();
- return array('Group' => array('id' => $groupNode[0]['Aro']['foreign_key']));
+ return array('Group' => array('id' => $data['User']['group_id']));
}
}
@@ -91,7 +97,7 @@ data array::
<?php
$this->User->id = 1;
$node = $this->User->node();
-
+
$user = array('User' => array(
'id' => 1
));
@@ -99,7 +105,17 @@ data array::
Will both return the same Acl Node information.
+If you had setup AclBehavior to create both ACO and ARO nodes, you need to
+specify which node type you want::
+ <?php
+ $this->User->id = 1;
+ $node = $this->User->node(null, 'Aro');
+
+ $user = array('User' => array(
+ 'id' => 1
+ ));
+ $node = $this->User->node($user, 'Aro');
.. meta::
:title lang=en: ACL

0 comments on commit f150c90

Please sign in to comment.
Something went wrong with that request. Please try again.