Version 5.0.6
This commit is contained in:
1 parent
a3a4a9ccbd
commit
b89858b2ff
1214 files changed
+92828
-14859
No files matched your search
@@ -569,7 +569,7 @@ class Forum extends Model implements Permissions
|
||||
}
|
||||
|
||||
$lastPostData = [
|
||||
$updatedItem->last_post . $updatedItem->tid => [
|
||||
$updatedItem->last_post . '.' . $updatedItem->tid => [
|
||||
'last_post' => $updatedItem->last_post,
|
||||
'last_poster_id' => $updatedItem->last_poster_id,
|
||||
'last_poster_name' => $updatedItem->last_poster_name,
|
||||
@@ -634,8 +634,12 @@ class Forum extends Model implements Permissions
|
||||
$lastPost['last_poster_name'] = $topic->last_poster_name;
|
||||
}
|
||||
|
||||
if( $lastPost['last_poster_id'] AND !empty( $lastPost['last_poster_name'] ) )
|
||||
{
|
||||
$lastPost['seo_last_name'] = Friendly::seoTitle( $lastPost['last_poster_name'] );
|
||||
}
|
||||
|
||||
$lastPost['last_post'] = ( $lastComment ? $lastComment->post_date : $topic->last_post );
|
||||
$lastPost['seo_last_name'] = Friendly::seoTitle( $lastPost['last_poster_name'] );
|
||||
$lastPost['last_title'] = $topic->title;
|
||||
$lastPost['seo_last_title'] = Friendly::seoTitle( $topic->title );
|
||||
$lastPost['last_id'] = $topic->tid;
|
||||
@@ -643,7 +647,7 @@ class Forum extends Model implements Permissions
|
||||
$lastPost['last_post_snippet'] = $lastComment?->truncated( true, 350 );
|
||||
$lastPost['posts'] = $topic->posts - 1;
|
||||
|
||||
$lastPostData[ $topic->last_post . $topic->tid ] = $lastPost;
|
||||
$lastPostData[ $topic->last_post . '.' . $topic->tid ] = $lastPost;
|
||||
}
|
||||
}
|
||||
catch ( UnderflowException $e ){}
|
||||
@@ -877,9 +881,10 @@ class Forum extends Model implements Permissions
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Default to a guest account so we can be sure the author is never null */
|
||||
$results[ $timestamp ]['author'] = new Member;
|
||||
if ( $data['_author'] and is_string( $data['_author'] ) )
|
||||
{
|
||||
$results[ $timestamp ]['author'] = new Member;
|
||||
$results[ $timestamp ]['author']->name = $data['_author'];
|
||||
}
|
||||
}
|
||||
@@ -1268,19 +1273,32 @@ class Forum extends Model implements Permissions
|
||||
'forum_permission_showtopic',
|
||||
'forum_permission_custom_error',
|
||||
"form_{$id}_header_permissions",
|
||||
"form_{$id}_tab_forum_display",
|
||||
"ipsTabs_form_{$id}_forum_display",
|
||||
'forum_disable_sharelinks',
|
||||
"form_{$id}_tab_posting_settings",
|
||||
"ipsTabs_form_{$id}_posting_settings",
|
||||
"form_{$id}_header_forum_display_topic",
|
||||
"form_{$id}_tab_permissions",
|
||||
"ipsTabs_form_{$id}_permissions",
|
||||
'forum_preview_posts',
|
||||
'forum_icon_choose',
|
||||
'forum_sort_key',
|
||||
'forum_feature_color'
|
||||
'forum_feature_color',
|
||||
'forum_skin_id',
|
||||
"form_{$id}_header_forum_solved_options",
|
||||
"forum_solved_mode",
|
||||
"forum_enable_assignments",
|
||||
"bw_fluid_view",
|
||||
"form_{$id}_header_forum_display_forum",
|
||||
"ipsTabs_form_{$id}_forum_rules",
|
||||
"ipsTabs_form_{$id}_topic_and_post_settings",
|
||||
),
|
||||
'category' => array(
|
||||
"form_{$id}_tab_forum_display",
|
||||
'forum_feature_color'
|
||||
"ipsTabs_form_{$id}_forum_display",
|
||||
'forum_feature_color',
|
||||
'forum_skin_id',
|
||||
"bw_fluid_view",
|
||||
"form_{$id}_header_forum_display_forum",
|
||||
"ipsTabs_form_{$id}_forum_rules",
|
||||
"ipsTabs_form_{$id}_topic_and_post_settings",
|
||||
),
|
||||
'redirect' => array(
|
||||
'forum_password_on',
|
||||
@@ -1456,7 +1474,7 @@ class Forum extends Model implements Permissions
|
||||
'forum_rules_text'
|
||||
),
|
||||
)
|
||||
) ) );
|
||||
), null, null, null, "forum_show_rules" ) );
|
||||
|
||||
$form->add( new Translatable( 'forum_rules_title', NULL, FALSE, array( 'app' => 'forums', 'key' => ( $this->id ? "forums_forum_{$this->id}_rulestitle" : NULL ) ), NULL, NULL, NULL, 'forum_rules_title' ) );
|
||||
$form->add( new Translatable( 'forum_rules_text', NULL, FALSE, array( 'app' => 'forums', 'key' => ( $this->id ? "forums_forum_{$this->id}_rules" : NULL ), 'editor' => array( 'app' => 'forums', 'key' => 'Forums', 'autoSaveKey' => ( $this->id ? "forums-rules-{$this->id}" : "forums-new-rules" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'rules' ) : NULL ) ), NULL, NULL, NULL, 'forum_rules_text' ) );
|
||||
@@ -2309,7 +2327,7 @@ class Forum extends Model implements Permissions
|
||||
* @param Club $club
|
||||
* @return void
|
||||
*/
|
||||
public function clubForm( Form $form, Club $club ) : void
|
||||
public function _clubForm( Form $form, Club $club ) : void
|
||||
{
|
||||
/* @var Topic $itemClass */
|
||||
$itemClass = static::$contentItemClass;
|
||||
|
||||
@@ -91,6 +91,13 @@ class SavedAction extends Model
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static ?string $titleLangPrefix = 'forums_mmod_';
|
||||
|
||||
/**
|
||||
* Determines if this class can be extended via UI Extension
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static bool $canBeExtended = true;
|
||||
|
||||
/**
|
||||
* Get available saved actions for a forum
|
||||
@@ -171,6 +178,8 @@ class SavedAction extends Model
|
||||
$form->add( new YesNo( 'topic_reply', $this->mm_id ? $this->topic_reply : FALSE, FALSE, array( 'togglesOn' => array( 'topic_reply_content_editor', 'topic_reply_postcount' ) ) ) );
|
||||
$form->add( new Editor( 'topic_reply_content', $this->mm_id ? $this->topic_reply_content : FALSE, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => ( $this->mm_id ? "forums-mmod-{$this->mm_id}" : "forums-new-mmod" ), 'attachIds' => $this->mm_id ? array( $this->mm_id, NULL, 'mmod' ) : NULL ), NULL, NULL, NULL, 'topic_reply_content_editor' ) );
|
||||
$form->add( new YesNo( 'topic_reply_postcount', $this->mm_id ? $this->topic_reply_postcount : TRUE, FALSE, array(), NULL, NULL, NULL, 'topic_reply_postcount' ) );
|
||||
|
||||
parent::form( $form );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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