Hi all,
I am relatively new to Yii and am currently developing my first proper application using the framework. I have been using the Agile Yii book as a reference for part of my project - since the functionality I need is very similar. Largely things are working OK, however I have run into a problem with checkAccess. When I try to check a users role from a view file my view doesn't render beyond the call to check Access, only things before this are rendered - there are no error messages & nothing is logged to application.log.
This is an example of my call to check access
I have configured RBAC using the standard tables & populated the tables with my operations, tasks & roles.
I have another table 'projectTeam' Which holds userId, projectId & role.
When I assign a user to a role I am applying the following business rule
The business rule uses this isUserInRole($role) method in the Project model
I believe the problem is with this function as I have tried executing the function without calling checkAccess and get a similar problem.
If anyone can offer some help I would really appreciate it - this is a project for my degree and my deadline is approaching rapidly! I really need to get this fixed ASAP so I can get on with the other features I need to implement!
Thanks in advance
I am relatively new to Yii and am currently developing my first proper application using the framework. I have been using the Agile Yii book as a reference for part of my project - since the functionality I need is very similar. Largely things are working OK, however I have run into a problem with checkAccess. When I try to check a users role from a view file my view doesn't render beyond the call to check Access, only things before this are rendered - there are no error messages & nothing is logged to application.log.
This is an example of my call to check access
$params =array("project"=>$model); if(Yii::app()->user->checkAccess('owner',$params)){ echo 'hello?'; }
I have configured RBAC using the standard tables & populated the tables with my operations, tasks & roles.
I have another table 'projectTeam' Which holds userId, projectId & role.
When I assign a user to a role I am applying the following business rule
$auth = Yii::app()->authManager; $bizRule = 'return isset($params["project"])&&$params["project"]->isUserInRole("'.$model->role.'");'; $auth->assign($model->role,$user->id, $bizRule);
The business rule uses this isUserInRole($role) method in the Project model
public function isUserInRole($role){ Yii::log('into isUserInRole model method'); $sql = "SELECT role FROM projectTeam WHERE projectId =:pid AND userId=:uId AND role=:role"; $command = Yii::app()->db->createCommand($sql); $command->bindValue(":pId",$this->id,PDO::PARAM_INT); $command->bindValue(":uId",Yii::app()->user->getId(),PDO::PARAM_INT); $command->bindValue(":role", $role,PDO::PARAM_STRING); return $command->execute()==1 ? true : false; }
I believe the problem is with this function as I have tried executing the function without calling checkAccess and get a similar problem.
If anyone can offer some help I would really appreciate it - this is a project for my degree and my deadline is approaching rapidly! I really need to get this fixed ASAP so I can get on with the other features I need to implement!
Thanks in advance