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
@@ -227,6 +227,11 @@ trait Followable
|
||||
*/
|
||||
public function notificationRecipients( int|array|null $limit=array( 0, 25 ), bool $countOnly=FALSE ): Select|int
|
||||
{
|
||||
if( $this instanceof Comment )
|
||||
{
|
||||
return $this->item()->notificationRecipientsForComments( $limit, $countOnly, $this );
|
||||
}
|
||||
|
||||
/* Do we only want the count? */
|
||||
if( $countOnly )
|
||||
{
|
||||
@@ -259,15 +264,68 @@ trait Followable
|
||||
return static::containerFollowers( $this->container(), Content::FOLLOW_PUBLIC + Content::FOLLOW_ANONYMOUS, array( 'immediate' ), $this->mapped('date'), $limit, 'follow_added' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Users to receive immediate notifications
|
||||
*
|
||||
* @param int|array|null $limit LIMIT clause
|
||||
* @param boolean $countOnly Just return the count
|
||||
* @param Comment|null $comment The comment that is triggering this notification
|
||||
* @return Select|int
|
||||
*/
|
||||
public function notificationRecipientsForComments( int|array|null $limit=array( 0, 25 ), bool $countOnly=FALSE, ?Comment $comment=null ): Select|int
|
||||
{
|
||||
if( !( $comment instanceof Comment ) or !IPS::classUsesTrait( $this, Followable::class ) or ( !$comment->item() instanceof static ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Do we only want the count? */
|
||||
if( $countOnly )
|
||||
{
|
||||
$count = 0;
|
||||
$count += $comment->author()->followersCount( 3, array( 'immediate' ), $comment->mapped('date') );
|
||||
if( IPS::classUsesTrait( $this, 'IPS\Content\Followable' ) )
|
||||
{
|
||||
$count += $this->followersCount( 3, array( 'immediate' ), $comment->mapped('date') );
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
$memberFollowers = $comment->author()->followers( 3, array( 'immediate' ), $comment->mapped('date'), NULL );
|
||||
|
||||
if( $memberFollowers !== 0 )
|
||||
{
|
||||
$unions = array(
|
||||
$this->followers( 3, array( 'immediate' ), $comment->mapped('date'), NULL ),
|
||||
$memberFollowers
|
||||
);
|
||||
|
||||
return Db::i()->union( $unions, 'follow_added', $limit );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->followers( static::FOLLOW_PUBLIC + static::FOLLOW_ANONYMOUS, array( 'immediate' ), $comment->mapped('date'), $limit, 'follow_added' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create Notification
|
||||
*
|
||||
* @param mixed $extra Additional data
|
||||
* @param Comment|null $comment
|
||||
* @return Notification
|
||||
*/
|
||||
public function createNotification( mixed $extra=NULL ): Notification
|
||||
public function createNotification( mixed $extra=NULL, ?Comment $comment=null ): Notification
|
||||
{
|
||||
if( $comment instanceof Comment )
|
||||
{
|
||||
$key = ( $comment instanceof Review ) ? 'new_review' : 'new_comment';
|
||||
return new Notification( Application::load( 'core' ), $key, $this, array( $comment ) );
|
||||
}
|
||||
|
||||
// New content is sent with itself as the item as we deliberately do not group notifications about new content items. Unlike comments where you're going to read them all - you might scan the notifications list for topic titles you're interested in
|
||||
return new Notification( Application::load( 'core' ), 'new_content', $this, array( $this ), $extra );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user