我试图在我的应用中使用RBAC和Auth扩展。我能够通过扩展喜欢这里提供 GUI添加层次: yii-auth:我应该在哪里添加bizrule到新任务?
什么我试着是增加bizRule到updateOwnPost现在要做的。 据link我需要添加一些代码:
$auth=Yii::app()->authManager;
$auth->createOperation('createPost','create a post');
$auth->createOperation('readPost','read a post');
$auth->createOperation('updatePost','update a post');
$auth->createOperation('deletePost','delete a post');
$bizRule='return Yii::app()->user->id==$params["post"]->authID;';
$task=$auth->createTask('updateOwnPost','update a post by author himself',$bizRule);
$task->addChild('updatePost');
$role=$auth->createRole('reader');
$role->addChild('readPost');
$role=$auth->createRole('author');
$role->addChild('reader');
$role->addChild('createPost');
$role->addChild('updateOwnPost');
$role=$auth->createRole('editor');
$role->addChild('reader');
$role->addChild('updatePost');
$role=$auth->createRole('admin');
$role->addChild('editor');
$role->addChild('author');
$role->addChild('deletePost');
但是我们可以看到这个代码是创建新的操作/任务/角色。我已经通过GUI添加了它们。 所以我现在需要的是地方到另一个地方是这样的:
$bizRule='return Yii::app()->user->id==$params["post"]->authID;';
创建较早updateOwnPost任务。
OFC我的运气为首我只是为了对这个话题:link其中m-NEL说:
这个问题是在扩展的 页面的评论部分回答。阅读:http://www.yiiframework.com/extension/auth/#c11261
和OFC评论我需要的是冲出来的空间:)
有人能回答我该怎么办,提供bizrule到任务? 谢谢;) (和对不起4我的英语)