Welcome to the Cookbook

loading...

6.1 ACL

There is no translation yet for this section. Please help out and translate this.. More information about translations

The Acl behavior provides a way to seamlessly integrate a model with your ACL system. It can create both AROs or ACOs 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.

class User extends AppModel {
	var $actsAs = array('Acl' => array('type' => 'requester'));
}
  1. class User extends AppModel {
  2. var $actsAs = array('Acl' => array('type' => 'requester'));
  3. }

This would attach the Acl behavior in ARO mode. To join the ACL behavior in ACO mode use:

class Post extends AppModel {
	var $actsAs = array('Acl' => array('type' => 'controlled'));
}
  1. class Post extends AppModel {
  2. var $actsAs = array('Acl' => array('type' => 'controlled'));
  3. }

You can also attach the behavior on the fly like so:

	$this->Post->Behaviors->attach('Acl', array('type' => 'controlled'));
  1. $this->Post->Behaviors->attach('Acl', array('type' => 'controlled'));