/**
  * 更新权限
  */
 public function actionUpdate()
 {
     $id = $this->get('parent_id', 0);
     //parent_id为实际编辑的id
     /**
      * @var $perm \liuxy\admin\models\Permission
      */
     $perm = Permission::findOne([Permission::$pk => $id]);
     if ($perm) {
         if ($perm->editable == 1) {
             $perm->name = $this->get('name', '');
             $perm->description = $this->get('description', '');
             $perm->link = $this->get('link', '');
             $perm->icon = $this->get('icon', '');
             $perm->is_nav = $this->get('is_nav', Permission::NAV_NO);
             $perm->update_by = $this->user->username;
             if (!$perm->update()) {
                 $this->setError($perm->getErrors());
             }
             $this->setResponseData('data', ['name' => $perm->name, 'id' => $perm->id]);
         } else {
             $this->setError(Module::t('error.perm.noeditable'));
         }
     } else {
         $this->setError(Module::t('error.perm.notexists'));
     }
 }
 /**
  * 判断用户是否有权限访问
  * @param unknown $userId
  */
 public static function hasPermission($userId, $current)
 {
     if (empty($current) || $current == '#') {
         return true;
     }
     $p = Permission::findOne(['link' => $current]);
     if ($p) {
         $myPermissions = self::getPermission($userId);
         return in_array($p['id'], $myPermissions);
     } else {
         return true;
     }
 }