Set permission regarding defined in permissionMap

@return  bool
424163
public function setMapPermission($mode = null)
    {
        $this->permissionError = array();
        $this->permissionErrorRules = array();

        $params = $this->getParams();

        $permissionRules = $this->permissionRules;
        if (isset($mode)) {
            foreach ($permissionRules as &$value) {
                $value = $mode;
            }
        }

        $result = true;
        foreach ($params['permissionMap'] as $type => $items) {

            $permission = $permissionRules[$type];

            foreach ($items as $item) {

                if (file_exists($item)) {

                    try {
                        $this->chmod($item, $permission, true);
                    } catch (\Exception $e) {
                    }

                    $res = is_readable($item);

                    /** check is wtitable */
                    if ($type == 'writable') {

                        $res &= is_writable($item);

                        if (is_dir($item)) {
                            $name = uniqid();

                            try {
                                $res &= $this->getFileManager()->putContents(array($item, $name), 'test');
                                $res &= $this->getFileManager()->removeFile($name, $item);
                            } catch (\Exception $e) {
                                $res = false;
                            }
                        }
                    }

                    if (!$res) {
                        $result = false;
                        $this->permissionError[] = $item;
                        $this->permissionErrorRules[$item] = $permission;
                    }
                }
            }
        }

        return $result;
    }
948901
private function registerPermissions()
    {
        collect([
            'admin_access',
        ])->map(function ($permission) {
            Gate::define($permission, function ($user) use ($permission) {
                if ($this->nobodyHasAccess($permission)) {
                    return true;
                }

                return $user->hasRoleWithPermission($permission);
            });
        });
    }
550341
public function change_permission($mode)
    {

        if (empty($mode) || !is_int($mode)) return false;

        if (chmod($this->path . $this->filename, $mode)) {
            return $this->open($this->path . $this->filename);
        }

        return false;
    }
56303
function StatePermissionMap(state) {
    var toStateObject = state.$$permissionState();
    var toStatePath = toStateObject.path;

    angular.forEach(toStatePath, function (state) {
      if (areSetStatePermissions(state)) {
        var permissionMap = new PermPermissionMap(state.data.permissions);
        this.extendPermissionMap(permissionMap);
      }
    }, this);
  }
1326796
protected function setAccessFileManager()
    {
        $path_from_query = $this->getQuery('cmd', 'list');
        $this->data_command = $this->command->get($path_from_query);

        if (empty($this->data_command['command_id'])) {
            return $this->data_access = false;
        }

        if (!$this->access("module_file_manager_{$this->data_command['command_id']}")) {
            return $this->data_access = false;
        }

        if (!empty($this->data_selected) && $this->isQuery('selected')) {
            return $this->data_access = true;
        }

        if (!$this->command->isAllowed($this->data_command, $this->data_file)) {
            return $this->data_access = false;
        }

        if ($this->accessPathAccessFileManager($this->data_path)) {
            return $this->data_access = true;
        }

        return $this->data_access = $this->access('module_file_manager');
    }
559301
protected function initPermissions()
    {
        if ($this->app->runningInConsole()) {
            return;
        }

        Permission::get()->map(function(Permission $permission) {
            Gate::define($permission->name, function ($user) use ($permission) {
                return $user->hasPermission($permission);
            });
        });        
    }
584206
public function setPermissionObject($a)
    {
        if ($a->isGlobalArea()) {
            $cx = Stack::getByName($a->getAreaHandle(), 'ACTIVE');
            $a = Area::get($cx, STACKS_AREA_NAME);
            if (!$a) {
                return false;
            }
        }

        if ($a instanceof SubArea && !$a->overrideCollectionPermissions()) {
            $a = $a->getSubAreaParentPermissionsObject();
        }
        $this->permissionObject = $a;

        // if the area overrides the collection permissions explicitly (with a one on the override column) we check
        if ($a->overrideCollectionPermissions()) {
            $this->permissionObjectToCheck = $a;
        } else {
            if ($a->getAreaCollectionInheritID() > 0) {
                // in theory we're supposed to be inheriting some permissions from an area with the same handle,
                // set on the collection id specified above (inheritid). however, if someone's come along and
                // reverted that area to the page's permissions, there won't be any permissions, and we
                // won't see anything. so we have to check
                $areac = Page::getByID($a->getAreaCollectionInheritID());
                $inheritArea = Area::get($areac, $a->getAreaHandle());
                if ($inheritArea && $inheritArea->overrideCollectionPermissions()) {
                    // okay, so that area is still around, still has set permissions on it. So we
                    // pass our current area to our grouplist, userinfolist objects, knowing that they will
                    // smartly inherit the correct items.
                    $this->permissionObjectToCheck = $inheritArea;
                }
            }

            if (!$this->permissionObjectToCheck) {
                $this->permissionObjectToCheck = $a->getAreaCollectionObject();
            }
        }
    }
707848
public function setPermissionsAttribute($permissions)
    {
        if (! ($permissions instanceof ChannelPermission)) {
            return;
        }

        list($allow, $deny) = $permissions->bitwise;
        $this->allow        = $allow;
        $this->deny         = $deny;

        $this->attributes['permissions'] = $permissions;
    }
530316
public function permissionTree()
  {
    $permtree = array();

    foreach($this->permissionCats() as $key => $val)
    {
      $permtree[$val]["permcatid"]      = $val;
      $permtree[$val]["permcathex"]     = "0x" . dechex($val);
      $permtree[$val]["permcatname"]    = TeamSpeak3_Helper_String::factory(TeamSpeak3_Helper_Convert::permissionCategory($val));
      $permtree[$val]["permcatparent"]  = $permtree[$val]["permcathex"]{3} == 0 ? 0 : hexdec($permtree[$val]["permcathex"]{2} . 0);
      $permtree[$val]["permcatchilren"] = 0;
      $permtree[$val]["permcatcount"]   = 0;

      if(isset($permtree[$permtree[$val]["permcatparent"]]))
      {
        $permtree[$permtree[$val]["permcatparent"]]["permcatchilren"]++;
      }

      if($permtree[$val]["permcatname"]->contains("/"))
      {
        $permtree[$val]["permcatname"] = $permtree[$val]["permcatname"]->section("/", 1)->trim();
      }

      foreach($this->permissionList() as $permission)
      {
        if($permission["permid"]["permcatid"] == $val)
        {
          $permtree[$val]["permcatcount"]++;
        }
      }
    }

    return $permtree;
  }
1154868
public function setId(int $value) : Permission
    {

        if ($this->data['id'] !== $value) {
            $this->data['id'] = $value;
            $this->setModified('id');
        }

        return $this;
    }
490875
public function getPermissionsAttribute()
    {
        $permissions = new Collection();

        foreach ($this->roles as $role) {
            foreach ($role->permissions as $permission) {
                $permissions->push($permission);
            }
        }

        return $permissions;
    }
835473
function canSwap()
    {
        if ( !isset( $this->Permissions['can_swap'] ) )
        {
            $this->Permissions['can_swap'] = $this->checkAccess( 'edit' );
        }
        return ( $this->Permissions['can_swap'] == 1 );
    }
92299
public function getCanAttribute()
    {
        $permissions = [];
        foreach (Permission::all() as $permission) {
            if (Auth::check() && Auth::user()->can($permission->name)) {
                $permissions[$permission->name] = true;
            } else {
                $permissions[$permission->name] = false;
            }
        }
        return $permissions;
    }
1302735
public function hasPermission(string $name): bool
    {
        $permissions = $this->getPermissions();
        if (array_search('all', $permissions) !== false) {
            return true;
        }
        return array_search($name, $permissions) !== false;
    }
721639
public static function map()
    {
        $permissions = [];

        foreach (static::get() as $permission) {
            $permissions[$permission->permission][] = (string) $permission->group_id;
        }

        return $permissions;
    }
1181427
public function hasPermission()
    {
        if (!($this->model instanceof ACLModel)) {
            return true;
        }

        return $this->model->can(static::MODEL_PERMISSION, ACLModelRequester::get());
    }
1061944
public function can($name)
    {
        foreach ($this->permissions as $permission) {
            if ($permission->name == $name || $permission->id == $name) {
                return true;
            }
        }

        return false;
    }