Один из способов сделать это - установить переменную в функциях вашего контроллера
function beforeFilter()
{
if($this->Auth->user('role_id')==1){
$this->set("role",$this->Auth->user('role_id'));//it will set a variable role for your view
}
else
{
$this->set("role",2);//2 is the role of normal users
}
}
по вашему мнению, вы тестируете эту переменную, как показано ниже
<?php if($role==1){ ?>
echo $html->link('view registered users',array('controller'=>'users','action'=>'admin_check_users'),array('title'=>'Users'));/provide a link for admin using html helper; }
else{
echo $html->link('logout',array('controller'=>'users','action'=>'logout'),array('title'=>'Logout...'));//provide a link for normal users using html helper;
}
?>
для вашего второго ответа ... вы можете сделать то же самое ...
function beforeFilter()
{
if($this->Auth->user('role_id')==1){
$this->Auth->allow('admin_view','admin_controls');//put your all admin actions separated by comma
}
}