Version 5.0.6
This commit is contained in:
1 parent
a3a4a9ccbd
commit
b89858b2ff
1214 files changed
+92828
-14859
No files matched your search
@@ -59,6 +59,7 @@ use IPS\Helpers\Form\Date;
|
||||
use IPS\Helpers\Form\Password;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Http\Url\Friendly;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
@@ -75,13 +76,17 @@ use SplObserver;
|
||||
use SplSubject;
|
||||
use function array_reverse;
|
||||
use function array_slice;
|
||||
use function class_implements;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function explode;
|
||||
use function func_get_args;
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
use function is_array;
|
||||
use function is_null;
|
||||
use function is_string;
|
||||
use function json_decode;
|
||||
use const IPS\LARGE_TOPIC_REPLIES;
|
||||
|
||||
@@ -356,7 +361,7 @@ class Topic extends Item implements Embeddable,
|
||||
* @param array $where Where clause
|
||||
* @param string|null $order MySQL ORDER BY clause (NULL to order by date)
|
||||
* @param int|array|null $limit Limit clause
|
||||
* @param string $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index or NULL to ignore permissions
|
||||
* @param string|null $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index or NULL to ignore permissions
|
||||
* @param int|bool|null $includeHiddenItems Include hidden items? NULL to detect if currently logged in member has permission, -1 to return public content only, TRUE to return unapproved content and FALSE to only return unapproved content the viewing member submitted
|
||||
* @param int $queryFlags Select bitwise flags
|
||||
* @param Member|null $member The member (NULL to use currently logged in member)
|
||||
@@ -373,7 +378,7 @@ class Topic extends Item implements Embeddable,
|
||||
* @param array|null $location Array of item lat and long
|
||||
* @return ActiveRecordIterator|int
|
||||
*/
|
||||
public static function getItemsWithPermission( array $where=array(), string $order=null, int|array|null $limit=10, string $permissionKey='read', int|bool|null $includeHiddenItems= Filter::FILTER_AUTOMATIC, int $queryFlags=0, Member $member=null, bool $joinContainer=FALSE, bool $joinComments=FALSE, bool $joinReviews=FALSE, bool $countOnly=FALSE, array|null $joins=null, bool|Model $skipPermission=FALSE, bool $joinTags=TRUE, bool $joinAuthor=TRUE, bool $joinLastCommenter=TRUE, bool $showMovedLinks=FALSE, array|null $location=null ): ActiveRecordIterator|int
|
||||
public static function getItemsWithPermission( array $where=array(), string $order=null, int|array|null $limit=10, ?string $permissionKey='read', int|bool|null $includeHiddenItems= Filter::FILTER_AUTOMATIC, int $queryFlags=0, Member $member=null, bool $joinContainer=FALSE, bool $joinComments=FALSE, bool $joinReviews=FALSE, bool $countOnly=FALSE, array|null $joins=null, bool|Model $skipPermission=FALSE, bool $joinTags=TRUE, bool $joinAuthor=TRUE, bool $joinLastCommenter=TRUE, bool $showMovedLinks=FALSE, array|null $location=null ): ActiveRecordIterator|int
|
||||
{
|
||||
$where = static::getItemsWithPermissionWhere( $where, $permissionKey, $member, $joinContainer, $skipPermission );
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins, $skipPermission, $joinTags, $joinAuthor, $joinLastCommenter, $showMovedLinks );
|
||||
@@ -1028,7 +1033,7 @@ class Topic extends Item implements Embeddable,
|
||||
{
|
||||
parent::delete();
|
||||
|
||||
if( in_array( $this->archive_status, array( static::ARCHIVE_DONE, static::ARCHIVE_WORKING, static::ARCHIVE_RESTORE ) ) )
|
||||
if( in_array( $this->topic_archive_status, array( static::ARCHIVE_DONE, static::ARCHIVE_WORKING, static::ARCHIVE_RESTORE ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1177,12 +1182,13 @@ class Topic extends Item implements Embeddable,
|
||||
/* @var Records $class */
|
||||
$class = '\IPS\cms\Records' . $database['database_id'];
|
||||
|
||||
$class::load( $this->tid, 'record_topicid' );
|
||||
|
||||
$database = Databases::constructFromData( $database );
|
||||
Member::loggedIn()->language()->words['cms_delete_linked_topic'] = sprintf( Member::loggedIn()->language()->get('cms_delete_linked_topic'), $database->recordWord( 1 ) );
|
||||
|
||||
Output::i()->error( 'cms_delete_linked_topic', '1T281/1', 403, '' );
|
||||
if( class_exists( $class ) )
|
||||
{
|
||||
$class::load( $this->tid, 'record_topicid' );
|
||||
$database = Databases::constructFromData( $database );
|
||||
Member::loggedIn()->language()->words[ 'cms_delete_linked_topic' ] = sprintf( Member::loggedIn()->language()->get( 'cms_delete_linked_topic' ), $database->recordWord( 1 ) );
|
||||
Output::i()->error( 'cms_delete_linked_topic', '1T281/1', 403, '' );
|
||||
}
|
||||
}
|
||||
catch( OutOfRangeException | Exception $ex ) { }
|
||||
}
|
||||
@@ -1763,6 +1769,48 @@ class Topic extends Item implements Embeddable,
|
||||
|
||||
if ( ! $alreadyDone )
|
||||
{
|
||||
/* Optimise getting just the first or last post */
|
||||
if ( $this->mapped('num_comments') > LARGE_TOPIC_REPLIES and ! $cutoff and ! $this->isArchived() and $limit === 1 and $order === 'date' )
|
||||
{
|
||||
$minMax = ( $orderDirection === 'asc' ) ? 'MIN' : 'MAX';
|
||||
$pidWhere = [
|
||||
[ 'topic_id=?', $this->tid ],
|
||||
];
|
||||
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Hideable' ) )
|
||||
{
|
||||
if ( $includeHiddenComments === NULL )
|
||||
{
|
||||
$includeHiddenComments = $this->canViewHiddenComments();
|
||||
}
|
||||
|
||||
if ( ! $includeHiddenComments )
|
||||
{
|
||||
/* @var \IPS\Content\Comment $class */
|
||||
$pidWhere[] = [ $class::db()->in( 'queued', [0,2] ) ];
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$row = $class::db()->select( "{$minMax}( CONCAT( post_date, '.', pid) ) as pid", 'forums_posts', $pidWhere )->first();
|
||||
$pid = (int) explode( '.', $row )[1];
|
||||
|
||||
if( \is_array( $extraWhereClause ) or is_null( $extraWhereClause ) )
|
||||
{
|
||||
$extraWhereClause[] = [ 'pid=?', $pid ];
|
||||
}
|
||||
else if ( is_string( $extraWhereClause ) )
|
||||
{
|
||||
$extraWhereClause = [
|
||||
[ $extraWhereClause ],
|
||||
[ 'pid=?', $pid ]
|
||||
];
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException ) { }
|
||||
}
|
||||
|
||||
$comments[ $_hash ] = $this->_comments( $class, $originalLimit ?: static::getCommentsPerPage(), $originalOffset, ( isset( $class::$databaseColumnMap[$order] ) ? ( $class::$databasePrefix . $class::$databaseColumnMap[$order] ) : $order ) . ' ' . $orderDirection, $member, $includeHiddenComments, $cutoff, $includeWarnings, $extraWhereClause, $includeDeleted );
|
||||
}
|
||||
}
|
||||
@@ -1973,7 +2021,7 @@ class Topic extends Item implements Embeddable,
|
||||
}
|
||||
|
||||
/* ! Reactions */
|
||||
|
||||
|
||||
/**
|
||||
* Reaction type
|
||||
*
|
||||
@@ -1982,17 +2030,7 @@ class Topic extends Item implements Embeddable,
|
||||
public static function reactionType(): string
|
||||
{
|
||||
/* Because of firstCommentRequired, the reaction on the item will always be the reaction for a comment */
|
||||
return Post::reactionType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionClass(): string
|
||||
{
|
||||
return Post::class;
|
||||
return 'tid';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user