/** /bb** * @Author: ANH DUNG Dec 19, 2014 * @Todo: thiet lap quyen trong user se uu tien cao nhat. user deny hoac allow thi se k phu thuoc group. */ public function actionUser($id) { try { $mUser = Users::model()->findByPk($id); $this->pageTitle = 'Setting Privilege Users - ' . $mUser->first_name; if (is_null($mUser)) { throw new Exception('Setting Privilege user exists'); } if (isset($_POST['submit'])) { foreach ($this->aControllers as $keyController => $aController) { $mController = Controllers::getByName($keyController); if ($mController) { $mController->addUserRoles($this->postArrayCheckBoxToAllowDenyValue($keyController), $id); $this->setNotifyMessage(NotificationType::Success, 'Successful Update'); } } $this->refresh(); } $this->render('user', array('id' => $id, 'mUser' => $mUser, 'actions' => $this->listActionsCanAccess)); } catch (Exception $exc) { Yii::log("Uid: " . Yii::app()->user->id . " Exception " . $exc->getMessage(), 'error'); $code = 404; if (isset($exc->statusCode)) { $code = $exc->statusCode; } if ($exc->getCode()) { $code = $exc->getCode(); } throw new CHttpException($code, $exc->getMessage()); } }
?> ">Cancel</a>--> </div> </div> <div id="accordion"> <?php foreach ($this->aControllers as $keyController => $aController) { ?> <div class="block_privilege"> <h3><a class="l_margin_20 item_b" href="#"><?php echo $aController['alias']; ?> </a></h3> <?php $mController = Controllers::getByName($keyController); $aActionsAllow = ActionsRoles::getActionArrayByRoleIdAndControllerId($id, $mController->id); ?> <div class="wrap_privilege"> <!--<h2><?php echo $aController['alias']; ?> </h2>--> <a href="javascript:void(0)" class="checkAll item_b">Select All</a> | <a href="javascript:void(0)" class="clearAll item_b">Deselect All</a><br><br> <ul class="permission-list"> <?php foreach ($aController['actions'] as $keyAction => $aAction) { ?> <li><input type="checkbox" name="<?php echo $keyController . '[' . $keyAction . ']'; ?>
public static function getActionArrayAllowForCurrentUserByControllerName($controllerName) { try { $aResult = array(); $user_id = Yii::app()->user->id; $mUser = Users::model()->findByPk($user_id); $mController = Controllers::getByName($controllerName); // ANH DUNG FIX NOW 14, 2014 if ($mController) { $mActionsUsers = ActionsUsers::model()->findAll('user_id=' . $user_id . ' AND controller_id=' . $mController->id); if ($mActionsUsers == NULL) { $aActionsAllowGroup = ActionsRoles::getActionArrayByRoleIdAndControllerId($mUser->role_id, $mController->id); $aResult = $aActionsAllowGroup; } else { $aActionsAllowUser = ActionsUsers::getActionArrayByUserIdAndControllerId($user_id, $mController->id); $aResult = $aActionsAllowUser; } } // ANH DUNG FIX NOW 14, 2014 // if($mController) // { // $mActionsUsers = ActionsUsers::model()->find('user_id='.$user_id.' AND controller_id='.$mController->id); // $aActionsAllowGroup = ActionsRoles::getActionArrayByRoleIdAndControllerId($mUser->role_id, $mController->id); // $aActionsAllowUser = ActionsUsers::getActionArrayByUserIdAndControllerId($user_id, $mController->id); // if($mActionsUsers == NULL) // { // $aResult = $aActionsAllowGroup; // } // else // $aResult = $aActionsAllowUser; // } return $aResult; } catch (Exception $exc) { echo $exc->getMessage(); die; } }