Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
+85
-39
@@ -11,6 +11,9 @@
|
||||
namespace IPS\Content;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\Http\Url;
|
||||
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
@@ -234,23 +237,6 @@ abstract class _Comment extends \IPS\Content
|
||||
$member->save();
|
||||
}
|
||||
|
||||
/* Send notifications and dish out points */
|
||||
if ( !\in_array( 'IPS\Content\Review', class_parents( \get_called_class() ) ) )
|
||||
{
|
||||
if ( !$obj->hidden() and ( !$first or !$item::$firstCommentRequired ) )
|
||||
{
|
||||
$obj->sendNotifications();
|
||||
if( !$item instanceof \IPS\core\Messenger\Conversation )
|
||||
{
|
||||
$member->achievementAction( 'core', 'Comment', $obj );
|
||||
}
|
||||
}
|
||||
else if( $obj->hidden() === 1 )
|
||||
{
|
||||
$obj->sendUnapprovedNotification();
|
||||
}
|
||||
}
|
||||
|
||||
/* Send webhook */
|
||||
if ( \in_array( $obj->hidden(), array( -1, 0, 1 ) ) ) // i.e. not post before register or pending deletion
|
||||
{
|
||||
@@ -273,11 +259,11 @@ abstract class _Comment extends \IPS\Content
|
||||
{
|
||||
$event = 'comment_create';
|
||||
$properties = $obj->getDataLayerProperties();
|
||||
}
|
||||
|
||||
if ( $properties['content_area'] === 'personal_messages' )
|
||||
{
|
||||
return;
|
||||
if ( $properties['content_area'] === 'personal_messages' )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$properties = array_merge( $properties, array(
|
||||
@@ -291,6 +277,23 @@ abstract class _Comment extends \IPS\Content
|
||||
/* Update item */
|
||||
$obj->postCreate();
|
||||
|
||||
/* Send notifications and dish out points */
|
||||
if ( !\in_array( 'IPS\Content\Review', class_parents( \get_called_class() ) ) )
|
||||
{
|
||||
if ( !$obj->hidden() and ( !$first or !$item::$firstCommentRequired ) )
|
||||
{
|
||||
$obj->sendNotifications();
|
||||
if( !$item instanceof \IPS\core\Messenger\Conversation )
|
||||
{
|
||||
$member->achievementAction( 'core', 'Comment', $obj );
|
||||
}
|
||||
}
|
||||
else if( $obj->hidden() === 1 )
|
||||
{
|
||||
$obj->sendUnapprovedNotification();
|
||||
}
|
||||
}
|
||||
|
||||
/* This needs to happen before the index is added */
|
||||
if( $item::$firstCommentRequired and $obj->isFirst() )
|
||||
{
|
||||
@@ -432,7 +435,7 @@ abstract class _Comment extends \IPS\Content
|
||||
if ( !$item->hidden() and ! $item->approvedButHidden() and $item->containerWrapper() and $item->container()->_comments !== NULL and !$item->isFutureDate() )
|
||||
{
|
||||
$item->container()->_comments = ( $item->container()->_comments + 1 );
|
||||
$item->container()->setLastComment( $this );
|
||||
$item->container()->setLastComment( $this, $item );
|
||||
$item->container()->save();
|
||||
}
|
||||
}
|
||||
@@ -442,7 +445,7 @@ abstract class _Comment extends \IPS\Content
|
||||
|
||||
if ( $item->containerWrapper() AND !$item->approvedButHidden() AND $this->hidden() == 1 AND $item->container()->_unapprovedComments !== NULL )
|
||||
{
|
||||
$item->container()->_unapprovedComments = $item->container()->_unapprovedComments + 1;
|
||||
$item->container()->_unapprovedComments = ( $item->container()->_unapprovedComments >= 0 ) ? ( $item->container()->_unapprovedComments + 1 ) : 0;
|
||||
$item->container()->save();
|
||||
}
|
||||
}
|
||||
@@ -463,7 +466,7 @@ abstract class _Comment extends \IPS\Content
|
||||
|
||||
/* Update trending */
|
||||
$class = \get_class( $item );
|
||||
if( \IPS\Application::appIsEnabled( 'cloud' ) and \IPS\cloud\Realtime::i()->isEnabled('trending') and $class::$includeInTrending )
|
||||
if( \IPS\Application::appIsEnabled( 'cloud' ) and \IPS\cloud\Application::trendingIsEnabled() and $class::$includeInTrending )
|
||||
{
|
||||
/* Score by timestamp for trending */
|
||||
try
|
||||
@@ -554,6 +557,49 @@ abstract class _Comment extends \IPS\Content
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array Shareable URLs
|
||||
*/
|
||||
protected static $shareableUrls = array();
|
||||
/**
|
||||
* Get a shareable URL
|
||||
*
|
||||
* @return Url
|
||||
*/
|
||||
public function shareableUrl( string $type='comment' )
|
||||
{
|
||||
$currentPage = \IPS\Dispatcher\Front::i()->currentPage ?? 1;
|
||||
$idColumn = static::$databaseColumnId;
|
||||
$item = $this->item();
|
||||
$itemIdColumn = $item::$databaseColumnId;
|
||||
|
||||
/* Avoid building a single item's URL multiple times, such as when viewing a topic */
|
||||
if ( isset( static::$shareableUrls[ $type ][ $item->$itemIdColumn ] ) )
|
||||
{
|
||||
$url = static::$shareableUrls[ $type ][ $item->$itemIdColumn ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = $item->url()->setPage( 'page', $currentPage );
|
||||
|
||||
/* if we can do both comments and reviews, just return the findCommment url as we have tabs to navigate anyway */
|
||||
if ( isset( $item::$reviewClass ) and isset( $item::$commentClass ) )
|
||||
{
|
||||
if ( method_exists( $item, 'commentReviewTabs' ) )
|
||||
{
|
||||
if ( count( $item->commentReviewTabs() ) > 1 )
|
||||
{
|
||||
$url = $url->setQueryString( ['tab' => $type . 's'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static::$shareableUrls[ $type ][ $item->$itemIdColumn ] = $url;
|
||||
}
|
||||
|
||||
return $url->setFragment( 'find' . ucfirst( $type ) . '-' . $this->$idColumn );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get containing item
|
||||
*
|
||||
@@ -910,6 +956,7 @@ abstract class _Comment extends \IPS\Content
|
||||
if ( $item->container()->_comments !== NULL )
|
||||
{
|
||||
$item->container()->setLastComment();
|
||||
$item->container()->_comments = ( $item->container()->_comments > 0 ) ? ( $item->container()->_comments - 1 ) : 0;
|
||||
$item->container()->resetCommentCounts();
|
||||
$item->container()->save();
|
||||
}
|
||||
@@ -923,7 +970,7 @@ abstract class _Comment extends \IPS\Content
|
||||
|
||||
if ( \IPS\IPS::classUsesTrait( $item, 'IPS\Content\Statistics' ) )
|
||||
{
|
||||
$item->clearCachedStatistics();
|
||||
$item->clearCachedStatistics( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -966,11 +1013,18 @@ abstract class _Comment extends \IPS\Content
|
||||
{
|
||||
if ( $item->container()->_comments !== NULL )
|
||||
{
|
||||
$item->container()->setLastComment();
|
||||
$item->container()->setLastComment( $this, $this->item() );
|
||||
$item->container()->_comments = ( $item->container()->_comments + 1 );
|
||||
$item->container()->resetCommentCounts();
|
||||
$item->container()->save();
|
||||
}
|
||||
|
||||
if( $item->container()->_unapprovedComments !== NULL and $approving )
|
||||
{
|
||||
$item->container()->_unapprovedComments = ( $item->container()->_unapprovedComments > 0 ) ? ( $item->container()->_unapprovedComments - 1 ) : 0;
|
||||
$item->container()->save();
|
||||
}
|
||||
|
||||
/* Update mappings */
|
||||
if ( \IPS\IPS::classUsesTrait( $item->container(), 'IPS\Node\Statistics' ) )
|
||||
{
|
||||
@@ -1092,11 +1146,6 @@ abstract class _Comment extends \IPS\Content
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->index( $this );
|
||||
}
|
||||
|
||||
if ( \IPS\IPS::classUsesTrait( $item, 'IPS\Content\Statistics' ) )
|
||||
{
|
||||
$item->clearCachedStatistics();
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the content items URL to IndexNow */
|
||||
@@ -1115,9 +1164,6 @@ abstract class _Comment extends \IPS\Content
|
||||
{
|
||||
\IPS\core\IndexNow::addUrlsToQueue( $noIndexUrls );
|
||||
}
|
||||
|
||||
/* Remove from Hive */
|
||||
\IPS\core\Hive::i()->removeContent( $this );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1243,7 +1289,7 @@ abstract class _Comment extends \IPS\Content
|
||||
|
||||
if ( $item AND \IPS\IPS::classUsesTrait( $this->item(), 'IPS\Content\Statistics' ) )
|
||||
{
|
||||
$item->clearCachedStatistics();
|
||||
$item->clearCachedStatistics( TRUE );
|
||||
}
|
||||
|
||||
/* Delete any notifications telling people about this */
|
||||
@@ -1292,7 +1338,7 @@ abstract class _Comment extends \IPS\Content
|
||||
if ( !$this->hidden() AND $this->hidden() !== -2 )
|
||||
{
|
||||
$item->container()->_comments = ( $item->container()->_comments > 0 ) ? ( $item->container()->_comments - 1 ) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
$item->resyncLastComment();
|
||||
$item->save();
|
||||
@@ -1352,12 +1398,12 @@ abstract class _Comment extends \IPS\Content
|
||||
}
|
||||
|
||||
/* Last comment */
|
||||
$this->item()->resyncLastComment();
|
||||
$this->item()->resyncLastReview();
|
||||
$this->item()->resyncLastComment( $this );
|
||||
$this->item()->resyncLastReview( $this );
|
||||
$this->item()->save();
|
||||
if ( $container = $this->item()->containerWrapper() )
|
||||
{
|
||||
$container->setLastComment();
|
||||
$container->setLastComment( updatedItem: $this->item() );
|
||||
$container->setLastReview();
|
||||
$container->save();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user