Beispiel #1
0
 /**
  * 单例构造器
  *
  * @return KefuRbacTool
  */
 public static function getInstance()
 {
     if (NULL == KefuRbacTool::$instance) {
         KefuRbacTool::$instance = new KefuRbacTool();
     }
     return KefuRbacTool::$instance;
 }
Beispiel #2
0
 /**
  * 进行权限检查的内联过滤器
  * 当权限检查失败时抛出全局异常
  * 
  * @param CFilterChain $filterChains
  */
 public function filterAuthCheck($filterChains)
 {
     // 未登录用户直接调转到首页,强制重新登录
     if (Yii::app()->user->isGuest) {
         $this->redirect(Yii::app()->createAbsoluteUrl('adminlogin/index'));
     }
     KefuRbacTool::getInstance()->checkAccess();
     $filterChains->run();
 }
Beispiel #3
0
 public function __construct()
 {
     $this->user_id = Yii::app()->user->id;
     // 对于超级用户,功能导航栏全开
     if (in_array($this->user_id, Yii::app()->params['super_admin'])) {
         $this->is_super_user = TRUE;
     }
     $_list_tasks = KefuRbacTool::getInstance()->getAllTaskOnRole($this->user_id);
     foreach ($_list_tasks as $_raw_task_item) {
         $_rights_tmp = explode('-', $_raw_task_item);
         $pre_label = 2 == count($_rights_tmp) ? $_rights_tmp[1] : $_rights_tmp[0];
         if (!in_array($pre_label, $this->list_pre_tasks)) {
             array_push($this->list_pre_tasks, $pre_label);
         }
     }
 }
Beispiel #4
0
 /**
  * 职能删除功能
  */
 public function actionAssignDelRoleToUser()
 {
     $email = Yii::app()->getRequest()->getParam("email", "");
     $roled = Yii::app()->getRequest()->getParam("roled", "");
     if (!empty($email) && !empty($roled)) {
         $rolArr = explode(",", $roled);
         //循环遍历增加
         foreach ($rolArr as $value) {
             if (!empty($value)) {
                 KefuRbacTool::getInstance()->revoke($value, $email);
             }
         }
         $this->_refreshRole($email);
     }
 }