Java代码 getId(); } if ($module === null && $this->getModule()) { $module = $this->getModule()->getId(); } return Privilege::model()->checkPower($module, $contrl, $action); } public function beforeAction($action) { $contrl = $this->getId(); $actionId = $action->getId(); $route = $contrl . '/' . $actionId; if (!in_array($route, array('site/login', 'site/error', 'site/logout')) && Yii::app()->user->id != 1) { $module = null; if ($action && $this->getModule()) { $module = $this->getModule()->getId(); } $this->purview($module, $contrl, $actionId); } return parent::beforeAction($action); }" wmode="transparent">
public function purview($module, $control, $action) {
if (!$this->checkPower($action, $control, module)) {
throw new CHttpException(403, '您没有访问权限!');
Yii::app()->end();
}
}
// CGRIDVIEW buttonID 'visible' =>'$this->grid->controller->checkPower("delete")',
public function checkPower($action, $contrl = null, $module = null) {
if ($contrl === null) {
$contrl = $this->getId();
}
if ($module === null && $this->getModule()) {
$module = $this->getModule()->getId();
}
return Privilege::model()->checkPower($module, $contrl, $action);
}
public function beforeAction($action) {
$contrl = $this->getId();
$actionId = $action->getId();
$route = $contrl . '/' . $actionId;
if (!in_array($route, array('site/login', 'site/error', 'site/logout')) && Yii::app()->user->id != 1) {
$module = null;
if ($action && $this->getModule()) {
$module = $this->getModule()->getId();
}
$this->purview($module, $contrl, $actionId);
}
return parent::beforeAction($action);
}