Version 4.7.6
This commit is contained in:
1 parent
8ba7d43898
commit
7b7404e741
1085 files changed
+30590
-7837
No files matched your search
+104
-24
@@ -289,7 +289,15 @@ abstract class _Comment extends \IPS\Content
|
||||
$obj->postCreate();
|
||||
|
||||
/* This needs to happen before the index is added */
|
||||
$parameters = array_merge( array( 'reply-' . $item::$application . '/' . $item::$module . '-' . $item->$idColumn ), $obj->attachmentIds() );
|
||||
if( $item::$firstCommentRequired and $obj->isFirst() )
|
||||
{
|
||||
$container = $obj->container();
|
||||
$parameters = array_merge( array( 'newContentItem-' . $item::$application . '/' . $item::$module . '-' . ( $container ? $container->_id : 0 ) ), $obj->attachmentIds() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$parameters = array_merge( array( 'reply-' . $item::$application . '/' . $item::$module . '-' . $item->$idColumn ), $obj->attachmentIds() );
|
||||
}
|
||||
\IPS\File::claimAttachments( ...$parameters );
|
||||
|
||||
/* Add to search index */
|
||||
@@ -418,7 +426,7 @@ abstract class _Comment extends \IPS\Content
|
||||
|
||||
$item->save();
|
||||
|
||||
if ( !$item->hidden() and ! $item->approvedButHidden() and $item->containerWrapper() and $item->container()->_comments !== NULL )
|
||||
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 );
|
||||
@@ -459,7 +467,66 @@ abstract class _Comment extends \IPS\Content
|
||||
{
|
||||
\IPS\Redis::i()->zIncrBy( 'trending', time(), $class . '__' . $item->$itemIdColumn );
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
catch( \RedisException $e ) { }
|
||||
}
|
||||
|
||||
/* Was it moderated? Let's see why. */
|
||||
if ( $this->hidden() === 1 )
|
||||
{
|
||||
$idColumn = static::$databaseColumnId;
|
||||
|
||||
/* Check we don't already have a reason from profanity / url / email filters */
|
||||
try
|
||||
{
|
||||
\IPS\core\Approval::loadFromContent( \get_called_class(), $this->$idColumn );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* If the user is mod-queued - that's why. These will cascade, so check in that order. */
|
||||
$foundReason = FALSE;
|
||||
$log = new \IPS\core\Approval;
|
||||
$log->content_class = \get_called_class();
|
||||
$log->content_id = $this->$idColumn;
|
||||
if ( $this->author()->mod_posts )
|
||||
{
|
||||
|
||||
$log->held_reason = 'user';
|
||||
$foundReason = TRUE;
|
||||
}
|
||||
|
||||
/* If the user isn't mod queued, but is in a group that is, that's why. */
|
||||
if ( $foundReason === FALSE AND $this->author()->group['g_mod_preview'] )
|
||||
{
|
||||
$log->held_reason = 'group';
|
||||
$foundReason = TRUE;
|
||||
}
|
||||
|
||||
/* If the user isn't on mod queue, but the container requires approval, that's why. */
|
||||
if ( $foundReason === FALSE )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $item->container() AND $item->container()->contentHeldForApprovalByNode( 'comment', $this->author() ) === TRUE )
|
||||
{
|
||||
$log->held_reason = 'node';
|
||||
$foundReason = TRUE;
|
||||
}
|
||||
}
|
||||
catch( \BadMethodCallException $e ) { }
|
||||
}
|
||||
|
||||
/* Finally if the item itself requires moderation, that's why */
|
||||
if ( $foundReason === FALSE AND \is_array( $item::supportedMetaDataTypes() ) AND \in_array('core_ItemModeration', $item::supportedMetaDataTypes() ) AND (bool) \IPS\Application::load('core')->extensions( 'core', 'MetaData' )['ItemModeration']->enabled( $item, $this->author() ) )
|
||||
{
|
||||
$log->held_reason = 'item';
|
||||
$foundReason = TRUE;
|
||||
}
|
||||
|
||||
if ( $foundReason )
|
||||
{
|
||||
$log->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1008,7 +1075,10 @@ abstract class _Comment extends \IPS\Content
|
||||
\IPS\Db::i()->delete( 'core_item_member_map', array( 'map_class=? and map_item_id=?', \get_class( $oldItem ), $oldItem->$idColumn ) );
|
||||
\IPS\Db::i()->delete( 'core_item_member_map', array( 'map_class=? and map_item_id=?', \get_class( $item ), $item->$idColumn ) );
|
||||
}
|
||||
|
||||
|
||||
/* Update reports */
|
||||
\IPS\Db::i()->update( 'core_rc_index', array( 'item_id' => $item->$idColumn, 'node_id' => ( $item->containerWrapper() ? $item->containerWrapper()->_id : 0 ) ), array( 'class=? and content_id=?', \get_class( $this ), $oldItem->$idColumn ) );
|
||||
|
||||
if( $skip === FALSE )
|
||||
{
|
||||
$oldItem->rebuildFirstAndLastCommentData();
|
||||
@@ -1096,7 +1166,7 @@ abstract class _Comment extends \IPS\Content
|
||||
}
|
||||
|
||||
/* Remove featured comment associations */
|
||||
if( $this->isFeatured() AND $item )
|
||||
if( $item and $this->isFeatured() )
|
||||
{
|
||||
\IPS\Application::load('core')->extensions( 'core', 'MetaData' )['FeaturedComments']->unfeatureComment( $item, $this );
|
||||
}
|
||||
@@ -1154,7 +1224,7 @@ abstract class _Comment extends \IPS\Content
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\IPS::classUsesTrait( $this->item(), 'IPS\Content\Solvable' ) and isset( $itemClass::$databaseColumnMap['solved_comment_id'] ) )
|
||||
if ( $item AND \IPS\IPS::classUsesTrait( $this->item(), 'IPS\Content\Solvable' ) and isset( $itemClass::$databaseColumnMap['solved_comment_id'] ) )
|
||||
{
|
||||
/* Reset item */
|
||||
if ( $item->mapped('solved_comment_id') and $item->mapped('solved_comment_id') == $this->$idColumn )
|
||||
@@ -1165,7 +1235,7 @@ abstract class _Comment extends \IPS\Content
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\IPS::classUsesTrait( $this->item(), 'IPS\Content\Statistics' ) )
|
||||
if ( $item AND \IPS\IPS::classUsesTrait( $this->item(), 'IPS\Content\Statistics' ) )
|
||||
{
|
||||
$item->clearCachedStatistics();
|
||||
}
|
||||
@@ -1806,28 +1876,38 @@ abstract class _Comment extends \IPS\Content
|
||||
public function webhookFilters()
|
||||
{
|
||||
$filters = parent::webhookFilters();
|
||||
$item = $this->item();
|
||||
try
|
||||
{
|
||||
$item = $this->item();
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
$item = NULL;
|
||||
}
|
||||
|
||||
/* This is kept for legacy compatibility, but starting with 4.6.13 the Content and Item class handle this inside their own webhookFilter methods */
|
||||
$filters['hidden'] = ( ( (bool) $this->hidden() ) or ( (bool) $item->hidden() ) );
|
||||
$filters['hidden'] = ( ( (bool) $this->hidden() ) or ( (bool) $item and $item->hidden() ) );
|
||||
|
||||
if ( \in_array( 'IPS\Content\Lockable', class_implements( $item ) ) )
|
||||
if( $item )
|
||||
{
|
||||
$filters['locked'] = $item->locked();
|
||||
if ( \in_array( 'IPS\Content\Lockable', class_implements( $item ) ) )
|
||||
{
|
||||
$filters['locked'] = $item->locked();
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Pinnable', class_implements( $item ) ) )
|
||||
{
|
||||
$filters['pinned'] = (bool) $item->mapped('pinned');
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Featurable', class_implements( $item ) ) )
|
||||
{
|
||||
$filters['featured'] = (bool) $item->mapped('featured');
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Polls', class_implements( $item ) ) )
|
||||
{
|
||||
$filters['hasPoll'] = (bool) $item->mapped('poll');
|
||||
}
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Pinnable', class_implements( $item ) ) )
|
||||
{
|
||||
$filters['pinned'] = (bool) $item->mapped('pinned');
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Featurable', class_implements( $item ) ) )
|
||||
{
|
||||
$filters['featured'] = (bool) $item->mapped('featured');
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Polls', class_implements( $item ) ) )
|
||||
{
|
||||
$filters['hasPoll'] = (bool) $item->mapped('poll');
|
||||
}
|
||||
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user