Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -10,25 +10,35 @@
*/
namespace IPS\forums\api\GraphQL\Mutations;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\SafeException;
use IPS\Api\GraphQL\TypeRegistry;
use IPS\Db;
use IPS\forums\api\GraphQL\Types\TopicType;
use IPS\forums\Topic;
use IPS\forums\Topic\Post;
use IPS\Member;
use IPS\Node\Api\GraphQL\NodeMutator;
use IPS\Request;
use OutOfRangeException;
use function defined;
use function intval;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Mark topic solved mutation for GraphQL API
*/
class _MarkTopicSolved extends \IPS\Node\Api\GraphQL\NodeMutator
class MarkTopicSolved extends NodeMutator
{
/*
* @brief Query description
*/
public static $description = "Mark a topic solved";
public static string $description = "Mark a topic solved";
/*
* Mutation arguments
@@ -47,8 +57,10 @@ class _MarkTopicSolved extends \IPS\Node\Api\GraphQL\NodeMutator
/**
* Return the mutation return type
*
* @return TopicType
*/
public function type()
public function type() : TopicType
{
return \IPS\forums\api\GraphQL\TypeRegistry::topic();
}
@@ -56,34 +68,34 @@ class _MarkTopicSolved extends \IPS\Node\Api\GraphQL\NodeMutator
/**
* Resolves this mutation
*
* @param mixed Value passed into this resolver
* @param array Arguments
* @return \IPS\forums\Topic
* @param mixed $val Value passed into this resolver
* @param array $args Arguments
* @return Topic
*/
public function resolve($val, $args)
public function resolve( mixed $val, array $args ) : Topic
{
try
{
$topic = \IPS\forums\Topic::loadAndCheckPerms( \intval( $args['id'] ) );
$topic = Topic::loadAndCheckPerms( intval( $args['id'] ) );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_TOPIC', 'GQL', 403 );
throw new SafeException( 'NO_TOPIC', 'GQL', 403 );
}
try
{
$post = \IPS\forums\Topic\Post::loadAndCheckPerms( \intval( $args['answer'] ) );
$post = Post::loadAndCheckPerms( intval( $args['answer'] ) );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_POST', 'GQL', 403 );
throw new SafeException( 'NO_POST', 'GQL', 403 );
}
/* This is "solved" mode */
if ( !$topic->canSolve() )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_PERMISSION', 'GQL', 403 );
throw new SafeException( 'NO_PERMISSION', 'GQL', 403 );
}
@@ -96,12 +108,12 @@ class _MarkTopicSolved extends \IPS\Node\Api\GraphQL\NodeMutator
$topic->toggleSolveComment( $post->pid, FALSE );
}
\IPS\Db::i()->insert( 'core_moderator_logs', array(
'member_id' => \IPS\Member::loggedIn()->member_id,
'member_name' => \IPS\Member::loggedIn()->name,
Db::i()->insert( 'core_moderator_logs', array(
'member_id' => Member::loggedIn()->member_id,
'member_name' => Member::loggedIn()->name,
'ctime' => time(),
'note' => json_encode( array( $post->pid => $args['solved'] ) ),
'ip_address' => \IPS\Request::i()->ipAddress(),
'ip_address' => Request::i()->ipAddress(),
'appcomponent' => 'forums',
'module' => 'forums',
'controller' => 'topic',