Scalr\Model\Entity\Script::hasAccessPermissions PHP Method

hasAccessPermissions() public method

See also: Scalr\DataType\AccessPermissionsInterface::hasAccessPermissions()
public hasAccessPermissions ( $user, $environment = null, $modify = null )
    public function hasAccessPermissions($user, $environment = null, $modify = null)
    {
        switch ($this->getScope()) {
            case static::SCOPE_ACCOUNT:
                return $this->accountId == $user->accountId && (empty($environment) || !$modify);
            case static::SCOPE_ENVIRONMENT:
                return $environment ? $this->envId == $environment->id : $user->hasAccessToEnvironment($this->envId);
            case static::SCOPE_SCALR:
                return !$modify;
            default:
                return false;
        }
    }