本文整理汇总了PHP中Rights::revoke方法的典型用法代码示例。如果您正苦于以下问题:PHP Rights::revoke方法的具体用法?PHP Rights::revoke怎么用?PHP Rights::revoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rights
的用法示例。
在下文中一共展示了Rights::revoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionUpdate()
{
$model = $this->loadModel();
$profile = $model->profile;
$this->performAjaxValidation(array($model, $profile));
/* Get current user role. Added by Phihx. date 14/02/2014*/
$assignedItems = Rights::getAuthorizer()->getAuthItems(null, $model->id);
$userCurrenRole = array_keys($assignedItems);
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$profile->attributes = $_POST['Profile'];
if ($model->validate() && $profile->validate()) {
/*$old_password = User::model()->notsafe()->findByPk($model->id);
if ($old_password->password!=$model->password) {
$model->password=Yii::app()->controller->module->encrypting($model->password);
$model->activkey=Yii::app()->controller->module->encrypting(microtime().$model->password);
}*/
if (!empty($_POST['newPassword'])) {
$model->password = Yii::app()->controller->module->encrypting($_POST['newPassword']);
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $_POST['newPassword']);
}
$model->save();
$profile->save();
/*remove role for user. added by phihx. date 14/02/2014*/
if (!empty($userCurrenRole)) {
foreach ($userCurrenRole as $role) {
Rights::revoke($role, $model->id);
}
}
/*Add role for user. added by phihx. date 14/02/2014*/
if (!empty($_POST['user_role'])) {
//foreach($_POST['user_role'] as $role){
Rights::assign($_POST['user_role'], $model->id);
//}
}
Yii::app()->user->setFlash('success', translate('Chỉnh sửa người dùng thành công.'));
$this->redirect(PIUrl::createUrl('/user'));
} else {
$profile->validate();
}
}
/* Get All role. Added by Phihx. date 14/02/2014*/
$allRoles = $this->getAllRoleUser();
//$allClass = Classes::model()->findAll();
$arrClass[''] = '---Chọn lớp---';
Yii::app()->theme = 'flatlab';
$this->render('update', array('model' => $model, 'profile' => $profile, 'allRoles' => $allRoles, 'userCurrenRole' => $userCurrenRole));
}
示例2: setRoles
public function setRoles($roles)
{
// $authorizer = Yii::app()->getModule("rights")->getAuthorizer();
if (!is_array($roles)) {
return false;
}
foreach ($this->roles as $role) {
Rights::revoke($role, $this->id);
}
foreach ($roles as $role) {
Rights::assign($role, $this->id);
}
return true;
}