Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
<?php
/**
* @brief applications API
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 22 Juli 2025
*/
namespace IPS\core\api;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\Api\PaginatedResponse;
use IPS\Api\Response;
use IPS\Application;
use IPS\core\Assignments\Assignment;
use IPS\Db;
use IPS\Node\Api\NodeController;
use IPS\Request;
use OutOfRangeException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief applications API
*/
class applications extends NodeController
{
protected string $class = Application::class;
/**
* GET /core/applications
* Get list of installed applications
*
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apireturn PaginatedResponse<IPS\Application>
* @return PaginatedResponse<Application>
*/
public function GETindex(): Response
{
$where = ['app_enabled=?', 1];
return $this->_list($where);
}
}
+76
View File
@@ -0,0 +1,76 @@
<?php
/**
* @brief Assignments API
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 05 Mai 2025
*/
namespace IPS\core\api;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\Api\Controller;
use IPS\Api\Exception;
use IPS\Api\PaginatedResponse;
use IPS\Api\Response;
use IPS\core\Assignments\Assignment;
use IPS\Db;
use IPS\Request;
use OutOfRangeException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief Assignments API
*/
class assignments extends Controller
{
/**
* GET /core/assignments
* Get list of assignments
*
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apiparam int member_id Member ID to return only assigned items for the member.
* @apiparam int team_id Team ID to return only assigned items for this team.
* @apireturn PaginatedResponse<IPS\core\Assignments\Assignment>
* @return PaginatedResponse<Assignment>
*/
public function GETindex(): Response
{
$page = isset( Request::i()->page ) ? Request::i()->page : 1;
$perPage = isset( Request::i()->perPage ) ? Request::i()->perPage : 25;
$where = [];
if( Request::i()->member_id )
{
$where[] = [ 'assign_type=?', Assignment::ASSIGNMENT_MEMBER ];
$where[] = [ 'assign_to=?', Request::i()->member_id ];
}
if( Request::i()->team_id )
{
$where[] = [ 'assign_type=?', Assignment::ASSIGNMENT_TEAM ];
$where[] = [ 'assign_to=?', Request::i()->team_id ];
}
/* Return */
return new PaginatedResponse(
200,
Db::i()->select( '*', Assignment::$databaseTable, $where ),
$page,
'IPS\core\Assignments\Assignment',
Db::i()->select( 'COUNT(*)', Assignment::$databaseTable, $where )->first(),
$this->member,
$perPage
);
}
}
+65 -4
View File
@@ -17,10 +17,12 @@ use IPS\Api\Controller;
use IPS\Api\Exception;
use IPS\Api\PaginatedResponse;
use IPS\Api\Response;
use IPS\Api\Webhook;
use IPS\Application;
use IPS\Content\Item;
use IPS\core\Achievements\Badge;
use IPS\core\Followed\Follow;
use IPS\core\Messenger\Message;
use IPS\core\Warnings\Reason;
use IPS\core\Warnings\Warning;
use IPS\DateTime;
@@ -75,6 +77,7 @@ class members extends Controller
* @apiparam int|array group Group ID or IDs to search for
* @apiparam int activity_after Find members that have been active since unix timestamp
* @apiparam int activity_before Find members that have been active before unix timestamp
* @apiparam int joined_after Find members that joined after a unix timestamp
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apireturn PaginatedResponse<IPS\Member>
@@ -112,6 +115,11 @@ class members extends Controller
$where[] = array( 'last_activity < ?', Request::i()->activity_before );
}
if( isset( Request::i()->joined_after ) )
{
$where[] = array( 'joined > ?', Request::i()->joined_after );
}
if( isset( Request::i()->group ) )
{
if( is_array( Request::i()->group ) )
@@ -624,7 +632,7 @@ class members extends Controller
{
throw new Exception( 'INVALID_CONTENT', '2C292/J', 404 );
}
/* If we are already following this, update instead of insert */
try
{
@@ -761,10 +769,13 @@ class members extends Controller
{
throw new Exception( 'INVALID_FOLLOW_KEY', '2C292/E', 404 );
}
$thing = Follow::constructFromData( $follow);
/* Unfollow */
Db::i()->delete( 'core_follow', array( 'follow_id=?', $followKey ) );
Webhook::fire( 'content_unfollowed', $thing);
/* If this is a club, unfollow all nodes in the club too */
if( $follow['follow_app'] == 'core' AND $follow['follow_area'] == 'club' )
{
@@ -779,8 +790,17 @@ class members extends Controller
$itemClass = $node['node_class']::$contentItemClass;
$followApp = $itemClass::$application;
$followArea = mb_strtolower( mb_substr( $node['node_class'], mb_strrpos( $node['node_class'], '\\' ) + 1 ) );
Db::i()->delete( 'core_follow', array( 'follow_id=? AND follow_member_id=?', md5( $followApp . ';' . $followArea . ';' . $node['node_id'] . ';' . $member->member_id ), $member->member_id ) );
$where = array( 'follow_id=? AND follow_member_id=?', md5( $followApp . ';' . $followArea . ';' . $node['node_id'] . ';' . $member->member_id ), $member->member_id );
try
{
$currentData = Db::i()->select( '*', 'core_follow', $where )->first();
$current = Follow::constructFromData( $currentData);
$current->delete();
}
catch ( UnderflowException $e )
{
}
}
}
catch ( OutOfRangeException $e ){}
@@ -1386,4 +1406,45 @@ class members extends Controller
return new Response( 201, $member->apiOutput( $this->member ) );
}
/**
* GET /core/members/{id}/messages
* Get personal conversations for a specific member
*
* @param int $id ID Number
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apireturn PaginatedResponse<IPS\core\Messenger\Message>
* @return PaginatedResponse<Message>
* @throws 1G200/1 INVALID_ID The member ID does not exist
* */
public function GETitem_messages( int $id ) : PaginatedResponse
{
try
{
$member = Member::load( $id );
if ( !$member->member_id )
{
throw new OutOfRangeException;
}
$where = array( 'msg_author_id=?', $member->member_id );
/* Return */
return new PaginatedResponse(
200,
Db::i()->select( '*', 'core_message_posts', $where ),
Request::i()->page ?? 1,
'IPS\core\Messenger\Message',
Db::i()->select( 'COUNT(*)', 'core_message_posts', $where )->first(),
$this->member,
Request::i()->perPage ?? null
);
}
catch ( OutOfRangeException $e )
{
throw new Exception( 'INVALID_ID', '1G200/1', 404 );
}
}
}
+126
View File
@@ -15,16 +15,19 @@ namespace IPS\core\api;
use IPS\Api\Controller;
use IPS\Api\Exception;
use IPS\Api\PaginatedResponse;
use IPS\Api\Response;
use IPS\core\Messenger\Conversation;
use IPS\core\Messenger\Message;
use IPS\DateTime;
use IPS\Db;
use IPS\Member;
use IPS\Request;
use IPS\Text\Parser;
use OutOfRangeException;
use function count;
use function defined;
use function in_array;
use function is_array;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
@@ -38,6 +41,129 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class messages extends Controller
{
/**
* GET /core/messages
* Get a list of conversations
*
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apiparam string sortBy What to sort by. Can be 'start_time', 'last_post_time' or leave unspecified for ID
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
* @apireturn PaginatedResponse<IPS\core\Messenger\Conversation>
* @return PaginatedResponse<Conversation>
*/
public function GETindex() : PaginatedResponse
{
$where = [];
if( $this->member instanceof Member )
{
$where = [
[ 'map_user_id=?', $this->member->member_id ],
[ 'map_user_active=?', 1 ]
];
}
/* Sort */
$sortBy = ( isset( Request::i()->sortBy ) and in_array( Request::i()->sortBy, array( 'start_time', 'last_post_time' ) ) ) ? Request::i()->sortBy : 'id';
$sortBy = 'mt_' . $sortBy;
$sortDir = ( isset( Request::i()->sortDir ) and in_array( mb_strtolower( Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? Request::i()->sortDir : 'asc';
if( $this->member instanceof Member )
{
return new PaginatedResponse(
200,
Db::i()->select( '*', 'core_message_topic_user_map', $where, "{$sortBy} {$sortDir}" )
->join( 'core_message_topics', 'map_topic_id=mt_id' ),
Request::i()->page ?? 1,
'IPS\core\Messenger\Conversation',
Db::i()->select( 'COUNT(*)', 'core_message_topic_user_map', $where )->first(),
$this->member,
Request::i()->perPage ?? null
);
}
/* Return */
return new PaginatedResponse(
200,
Db::i()->select( '*', 'core_message_topics', $where, "{$sortBy} {$sortDir}" ),
Request::i()->page ?? 1,
'IPS\core\Messenger\Conversation',
Db::i()->select( 'COUNT(*)', 'core_message_topics', $where )->first(),
$this->member,
Request::i()->perPage ?? null
);
}
/**
* GET /core/messages/{id}
* Get a Conversation
*
* @param int $id Conversation ID
* @throws 1G100/3 INVALID_ID The Conversation ID does not exist
* @apireturn \IPS\core\Messenger\Conversation
* @return Response
*/
public function GETitem( int $id ) : Response
{
try
{
return new Response( 200, Conversation::load( $id )->apiOutput( $this->member ) );
}
catch ( OutOfRangeException $e )
{
throw new Exception( 'INVALID_ID', '1G100/3', 404 );
}
}
/**
* GET /core/messages/{id}/replies
* Get a list of messages for a Conversation
*
* @param int $id Conversation ID Number
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apireturn PaginatedResponse<IPS\core\Messenger\Message>
* @return PaginatedResponse<Message>
*/
public function GETitem_replies( int $id ) : PaginatedResponse
{
$where = array('msg_topic_id=?', $id);
/* Return */
return new PaginatedResponse(
200,
Db::i()->select( '*', 'core_message_posts', $where ),
Request::i()->page ?? 1,
'IPS\core\Messenger\Message',
Db::i()->select( 'COUNT(*)', 'core_message_posts', $where )->first(),
$this->member,
Request::i()->perPage ?? null
);
}
/**
* GET /core/messages/{id}/reply/{replyId}
* Get a Message
*
* @param int $id Conversation ID Number
* @param int $replyId Message ID number
* @throws 1G100/4 INVALID_ID The Message ID does not exist
* @apireturn \IPS\core\Messenger\Message
* @return Response
*/
public function GETitem_reply( int $id, int $replyId ) : Response
{
try
{
return new Response( 200, Message::load( $replyId )->apiOutput( $this->member ) );
}
catch ( OutOfRangeException $e )
{
throw new Exception( 'INVALID_ID', '1G100/4', 404 );
}
}
/**
* POST /core/messages
* Create a new personal conversation
+74
View File
@@ -0,0 +1,74 @@
<?php
/**
* @brief Tags API
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 3 July 2025
*/
namespace IPS\core\api;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\Api\Controller;
use IPS\Api\Exception;
use IPS\Api\PaginatedResponse;
use IPS\Api\Response;
use IPS\Content\Tag;
use IPS\Db;
use IPS\Member\Group;
use IPS\Node\Api\NodeController;
use IPS\Request;
use OutOfRangeException;
use function defined;
if( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER[ 'SERVER_PROTOCOL' ]??'HTTP/1.0' ).' 403 Forbidden' );
exit;
}
/**
* @brief Tags API
*/
class tags extends NodeController
{
protected string $class = Tag::class;
/**
* GET /core/tags
* Get list of tags
*
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apireturn PaginatedResponse<IPS\Content\Tag>
* @return PaginatedResponse
*/
public function GETindex(): PaginatedResponse
{
return $this->_list();
}
/**
* GET /core/tags/{id}
* Get information about a specific tag
*
* @param int $id ID Number
* @return Response
* @throws 1C358/1 INVALID_ID The group ID does not exist
* @apireturn \IPS\Content\Tag
*/
public function GETitem( int $id ): Response
{
try
{
return $this->_view( $id );
}
catch ( OutOfRangeException $e )
{
throw new Exception( 'INVALID_ID', '1TAG', 404 );
}
}
}