Yii Authorization

Hi,

In the documentation it states to write a file like this …




$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');



Where do I put this code? And how do I include the nessacary libraries to make it work?

Any ideas folks?

http://www.yiiframework.com/doc/api/1.1/CPhpAuthManager

Hi thanks, but I am using the CDb version? Do you know if I can still write the file, rather than adding DB records manually?