Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

+41 -75
View File
@@ -184,20 +184,6 @@ abstract class _Comment extends \IPS\Content
}
catch( \BadMethodCallException $e ) { }
/* Update the container */
if ( !$obj->hidden() AND !$item->hidden() )
{
try
{
$container = $item->container();
if ( $container->_comments !== NULL )
{
$container->setLastComment( $obj );
$container->save();
}
}
catch ( \BadMethodCallException $e ) { }
}
/* Update member's last post and daily post limits */
if( $obj->author()->member_id )
@@ -253,10 +239,14 @@ abstract class _Comment extends \IPS\Content
* @note We do not save here, as saving is done in user-land code after
* @param bool $first Is this the first comment?
* @param bool $edit Are we editing or merging (true) or is this a new comment (false)?
* @param string|NULL $content The content to check - useful for if the content needs to be checked first, before it gets saved to the database.
* @return bool Whether to send unapproved notifications
*/
protected function checkProfanityFilters( $first=FALSE, $edit=TRUE )
public function checkProfanityFilters( $first=FALSE, $edit=TRUE, $content=NULL )
{
/* Set our content */
$content = $content ?: $this->content();
/* We need our item */
$item = $this->item();
@@ -265,25 +255,29 @@ abstract class _Comment extends \IPS\Content
/* Pass this through our profanity filters to see if it needs to be mod queued */
$sendNotifications = FALSE;
/* Do we need to recount item comments and container comments? */
$recount = FALSE;
try
{
$hiddenByFilter = FALSE;
if ( !$this->hidden() AND ( ! $item::$firstCommentRequired or ( $item::$firstCommentRequired and !$first ) ) AND !$member->group['g_bypass_badwords'] )
{
$hiddenByFilter = \IPS\core\Profanity::hiddenByFilters( $this->content() );
$hiddenByFilter = \IPS\core\Profanity::hiddenByFilters( $content );
}
/* If the comment is hidden (probably requires moderator approval) and this is the first post in the item that requires a comment (i.e. a post in a topic), then we need to set the item as requiring approval instead. */
elseif ( $item instanceof \IPS\Content\Hideable AND !$member->group['g_bypass_badwords'] AND ( $item::$firstCommentRequired and $first ) )
{
$itemHiddenByFilter = \IPS\core\Profanity::hiddenByFilters( $this->content() );
$itemHiddenByFilter = \IPS\core\Profanity::hiddenByFilters( $content );
if ( isset( $item::$databaseColumnMap['approved'] ) and $itemHiddenByFilter )
{
/* 'approved' is easy, clear and concise */
$column = $item::$databaseColumnMap['approved'];
$item->$column = 0;
$item->save();
$recount = TRUE;
}
elseif ( isset( $item::$databaseColumnMap['hidden'] ) and $itemHiddenByFilter )
{
@@ -291,8 +285,9 @@ abstract class _Comment extends \IPS\Content
$column = $item::$databaseColumnMap['hidden'];
$item->$column = 1;
$item->save();
$recount = TRUE;
}
if( $edit === TRUE )
{
$sendNotifications = TRUE;
@@ -303,6 +298,7 @@ abstract class _Comment extends \IPS\Content
if ( $hiddenByFilter === TRUE )
{
$recount = TRUE;
if ( isset( static::$databaseColumnMap['approved'] ) )
{
/* 'approved' is easy, clear and concise */
@@ -318,6 +314,20 @@ abstract class _Comment extends \IPS\Content
$sendNotifications = TRUE;
}
if ( $recount === TRUE )
{
$item->resyncCommentCounts();
$item->resyncLastComment();
$item->save();
if ( $container = $item->containerWrapper() )
{
$container->resetCommentCounts();
$container->save();
}
}
return $sendNotifications;
}
@@ -422,7 +432,7 @@ abstract class _Comment extends \IPS\Content
{
$item->save();
if ( $item->containerWrapper() AND !$item->approvedButHidden() AND $item->container()->_unapprovedComments !== NULL )
if ( $item->containerWrapper() AND !$item->approvedButHidden() AND $this->hidden() == 1 AND $item->container()->_unapprovedComments !== NULL )
{
$item->container()->_unapprovedComments = $item->container()->_unapprovedComments + 1;
$item->container()->save();
@@ -564,14 +574,7 @@ abstract class _Comment extends \IPS\Content
{
$member = $member ?: \IPS\Member::loggedIn();
$container = NULL;
try
{
$container = $this->item()->container();
}
catch ( \BadMethodCallException $e ) { }
return ( !$this->isFirst() and ( static::modPermission( 'hide', $member, $container ) or ( $member->member_id and $member->member_id == $this->author()->member_id and ( $member->group['g_hide_own_posts'] == '1' or in_array( get_class( $this->item() ), explode( ',', $member->group['g_hide_own_posts'] ) ) ) ) ) );
return ( !$this->isFirst() and ( static::modPermission( 'hide', $member, $this->item()->containerWrapper() ) or ( $member->member_id and $member->member_id == $this->author()->member_id and ( $member->group['g_hide_own_posts'] == '1' or in_array( get_class( $this->item() ), explode( ',', $member->group['g_hide_own_posts'] ) ) ) ) ) );
}
/**
@@ -584,13 +587,6 @@ abstract class _Comment extends \IPS\Content
{
$member = $member ?: \IPS\Member::loggedIn();
$container = NULL;
try
{
$container = $this->item()->container();
}
catch ( \BadMethodCallException $e ) { }
$hiddenByItem = FALSE;
if ( isset( static::$databaseColumnMap['hidden'] ) )
{
@@ -598,7 +594,7 @@ abstract class _Comment extends \IPS\Content
$hiddenByItem = (boolean) ( $this->$column === 2 );
}
return ( !$this->isFirst() and ! $hiddenByItem and static::modPermission( 'unhide', $member, $container ) );
return ( !$this->isFirst() and ! $hiddenByItem and static::modPermission( 'unhide', $member, $this->item()->containerWrapper() ) );
}
/**
@@ -611,14 +607,7 @@ abstract class _Comment extends \IPS\Content
{
$member = $member ?: \IPS\Member::loggedIn();
$container = NULL;
try
{
$container = $this->item()->container();
}
catch ( \BadMethodCallException $e ) { }
return ( !$this->isFirst() and ( static::modPermission( 'delete', $member, $container ) or ( $member->member_id and $member->member_id == $this->author()->member_id and ( $member->group['g_delete_own_posts'] == '1' or in_array( get_class( $this->item() ), explode( ',', $member->group['g_delete_own_posts'] ) ) ) ) ) );
return ( !$this->isFirst() and ( static::modPermission( 'delete', $member, $this->item()->containerWrapper() ) or ( $member->member_id and $member->member_id == $this->author()->member_id and ( $member->group['g_delete_own_posts'] == '1' or in_array( get_class( $this->item() ), explode( ',', $member->group['g_delete_own_posts'] ) ) ) ) ) );
}
/**
@@ -633,17 +622,10 @@ abstract class _Comment extends \IPS\Content
if ( $itemClass::$firstCommentRequired )
{
$container = NULL;
try
{
$container = $this->item()->container();
}
catch ( \BadMethodCallException $e ) { }
if ( !$this->isFirst() )
{
$member = $member ?: \IPS\Member::loggedIn();
return $itemClass::modPermission( 'split_merge', $member, $container );
return $itemClass::modPermission( 'split_merge', $member, $this->item()->containerWrapper() );
}
}
return FALSE;
@@ -715,35 +697,17 @@ abstract class _Comment extends \IPS\Content
*/
public function editContents( $newContent )
{
/* Check if profanity filters should mod-queue this comment */
$sendNotifications = $this->checkProfanityFilters( $this->isFirst(), TRUE, $newContent );
/* Do it */
$valueField = static::$databaseColumnMap['content'];
$oldValue = $this->$valueField;
$this->$valueField = $newContent;
$isHiddenNow = $this->hidden();
/* Check if profanity filters should mod-queue this comment */
$sendNotifications = $this->checkProfanityFilters( $this->isFirst(), TRUE );
$this->save();
/* Send any new mention/quote notifications */
$this->sendAfterEditNotifications( $oldValue );
/* Resync the item - necessary as profanity filters may have just hidden an otherwise approved post */
$item = $this->item();
if( $isHiddenNow != $this->hidden() )
{
$item->resyncCommentCounts();
$item->resyncLastComment();
$item->save();
}
if ( $container = $item->containerWrapper() )
{
$container->resetCommentCounts();
$container->save();
}
/* Reindex */
if ( $this instanceof \IPS\Content\Searchable )
@@ -1158,7 +1122,9 @@ abstract class _Comment extends \IPS\Content
{
$oldAuthor = $this->author();
if( $oldAuthor->member_id == $newAuthor->member_id )
/* If we delete a member, then change author, the old author returns 0 as does the new author as the
member row is deleted before the task is run */
if( $newAuthor->member_id and ( $oldAuthor->member_id == $newAuthor->member_id ) )
{
return;
}