当前位置: 首页>>代码示例>>PHP>>正文


PHP Rights::revoke方法代码示例

本文整理汇总了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));
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:52,代码来源:AdminController.php

示例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;
 }
开发者ID:stan5621,项目名称:jp_edu_online,代码行数:14,代码来源:UserInfo.php


注:本文中的Rights::revoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。