Exemplo n.º 1
0
 public function getCachedBoards()
 {
     if ($this->_cachedBoards == null) {
         $this->_cachedBoards = YiiForum::getAppParam('cachedBoards');
     }
     return $this->_cachedBoards;
 }
Exemplo n.º 2
0
 /**
  * Updates an existing AuthItem model.
  * If update is successful, the browser will be redirected to the 'view' page.
  *
  * @param string $id        	
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         $item = $this->model2Item($model, new Permission());
         $this->auth->update($id, $item);
         return $this->redirect(['index']);
     } else {
         $locals = [];
         $locals['groups'] = YiiForum::getAppParam('cachedPermissionsGroup');
         $parent = AuthItem::getAuthItemParent($id);
         if ($parent) {
             $model->category = $parent;
         }
         $locals['model'] = $model;
         return $this->render('update', $locals);
     }
 }
Exemplo n.º 3
0
 public function actionPermission($id)
 {
     $model = $this->findModel($id);
     $existPermissions = $this->auth->getPermissionsByRole($id);
     if (YiiForum::hasPostValue('submit')) {
         $parent = new Role();
         $parent->name = $id;
         $allPermissions = $this->auth->getPermissions();
         $selectedPermissions = YiiForum::getPostValue('selectedPermissions');
         $this->updatePermissions($allPermissions, $selectedPermissions, $existPermissions, $parent, new Permission());
         return $this->redirect(['index']);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['allPermissions'] = $this->getFormatAllPermissions();
         $locals['existPermissions'] = $existPermissions;
         //权限组
         $permissionsGroup = YiiForum::getAppParam('cachedPermissionsGroup');
         //var_dump($rolesGroup);
         //exit;
         $permissionsArr = [];
         foreach ($permissionsGroup as $group) {
             $permissionsArr[$group['name']] = $group['description'];
         }
         $permissionsArr['other'] = '其他';
         $locals['permissionsGroup'] = $permissionsArr;
         return $this->render('permission', $locals);
     }
 }
Exemplo n.º 4
0
 /**
  * 查询所有的角色,并个分组格式化
  */
 public function getFormatAllRoles()
 {
     $allRoles = $this->auth->getRoles();
     $allRolesArr = [];
     foreach ($allRoles as $prole) {
         $allRolesArr[] = $prole->name;
     }
     $allGroup = YiiForum::getAppParam('cachedRolesGroup');
     $resArr = [];
     $excluedArr = [];
     foreach ($allGroup as $group) {
         $allChild = $this->auth->getChildren($group['name']);
         $childArr = [];
         foreach ($allChild as $child) {
             if (in_array($child->name, $allRolesArr)) {
                 $childArr[$child->name] = ['name' => $child->name, 'description' => $child->description];
             }
             unset($allRoles[$child->name]);
         }
         $resArr[$group['name']] = $childArr;
         $excluedArr[] = $group['name'];
     }
     if (count($allRoles) > 0) {
         foreach ($allRoles as $role) {
             if (!in_array($role->name, $excluedArr)) {
                 $resArr['other'][$role->name] = ['name' => $role->name, 'description' => $role->description];
             }
         }
     }
     return $resArr;
 }