Tests for file permissions. The permissions argument can be several flags
of type FilePermission.<br />
<br />
On systems where files do not have permissions this function always returns true.

@param FilePermission $permission
@return boolean
337805
public function permission($permission): bool
    {
        $perms = fileperms($this->getAbsoluteFilePath());

        switch ($permission) {
            case FilePermission::READ_OWNER:
                return (($perms & 0x0100) ? true : false);

            case FilePermission::WRITE_OWNER:
                return (($perms & 0x0080) ? true : false);

            case FilePermission::EXE_OWNER:
                return (($perms & 0x0040) ?
                    (($perms & 0x0800) ? null /* 's' */ : true) :
                    (($perms & 0x0800) ? null /* 'S' */ : false));

            case FilePermission::READ_USER:
                return $this->isReadable();

            case FilePermission::WRITE_USER:
                return $this->isWritable();

            case FilePermission::EXE_USER:
                return $this->isExecutable();

            case FilePermission::READ_GROUP:
                return (($perms & 0x0020) ? true : false);

            case FilePermission::WRITE_GROUP:
                return (($perms & 0x0010) ? true : false);

            case FilePermission::EXE_GROUP:
                return (($perms & 0x0008) ?
                    (($perms & 0x0400) ? null /* 's' */ : true) :
                    (($perms & 0x0400) ? null /* 'S' */ : false));

            case FilePermission::READ_OTHER:
                return (($perms & 0x0004) ? true : false);

            case FilePermission::WRITE_OTHER:
                return (($perms & 0x0002) ? true : false);

            case FilePermission::EXE_OTHER:
                return (($perms & 0x0001) ?
                    (($perms & 0x0200) ? null /* 't' */ : true) :
                    (($perms & 0x0200) ? null /* 'T' */ : false));
        }

        return true;
    }
252221
public function hasPermission ($permission = null, $and = false)
		{
			if (Yii::$app->user->can(User::R_ADMIN))
				return true;

			if ($permission == null)
				return false;

			if (is_string($permission))
			{
				return Yii::$app->user->can($permission, [], false);
			}
			elseif (is_array($permission))
			{
				foreach ($permission as $item)
				{
					if ($and)
					{
						if (!Yii::$app->user->can($item, [], false))
							return false;
					}
					else
					{
						if (Yii::$app->user->can($item, [], false))
							return true;
					}
				}
			}

			return false;
		}
355350
public function findWithPermission($permission)
    {
        return array_filter(
            $this->findAll(),
            function ($user) use ($permission) {
                return $user->has($permission);
            }
        );
    }
731251
function is_permission_requested( $permission ) {
            return isset( $this->_permissions[ $permission ] ) && ( true === $this->_permissions[ $permission ] );
        }
312580
public function isPermitted( $permission ) {

		if( is_string( $permission ) ) {

			return in_array( $permission, $this->permissions );
		}
		else {

			$permitted = false;

			foreach( $permission as $perm ) {

				if( in_array( $perm, $this->permissions ) ) {

					$permitted = true;

					break;
				}
			}

			return $permitted;
		}
	}
1205383
public function hasPermission($permission, $force = false)
    {
        $permissions = $this->getAllPermissions($force)->pluck('name')->toArray();

        if (strpos($permission, '*')) {
            $permission = substr($permission, 0, -2);

            return (bool) preg_grep('~'.$permission.'~', $permissions);
        }

        return in_array($permission, $permissions);
    }
1167854
public function deletePermission($permission)
    {
        if ($this->hasPermission($permission)) {
            return PermissionRole::where(
                    ['role_id' => $this->id, 'permission_id' => $permission->id]
                )->first()->delete();
        }

        return false;
    }
360923
public function can(string $permission): bool
    {
        if ($this->isAdministrator()) {
            return true;
        }

        if ($this->permissions->pluck('slug')->contains($permission)) {
            return true;
        }

        return $this->roles->pluck('permissions')->flatten()->pluck('slug')->contains($permission);
    }
568631
public function canAll($permission)
    {
        foreach ($this->getArrayFrom($permission) as $permission) {
            if (!$this->hasPermission($permission)) {
                return false;
            }
        }

        return true;
    }
1036449
public function hasOneOfPermissions($permissions)
    {
        if ($this->hasRole('root'))
            return true;

        $has = false;

        foreach ($permissions as $permission) {
            $has = $has || $this->hasPermission($permission);
        }

        return $has;
    }
1360998
public function addPermission($permission)
    {
        if (!$this->hasPermission($permission)) {
            return PermissionRole::create(['role_id' => $this->id, 'permission_id' => $permission->id]);
        }

        return false;
    }
197411
public function hasDirectPermission($permission)
    {
        $name = $permission instanceof Permission ? $permission->name : $permission;
        return (bool) $this->permissions->where('name', $name)->count();
    }
425270
protected function checkAccess($permission): bool
    {
        return $this->app->core->user->permissions[$this->app->getName()]->allowedTo($permission);
    }
883112
public function hasPermission(string $permission): bool {
		$role = new role($this->user->role->name);

		return $role->hasPermission($permission);
	}
580530
private function hasCharacterPermission(array $permission)
    {

        $map = $this->getAffiliationMap();

        // Owning a character grants you '*' permissions to the owned object. In this
        // context, '*' acts as a wildcard for *all* permissions
        foreach ($map['char'] as $char => $permissions) {

            // in case the permissions array is not related to the character for which we're requesting access
            // skip
            if ($char != $this->getCharacterId())
                continue;

            // in case a wildcard access has been assigned (user is owner), grant access
            if (in_array('character.*', $permissions))
                return true;

            // yeah, this is dumb. So if we have an array permission, we need to
            // loop and check each in there.
            foreach ($permission as $sub_permission) {

                // check only character wildcard and specific permission
                if (in_array($sub_permission, $permissions))
                    return true;
            }
        }

        return false;
    }
1004802
public function hasPermission($permission)
    {
        $permission = !is_string($permission) ?: Permission::where(['slug' => $permission])->first();
        
        if (config('laralum.superadmin_bypass_haspermission')) {
            return true;
        }
        
        if ($permission) {
            foreach ($this->roles as $role) {
                if ($role->hasPermission($permission)) {
                    return true;
                }
            }
        }

        return false;
    }
1196775
public function checkPermission($permission)
    {
        return $this->getPermissions()->contains(function ($value) use ($permission) {
            return $permission == $value->id || Str::is($permission, $value->slug);
        });
    }