hei mark, i don’t understand about:
cake acl grant $aroAlias $acoAlias
can you explained to me :)
thanks
virgi on 12/26/11
virgi: The $acoAlias
and $aroAlias
should be replaced with the aliases for the ACO and ARO nodes you wish to connect.
mark story on 12/28/11
I’m just starting out with ACL. I was able to work through the tutorial in The Book. Thanks.
A few questions that I’ve be unable to answer:
- Can a user be assigned to multiple groups? – Does every user have to be assigned to a group? – If so, does that mean a general user group (ACO) must be created and mapped to all public actions (AROs)? Seems tedious? Can Auth->allow() or deny() be used to supplement the process?
Jason McCreary on 1/12/12
Hi Mark,
I love this tutorial and have used it many times to setup my Acl.
With CakePHP 2.0 out now, there are some changes necessary to your BuildAcl() function that I want to share below. I will just paste the whole function again but my comments are in line. Basically there are 3 small changes, one related to a deprecated call to Configure::listObjects() and two related to the new file naming scheme
Thanks so much for this tutorial and I hope this is useful for you and any others
function buildAcl() { $log = array();
$aco =& $this->Acl->Aco; $root = $aco->node(‘controllers’); if (!$root) { $aco->create(array(‘parent_id’ => null, ‘model’ => null, ‘alias’ => ‘controllers’)); $root = $aco->save(); $root[‘Aco’][‘id’] = $aco->id; $log[] = ‘Created Aco node for controllers’; } else { $root = $root0; } App::import(‘Core’, ‘File’); //This line was deprecated and is now completely removed, use App::Objects //$Controllers = Configure::listObjects(‘controller’); $Controllers = App::objects(‘controller’); $appIndex = array_search(‘App’, $Controllers); if ($appIndex !== false ) { unset($Controllers[$appIndex]); } $baseMethods = get_class_methods(‘Controller’); $baseMethods[] = ‘buildAcl’; // look at each controller in app/controllers foreach ($Controllers as $ctrlName) { // New naming scheme now includes the word “Controller so replace it” App::import(‘Controller’, str_replace( “Controller”, “”, $ctrlName ) ); //this line is now redundant, as ‘Controller’ is already included // $ctrlclass = $ctrlName . ‘Controller’; $methods = get_class_methods($ctrlName); // find / make controller node $controllerNode = $aco->node(‘controllers/’.$ctrlName); if (!$controllerNode) { $aco->create(array(‘parent_id’ => $root[‘Aco’][‘id’], ‘model’ => null, ‘alias’ => $ctrlName)); $controllerNode = $aco->save(); $controllerNode[‘Aco’][‘id’] = $aco->id; $log[] = ‘Created Aco node for ‘.$ctrlName; } else { $controllerNode = $controllerNode0; } //clean the methods. to remove those in Controller and private actions. foreach ($methods as $k => $method) { if (strpos($method, ‘_’, 0) === 0) { unset($methods[$k]); continue; } if (in_array($method, $baseMethods)) { unset($methods[$k]); continue; } $methodNode = $aco->node(‘controllers/’.$ctrlName.’/’.$method); if (!$methodNode) { $aco->create(array(‘parent_id’ => $controllerNode[‘Aco’][‘id’], ‘model’ => null, ‘alias’ => $method)); $methodNode = $aco->save(); $log[] = ‘Created Aco node for ‘. $method; } } } debug($log); }Kyle Newsome on 2/5/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
Can I use this tutorial on cakephp 2.0 or 2.1?
soe on 7/25/12
I have setup groups table for ACL and linked every user to a group, i.e. I have group_id column in users table with a valid value.
In aros table I have a record for every group. Do I need to add a separate record for every user into aros table??
Rashid Azar on 10/31/11