Because you are authorizing actions, you have to add the action to the aco
table.
You can do this by using the cake console... but here is some code that I
use to automatically do it for you.
Put this is your AppContoller...
/*
*
* Used for Adding Aco action automatically on page load.
*
* Designed for use in development and deployment.
* Call from beforeFilter in new controller and access each controller
method via a web browser,
* then remove from controller code, once you have everything initiated.
*
*/
function _initAco(){
// Get Action from Auth Component
$pathparts = explode('/',$this->Auth->action());
$path = '';
// Loops through the pieces of the path and adds them if necessary
foreach($pathparts as $key => $item){
$path .= $item;
$node = $this->Acl->Aco->node($path);
if(!$node && !isset($currentParent)){
$controllers = $this->Acl->Aco->node('controllers');
$currentParent = $controllers[0]['Aco'];
}
if($node){
$currentParent = $node[0]['Aco'];
}else{
$this->Acl->Aco->create(array(
'parent_id' => $currentParent['id'],
'model' => null, 'alias' => $pathparts[$key]
));
$node = $this->Acl->Aco->save();
$currentParent = array('id' => $this->Acl->Aco->id, 'alias' =>
$node['Aco']['alias']);
};
$path .= '/';
}
}
Then add $this->_initAco(); to the beforeFilter of the controller you are
working on.
function beforeFilter(){
$this->_initAco();
parent::beforeFilter();
}
Just remember to remove this code, when you are done developing on that
controller. It obviously adds weight... but for convenience, it's great.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php