Version 5.0.0 beta 6
This commit is contained in:
1 parent
57d9db6ce2
commit
fa2a720105
115 files changed
+1823
-1147
No files matched your search
@@ -671,10 +671,11 @@ class Forum extends Model implements Permissions
|
||||
/**
|
||||
* Get last post data
|
||||
*
|
||||
* @param int $count Max number of items, most available is 5
|
||||
* @param int $count Max number of items, most available is 5
|
||||
* @param bool $isChild
|
||||
* @return array|null
|
||||
*/
|
||||
public function lastPost( int $count=1 ): ?array
|
||||
public function lastPost( int $count=1, $isChild=false ): ?array
|
||||
{
|
||||
if ( $count > 5 )
|
||||
{
|
||||
@@ -743,7 +744,7 @@ class Forum extends Model implements Permissions
|
||||
foreach( $this->children() as $child )
|
||||
{
|
||||
/* We need to merge all children and pick the top 5 */
|
||||
if ( $childLastPost = $child->lastPost( $count ) )
|
||||
if ( $childLastPost = $child->lastPost( $count, true ) )
|
||||
{
|
||||
$results = $results + $childLastPost;
|
||||
}
|
||||
@@ -785,25 +786,14 @@ class Forum extends Model implements Permissions
|
||||
{
|
||||
foreach( $lastPostData as $lastPostTime => $lastPost )
|
||||
{
|
||||
if ( $lastPost['last_poster_id'] )
|
||||
{
|
||||
$lastAuthor = Member::load( $lastPost['last_poster_id'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastAuthor = new Member;
|
||||
if ( $lastPost['last_poster_name'] )
|
||||
{
|
||||
$lastAuthor->name = $lastPost['last_poster_name'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->sub_can_post and !$this->permission_showtopic and ! $this->can('read') )
|
||||
{
|
||||
$lastPost['last_title'] = null;
|
||||
}
|
||||
|
||||
$results[ $lastPostTime ] = array(
|
||||
'author' => $lastAuthor,
|
||||
'author' => null,
|
||||
'_author' => ! empty( $lastPost['last_poster_id'] ) ? $lastPost['last_poster_id'] : ( $lastPost['last_poster_name'] ?? '' ),
|
||||
'topic_url' => Url::internal( "app=forums&module=forums&controller=topic&id={$lastPost['last_id']}", 'front', 'forums_topic', array( $lastPost['seo_last_title'] ) ),
|
||||
'topic_title' => $lastPost['last_title'],
|
||||
'date' => $lastPostTime,
|
||||
@@ -818,7 +808,7 @@ class Forum extends Model implements Permissions
|
||||
{
|
||||
/* @var Forum $child */
|
||||
/* We need to merge all children and pick the top 5 */
|
||||
if ( $childLastPost = $child->lastPost( $count ) )
|
||||
if ( $childLastPost = $child->lastPost( $count, true ) )
|
||||
{
|
||||
if( is_array( $childLastPost ) )
|
||||
{
|
||||
@@ -836,6 +826,42 @@ class Forum extends Model implements Permissions
|
||||
|
||||
if ( count( $results ) )
|
||||
{
|
||||
/* Don't process the author details if we're not going to use them */
|
||||
if ( ! $isChild )
|
||||
{
|
||||
$membersToLoad = [];
|
||||
|
||||
/* Let's get the author details */
|
||||
foreach ( $results as $timestamp => $data )
|
||||
{
|
||||
if ( $data['_author'] and is_int( $data['_author'] ) )
|
||||
{
|
||||
$membersToLoad[ $timestamp ] = $data['_author'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $data['_author'] and is_string( $data['_author'] ) )
|
||||
{
|
||||
$results[ $timestamp ]['author'] = new Member;
|
||||
$results[ $timestamp ]['author']->name = $data['_author'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $membersToLoad ) )
|
||||
{
|
||||
$membersLoaded = iterator_to_array( Db::i()->select( '*', 'core_members', [ Db::i()->in( 'member_id', $membersToLoad ) ] )->setKeyField( 'member_id' ) );
|
||||
|
||||
foreach ( $membersToLoad as $timestamp => $memberId )
|
||||
{
|
||||
if ( isset( $membersLoaded[$memberId] ) )
|
||||
{
|
||||
$results[$timestamp]['author'] = Member::constructFromData( $membersLoaded[$memberId] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
krsort( $results );
|
||||
if ( $count === 1 )
|
||||
{
|
||||
|
||||
@@ -369,6 +369,22 @@ class Post extends Comment implements Embeddable,
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom where conditions used specifically for finding comments
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function findCommentWhere() : array|null
|
||||
{
|
||||
/* If we feature the first post, then pagination is all wrong */
|
||||
if( Member::loggedIn()->getLayoutValue( 'forum_topic_view_firstpost' ) )
|
||||
{
|
||||
return [ 'new_topic=?', 0 ];
|
||||
}
|
||||
|
||||
return parent::findCommentWhere();
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Save
|
||||
@@ -398,10 +414,7 @@ class Post extends Comment implements Embeddable,
|
||||
static::recordSync( $item );
|
||||
}
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$item = NULL;
|
||||
}
|
||||
catch( OutOfRangeException $e ){}
|
||||
|
||||
parent::delete();
|
||||
|
||||
|
||||
@@ -979,6 +979,18 @@ class Topic extends Item implements Embeddable,
|
||||
$topic->state = 'closed';
|
||||
}
|
||||
}
|
||||
|
||||
if ( Bridge::i()->featureIsEnabled( 'realtime' ) )
|
||||
{
|
||||
$hash = [
|
||||
'app' => 'forums',
|
||||
'module' => 'forums',
|
||||
'controller' => 'topic',
|
||||
'id' => $topic->tid
|
||||
];
|
||||
Bridge::i()->addAdditionalLocation( $hash );
|
||||
$topic->locationHash = Bridge::i()->getLocationHash( $hash );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !empty( $openIds ) )
|
||||
|
||||
Reference in new issue
Block a user