UserController:
public function accessRules()
{
return array(
array('allow', // allow authenticated user to perform view and update actions
'actions'=>array('view','update','delete'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform index, create, admin and delete actions
'actions'=>array('index','create','admin'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
layouts/main:
<div id="mbmenu">
<?php
if (Yii::app()->user->isGuest) {
$this->widget('ext.mbmenu.MbMenu',array(
'activeCssClass' => 'active',
'activateParents' => true,
'items'=>array(
array('label'=>'Contact', 'url'=>array('/site/contact')),
array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
),
));
} else {
$this->widget('ext.mbmenu.MbMenu',array(
'activeCssClass' => 'active',
'activateParents' => true,
'items'=>array(
array('label'=>'Scaffold', 'url'=>array('/scaffold/admin')),
array('label'=>'Add Options', 'url'=>array(''),
'items'=>array(
array('label'=>'Scaffold', 'url'=>array(''),
'items'=>array(
array('label'=>'Department', 'url'=>array('/department/create')),
array('label'=>'Facility', 'url'=>array('/facility/create')),
array('label'=>'Type', 'url'=>array('/type/create')),
)),
array('label'=>'Inspector', 'url'=>array('/inspector/create')),
)
),
array('label'=>'Users', 'url'=>array('/user/admin')),
array('label'=>'Contact', 'url'=>array('/site/contact')),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'))
)
));
}
?>
</div><!-- mainmenu -->
What I would like to happen is if logged-in username is NOT ‘admin’ and Users tab from mbmenu was clicked then it should redirect to own account id in view (CDetailView) and will display only update and delete crud action on sidebar (Operations) but if logged-in as admin then redirect to ‘url’=>array(’/user/admin’)) and with normal crud actions on sidebar.