src/Milky/Account/Permissions/PermissionManager.php
protected function checkRaw( $namespace, PermissibleEntity $entity = null )
	{
		if ( $namespace == null || strlen( $namespace ) == 0 || $namespace == "everybody" || $namespace == "-1" )
			$namespace = Permission::EVERYBODY;
		if ( $namespace == "op" || $namespace == "0" )
			$namespace = Permission::OP;
		if ( $namespace == "admin" )
			$namespace = Permission::ADMIN;
		if ( $namespace == "banned" )
			$namespace = Permission::BANNED;
		if ( $namespace == "whitelisted" )
			$namespace = Permission::WHITELISTED;

		$namespace = static::getAlias( $namespace );

		if ( !preg_match( "/[a-z0-9_.]*/", $namespace ) )
			throw new PermissionException( "The permission namespace [$namespace] can only contain the characters 'a-z0-9_.'." );

		$permission_defaults = PermissionDefaults::find( $namespace );

		if ( $entity === null )
		{
			if ( !Acct::check() )
			{
				$result = $this->checkWalker( $namespace, [] );
				if ( $result == PermissionValues::UNSET )
					$result = $permission_defaults->value_default;

				return $result;
			}
			$entity = Acct::acct();
		}

		$group_state = PermissionValues::UNSET;

		/*
		 * Check group permissible state
		 */
		foreach ( $entity->groups() as $group )
		{
			$group_state = $this->checkRaw( $namespace, $group );
			if ( $group_state == PermissionValues::ALWAYS || $group_state == PermissionValues::NEVER )
				break;
		}

		/*
		 * Check user permissible state
		 */
		$user_state = $this->checkWalker( $namespace, $entity->permissions() );

		if ( $group_state == PermissionValues::ALWAYS || $group_state == PermissionValues::NEVER )
		{
			if ( $user_state == PermissionValues::ALWAYS )
				return true;
			else if ( $user_state == PermissionValues::NEVER )
				return false;
			else
				return $group_state;
		}
		else if ( $group_state == PermissionValues::UNSET && $user_state == PermissionValues::UNSET )
			return $permission_defaults->value_default;
		else if ( $user_state == PermissionValues::UNSET )
			return $group_state;
		else // if ( $group_state == PermissionValues::UNSET )
			return $user_state;
	}
protected function checkRaw( $namespace, PermissibleEntity $entity = null )
	{
		if ( $namespace == null || strlen( $namespace ) == 0 || $namespace == "everybody" || $namespace == "-1" )
			$namespace = Permission::EVERYBODY;
		if ( $namespace == "op" || $namespace == "0" )
			$namespace = Permission::OP;
		if ( $namespace == "admin" )
			$namespace = Permission::ADMIN;
		if ( $namespace == "banned" )
			$namespace = Permission::BANNED;
		if ( $namespace == "whitelisted" )
			$namespace = Permission::WHITELISTED;

		$namespace = static::getAlias( $namespace );

		if ( !preg_match( "/[a-z0-9_.]*/", $namespace ) )
			throw new PermissionException( "The permission namespace [$namespace] can only contain the characters 'a-z0-9_.'." );

		$permission_defaults = PermissionDefaults::find( $namespace );

		if ( $entity === null )
		{
			if ( !Acct::check() )
			{
				$result = $this->checkWalker( $namespace, [] );
				if ( $result == PermissionValues::UNSET )
					$result = $permission_defaults->value_default;

				return $result;
			}
			$entity = Acct::acct();
		}

		$group_state = PermissionValues::UNSET;

		/*
		 * Check group permissible state
		 */
		foreach ( $entity->groups() as $group )
		{
			$group_state = $this->checkRaw( $namespace, $group );
			if ( $group_state == PermissionValues::ALWAYS || $group_state == PermissionValues::NEVER )
				break;
		}

		/*
		 * Check user permissible state
		 */
		$user_state = $this->checkWalker( $namespace, $entity->permissions() );

		if ( $group_state == PermissionValues::ALWAYS || $group_state == PermissionValues::NEVER )
		{
			if ( $user_state == PermissionValues::ALWAYS )
				return true;
			else if ( $user_state == PermissionValues::NEVER )
				return false;
			else
				return $group_state;
		}
		else if ( $group_state == PermissionValues::UNSET && $user_state == PermissionValues::UNSET )
			return $permission_defaults->value_default;
		else if ( $user_state == PermissionValues::UNSET )
			return $group_state;
		else // if ( $group_state == PermissionValues::UNSET )
			return $user_state;
	}
protected function checkRaw ( $ namespace , PermissibleEntity $ entity = null ) { if ( $ namespace == null || strlen ( $ namespace ) == 0 || $ namespace == "everybody" || $ namespace == "-1" ) $ namespace = Permission :: EVERYBODY ; if ( $ namespace == "op" || $ namespace == "0" ) $ namespace = Permission :: OP ; if ( $ namespace == "admin" ) $ namespace = Permission :: ADMIN ; if ( $ namespace == "banned" ) $ namespace = Permission :: BANNED ; if ( $ namespace == "whitelisted" ) $ namespace = Permission :: WHITELISTED ; $ namespace = static :: getAlias ( $ namespace ) ; if ( ! preg_match ( "/[a-z0-9_.]*/" , $ namespace ) ) throw new PermissionException ( "The permission namespace [$namespace] can only contain the characters 'a-z0-9_.'." ) ; $ permission_defaults = PermissionDefaults :: find ( $ namespace ) ; if ( $ entity === null ) { if ( ! Acct :: check ( ) ) { $ result = $ this -> checkWalker ( $ namespace , [ ] ) ; if ( $ result == PermissionValues :: UNSET ) $ result = $ permission_defaults -> value_default ; return $ result ; } $ entity = Acct :: acct ( ) ; } $ group_state = PermissionValues :: UNSET ; /*
		 * Check group permissible state
		 */ foreach ( $ entity -> groups ( ) as $ group ) { $ group_state = $ this -> checkRaw ( $ namespace , $ group ) ; if ( $ group_state == PermissionValues :: ALWAYS || $ group_state == PermissionValues :: NEVER ) break ; } /*
		 * Check user permissible state
		 */ $ user_state = $ this -> checkWalker ( $ namespace , $ entity -> permissions ( ) ) ; if ( $ group_state == PermissionValues :: ALWAYS || $ group_state == PermissionValues :: NEVER ) { if ( $ user_state == PermissionValues :: ALWAYS ) return true ; else if ( $ user_state == PermissionValues :: NEVER ) return false ; else return $ group_state ; } else if ( $ group_state == PermissionValues :: UNSET && $ user_state == PermissionValues :: UNSET ) return $ permission_defaults -> value_default ; else if ( $ user_state == PermissionValues :: UNSET ) return $ group_state ; else // if ( $group_state == PermissionValues::UNSET ) return $ user_state ; }
Checks a raw singular namespace and returns the unhindered result

@param $namespace
@param PermissibleEntity|null $entity

@return string
Checks a raw singular namespace and returns the unhindered result