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

@@ -12,60 +12,75 @@
namespace IPS\forums\Topic;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Application;
use IPS\Content\Item;
use IPS\Db;
use IPS\Db\Exception;
use IPS\Member;
use IPS\Settings;
use function defined;
use function IPS\Cicloud\getForumArchiveDb;
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;
}
/**
* Post Model
*/
class _ArchivedPost extends Post
class ArchivedPost extends Post
{
/**
* @brief [ActiveRecord] Multiton Store
*/
protected static $multitons;
protected static array $multitons;
/**
* @brief Title
*/
public static $archiveTitle = 'archivedpost';
public static string $archiveTitle = 'archivedpost';
/**
* @brief [ActiveRecord] Database Connection
* @return \IPS\Db
* @return Db
*/
public static function db()
public static function db(): Db
{
if ( Application::appIsEnabled('cloud') )
{
return getForumArchiveDb();
}
/* Connect to the remote DB if needed */
return ( !\IPS\Settings::i()->archive_remote_sql_host ) ? \IPS\Db::i() : \IPS\Db::i( 'archive', array(
'sql_host' => \IPS\Settings::i()->archive_remote_sql_host,
'sql_user' => \IPS\Settings::i()->archive_remote_sql_user,
'sql_pass' => \IPS\Settings::i()->archive_remote_sql_pass,
'sql_database' => \IPS\Settings::i()->archive_remote_sql_database,
'sql_port' => \IPS\Settings::i()->archive_sql_port,
'sql_socket' => \IPS\Settings::i()->archive_sql_socket,
'sql_tbl_prefix'=> \IPS\Settings::i()->archive_sql_tbl_prefix,
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
return ( !Settings::i()->archive_remote_sql_host ) ? Db::i() : Db::i( 'archive', array(
'sql_host' => Settings::i()->archive_remote_sql_host,
'sql_user' => Settings::i()->archive_remote_sql_user,
'sql_pass' => Settings::i()->archive_remote_sql_pass,
'sql_database' => Settings::i()->archive_remote_sql_database,
'sql_port' => Settings::i()->archive_sql_port,
'sql_socket' => Settings::i()->archive_sql_socket,
'sql_tbl_prefix'=> Settings::i()->archive_sql_tbl_prefix,
'sql_utf8mb4' => isset( Settings::i()->sql_utf8mb4 ) ? Settings::i()->sql_utf8mb4 : FALSE
) );
}
/**
* @brief [ActiveRecord] Database Table
*/
public static $databaseTable = 'forums_archive_posts';
public static ?string $databaseTable = 'forums_archive_posts';
/**
* @brief Database Prefix
*/
public static $databasePrefix = 'archive_';
public static string $databasePrefix = 'archive_';
/**
* @brief Database Column Map
*/
public static $databaseColumnMap = array(
public static array $databaseColumnMap = array(
'item' => 'topic_id',
'author' => 'author_id',
'author_name' => 'author_name',
@@ -83,7 +98,7 @@ class _ArchivedPost extends Post
/**
* @brief Bitwise values for post_bwoptions field
*/
public static $bitOptions = array(
public static array $bitOptions = array(
'post_bwoptions' => array(
'post_bwoptions' => array(
'best_answer' => 1
@@ -94,17 +109,17 @@ class _ArchivedPost extends Post
/**
* @brief Database Column ID
*/
public static $databaseColumnId = 'id';
public static string $databaseColumnId = 'id';
/**
* Post count for member
*
* @param \IPS\Member $member The member
* @param Member $member The member
* @param bool $includeNonPostCountIncreasing If FALSE, will skip any posts which would not cause the user's post count to increase
* @param bool $includeHiddenAndPendingApproval If FALSE, will skip any hidden posts, or posts pending approval
* @return int
*/
public static function memberPostCount( \IPS\Member $member, bool $includeNonPostCountIncreasing = FALSE, bool $includeHiddenAndPendingApproval = TRUE )
public static function memberPostCount( Member $member, bool $includeNonPostCountIncreasing = FALSE, bool $includeHiddenAndPendingApproval = TRUE ): int
{
$where = [];
$where[] = [ 'archive_author_id=?', $member->member_id ];
@@ -113,7 +128,7 @@ class _ArchivedPost extends Post
{
if ( !$includeNonPostCountIncreasing )
{
$where[] = [ static::db()->in( 'archive_forum_id', iterator_to_array( \IPS\Db::i()->select( 'id', 'forums_forums', 'inc_postcount=1' ) ) ) ];
$where[] = [ static::db()->in( 'archive_forum_id', iterator_to_array( Db::i()->select( 'id', 'forums_forums', 'inc_postcount=1' ) ) ) ];
}
if ( !$includeHiddenAndPendingApproval )
{
@@ -122,7 +137,7 @@ class _ArchivedPost extends Post
return static::db()->select( 'COUNT(*)', static::$databaseTable, $where )->first();
}
catch ( \IPS\Db\Exception $e )
catch ( Exception $e )
{
return 0;
}
@@ -132,10 +147,10 @@ class _ArchivedPost extends Post
/**
* Joins (when loading comments)
*
* @param \IPS\Content\Item $item The item
* @param Item $item The item
* @return array
*/
public static function joins( \IPS\Content\Item $item )
public static function joins( Item $item ): array
{
$return = parent::joins( $item );
@@ -148,10 +163,10 @@ class _ArchivedPost extends Post
/**
* Can edit?
*
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
* @return bool
*/
public function canEdit( $member=NULL )
public function canEdit( Member|null $member=null ): bool
{
return FALSE;
}
@@ -159,10 +174,10 @@ class _ArchivedPost extends Post
/**
* Can hide?
*
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
* @return bool
*/
public function canHide( $member=NULL )
public function canHide( Member|null $member=NULL ): bool
{
return FALSE;
}
@@ -170,9 +185,9 @@ class _ArchivedPost extends Post
/**
* Can unhide?
*
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
*/
public function canUnhide( $member=NULL )
public function canUnhide( Member $member=NULL ): bool
{
return FALSE;
}
@@ -180,10 +195,10 @@ class _ArchivedPost extends Post
/**
* Can delete?
*
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
* @return bool
*/
public function canDelete( $member=NULL )
public function canDelete( Member $member=null ): bool
{
return FALSE;
}
@@ -191,10 +206,10 @@ class _ArchivedPost extends Post
/**
* Can split?
*
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @param Member|null $member The member to check for (NULL for currently logged in member)
* @return bool
*/
public function canSplit( $member=NULL )
public function canSplit( Member|null $member=null ): bool
{
return FALSE;
}
@@ -203,10 +218,10 @@ class _ArchivedPost extends Post
* Can react?
*
* @note This method is also ran to check if a member can "unrep"
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
* @return bool
*/
public function canReact( \IPS\Member $member = NULL )
public function canReact( Member $member = NULL ): bool
{
return FALSE;
}