本文整理匯總了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;
}