Yes, I did in cake.
I am no expert, so be aware that my solution can have some flaws.
so in app_controller.php :
<?php
function beforeRender()
{
/**
* If we have an authorised user logged then pass over an
array of
* controllers to which they have index action permission
*/
if ($this->Auth->user()) {
$controllerList = Configure::listObjects('controller');
$permittedControllers = array();
foreach ($controllerList as $controllerItem) {
if (($controllerItem != 'App')
&& ($this->__permitted($controllerItem, 'index'))
) {
$permittedControllers[] = $controllerItem;
}
}
/**
* build menu based on user's permissions
*/
$this->nav = array_intersect($this->nav,
$permittedControllers);
/**
* build sub menu based on user's permission
*/
foreach ($this->subnav as $k => $s) {
if (is_array($s)) {
if (empty($s)) {
unset($this->subnav[$k]);
continue;
}
$s = (string)array_shift($s);
}
if (!$this->__permitted($this->name, $s)) {
unset($this->subnav[$k]);
}
}
}
$this->set('nav', $this->nav);
$this->set('subnav', $this->subnav);
}
?>
"nav" holds an array of "menu items". In my case all items are
controller names, because i build my menu based on them. then I have a
"subnav" that holds the controllers actions so I show only the action
that the user has access to. so in the layout (or view) I loop into
the vars "nav" and "subnav" building the menu.
of course you can hack it to have a different approach.
Best,
~IF.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---