
Untitled
By: a guest on
Aug 5th, 2012 | syntax:
None | size: 0.66 KB | hits: 16 | expires: Never
assign a user a role from admin creates a user, in Yii Rbac extension Rights
<?php
if (Yii::app()->user->isSuperuser) {
$all_roles=new RAuthItemDataProvider('roles', array(
'type'=>2,
));
$data=$all_roles->fetchData();
?>
<div>
<label for="type_id">Type</label>
<?php echo CHtml::dropDownList("Type",'',CHtml::listData($data,'name','name'));? >
</div>
<?php
}
?>
if(Yii::app()->user->isSuperuser)
$type=$_POST['Type'];
else
$type='User';
$authorizer = Yii::app()->getModule("rights")->authorizer;
$authorizer->authManager->assign($type, $model->id);
Yii::app()->authManager->assign($role, $userid);