I am trying to make parts of menu conditional to user authorisation status. I have the following code in ‘protected/views/layouts/main.php’ -
…
array('label'=>'Management', 'items'=>array(
array('label'=>'User Management', 'url'=>array('/user')),
array('label'=>'Status Report', 'url'=>array('/casesheet/update')),
), 'visible'=>!Yii::app()->user->isUserAdmin),
…
I have initialised the variable in UserIdentity.php thus -
…
$this->_isUserAdmin=true;
…
$this->setState('isUserAdmin',$this->_userAdmin);
But when I run the program I get the following error.
[font="Verdana"][size="2"]
CException
Description
[color="maroon"][font="Verdana"][size="2"]Property "CWebUser.isUserAdmin" is not defined.[/size][/font][/color]
Source File
[font="Verdana"][size="2"]E:\xampp\htdocs\myWebFolder\icfelectcomp\framework\web\auth\CWebUser.php(108)[/size][/font]
[font="Verdana"] [/font]
[font=“Verdana”][size=“2”]I persume the problem is in initialisation as the menu works with ‘isGuest’ in place of ‘isUserAdmin’. So how do I set ‘isUserAdmin’ parameter in [color="#800000"]CWebUser at the very start?[/color][/size][/font]
[/size][/font]