Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Bizrules And Accessrules Doubt

$
0
0
Hi everyone,

I've generated this without bizrules:
$auth=Yii::app()->authManager;
		$auth->createOperation('editar','Es una op...');
		$task=$auth->createTask('tarea_edicion','Es una tare...');
		$task->addChild('editar_tipos');
		$role=$auth->createRole('rol_edicion_tipos','Este....');
		$role->addChild('tarea_edicion_tipos');
		$auth->assign('rol_edicion',$this->user->id);


And using this in the controller:

public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('index','view','create','update','delete','admin'),
				'roles'=>array('rol_edicion'),
				//'expression'=>'Yii::app()->user->checkAccess("rol_edicion")',
			),


That works properly but I need bizrules... so I tried to use them, but it didn't work as I wanted.

So can I use bizrules via accessRules without using

if(Yii::app()->user->checkAccess(....
?

I mean , can I generate this new structure with bizrules:

$auth=Yii::app()->authManager;
		$auth->createOperation('editar_tipos','Es una op...');
		 $bizRule= "return 1 == 1";
		$task=$auth->createTask('tarea_edicion_tipos','Es una tare...');
		$task->addChild('editar_tipos');
		$role=$auth->createRole('rol_edicion_tipos','Este....',$bizRule);
		$role->addChild('tarea_edicion_tipos');
		$auth->assign('rol_edicion',$this->user->id);


And use it with the accessRules in the controller???

Because I tried it but it doesn't work, it's the same if I set

$bizRule= "return 1 == 0";

or
$bizRule= "return 1 == 1";


I can't access the controller as I could without bizrules...

Need some help please :D

Thanks!

Viewing all articles
Browse latest Browse all 18717

Trending Articles