1
我有未來accessRules控制器指定控制器動作:的Yii ::獲得通過的行動()
public function accessRules()
{
return array(
array('allow',
'actions'=>array('login','logout'),
'users'=>array('*'),
),
array('allow',
'actions'=>array('index'),
'users'=>array('@'),
),
array('allow',
'actions'=>array('users'),
'expression'=>'$user->getState(\'role\')==0',
),
array('deny',
'users'=>array('*'),
),
);
}
的所有操作(在所有控制器)的行爲規定()方法:
public function actions()
{
return array(
'index'=>$this->module->getName().'.controllers.main.IndexAction',
'login'=>$this->module->getName().'.controllers.main.LoginAction',
'logout'=>$this->module->getName().'.controllers.main.LogoutAction',
);
}
是有機會得到控制器/動作列表取決於當前的用戶權限? 我想建立與所有控制器的名單和他們的行動,這樣的一個導航菜單:
- Controler1
(show only if current user have permissions to access it)
- Controler1 /動作1
(show only if current user have permissions to access it)
- Controler1 /動作2
(show only if current user have permissions to access it)
- Controler1 /動作1
- 控制器2
(show only if current user have permissions to access it)
- Controler2 /動作1
(show only if current user have permissions to access it)
- Controler2 /動作2
(show only if current user have permissions to access it)
- Controler2 /動作1