权限问题 搞的我蛋疼了,帮忙看下 [ 新手入门 ]
<?php
/*
 * Created on 2011-10-12
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class AuthController extends CController{
    /**
    * @return array action filters
    */
    public function filters()
    {
        return array(
            'accessControl', // perform access control for CRUD operations
        );
    }
    /**
    * Specifies the access control rules.
    * This method is used by the 'accessControl' filter.
    * @return array access control rules
    */
    public function accessRules()
    {
        return array(
            array('allow',  // allow all users to perform 'index' and 'view' actions
                'actions'=>array('show'),
                'users'=>array('*')
            ),
        );
    }
    public function actionTest(){
        $auth=Yii::app()->authManager;
        $auth->createOperation("postop",'postpost');
        $auth->createTask("postta","posts");
        $auth->createRole("postro","post");
        $auth->addItemChild("postro","postop");
        $auth->assign("postro",'demo');
    }
    public function actionShow(){
        //echo Yii::app()->user->isGuest;
        if(Yii::app()->user->checkAccess("postop")){
            echo 'Yes';
        }else{
            echo 'No';
        }
    }
}
?>
结果还是打印 No,蛋疼。 而且在表中有记录:
authassignment postop	demo	NULL	N;
   authitem:    postop	0	postpost	NULL	N;
			postro	2	post	NULL	N;
			postta	1	posts	NULL	N;
共 1 条回复
- 
 zk546113096 回复于 2011-10-12 13:41 举报 zk546113096 回复于 2011-10-12 13:41 举报去下这个插件玩吧。。。 
simpman
            注册时间:2011-09-16
最后登录:2021-11-04
在线时长:6小时32分
    最后登录:2021-11-04
在线时长:6小时32分
- 粉丝1
- 金钱225
- 威望0
- 积分285
