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

+138 -131
View File
@@ -933,6 +933,18 @@ abstract class _Item extends \IPS\Content
$field = $commentClass::$databaseColumnMap['edit_show'];
$commentObj->$field = 0;
}
/* Check if profanity filters should mod-queue this comment */
$sendNotifications = $commentObj->checkProfanityFilters( TRUE, TRUE );
/* Send notifications */
if ( $sendNotifications AND !in_array( 'IPS\Content\Review', class_parents( get_called_class() ) ) )
{
if( $commentObj->hidden() === 1 )
{
$commentObj->sendUnapprovedNotification();
}
}
}
$oldValue = $commentObj->$column;
@@ -1231,20 +1243,47 @@ abstract class _Item extends \IPS\Content
public function contentImages( $limit = NULL )
{
$idColumn = static::$databaseColumnId;
$internal = NULL;
$internal = array();
$attachments = array();
$loadedExtensions = array();
/* Get attachments from the content, or all comments */
if ( isset( static::$databaseColumnMap['content'] ) or isset( static::$commentClass ) )
{
$internal = \IPS\Db::i()->select( 'attachment_id', 'core_attachments_map', array( 'location_key=? and id1=?', static::$application . '_' . mb_ucfirst( static::$module ), $this->$idColumn ) );
$internal = iterator_to_array( \IPS\Db::i()->select( '*', 'core_attachments_map', array( 'location_key=? and id1=?', static::$application . '_' . mb_ucfirst( static::$module ), $this->$idColumn ) )->setKeyField('attachment_id') );
}
if ( $internal )
{
foreach( \IPS\Db::i()->select( '*', 'core_attachments', array( array( 'attach_id IN(?)', $internal ), array( 'attach_is_image=1' ) ), 'attach_id ASC', $limit ) as $row )
{
$attachments[] = array( 'core_Attachment' => $row['attach_location'] );
foreach( \IPS\Db::i()->select( '*', 'core_attachments', array( array( \IPS\Db::i()->in( 'attach_id', array_keys( $internal ) ) ), array( 'attach_is_image=1' ) ), 'attach_id ASC', $limit ) as $row )
{
$map = $internal[ $row['attach_id'] ];
if ( !isset( $loadedExtensions[ $map['location_key'] ] ) )
{
$exploded = explode( '_', $map['location_key'] );
try
{
$extensions = \IPS\Application::load( $exploded[0] )->extensions( 'core', 'EditorLocations' );
if ( isset( $extensions[ $exploded[1] ] ) )
{
$loadedExtensions[ $map['location_key'] ] = $extensions[ $exploded[1] ];
}
}
catch ( \OutOfRangeException $e ) { }
}
if ( isset( $loadedExtensions[ $map['location_key'] ] ) )
{
try
{
if ( $loadedExtensions[ $map['location_key'] ]->attachmentPermissionCheck( \IPS\Member::loggedIn(), $map['id1'], $map['id2'], $map['id3'], $row, TRUE ) )
{
$attachments[] = array( 'core_Attachment' => $row['attach_location'] );
}
}
catch ( \Exception $e ) { }
}
}
}
@@ -1285,9 +1324,9 @@ abstract class _Item extends \IPS\Content
{
$return = parent::content();
}
elseif( static::$firstCommentRequired )
elseif( static::$firstCommentRequired AND $comment = $this->firstComment() )
{
$return = $this->firstComment()->content();
$return = $comment->content();
}
else
{
@@ -1505,29 +1544,18 @@ abstract class _Item extends \IPS\Content
/* Add to search index */
if ( $this instanceof \IPS\Content\Searchable )
{
if ( $this instanceof \IPS\Content\Item and static::$firstCommentRequired )
if ( $this instanceof \IPS\Content\Item AND ( isset( static::$commentClass ) OR isset( static::$reviewClass ) ) )
{
\IPS\Content\Search\Index::i()->index( $this->firstComment() );
\IPS\Content\Search\Index::i()->index( ( static::$firstCommentRequired ) ? $this->firstComment() : $this );
\IPS\Content\Search\Index::i()->indexSingleItem( $this );
}
else
{
/* Either this is a comment / review, or the item doesn't support comments or reviews, so we can just reindex it now. */
\IPS\Content\Search\Index::i()->index( $this );
}
}
$idColumn = static::$databaseColumnId;
foreach ( array( 'commentClass', 'reviewClass' ) as $class )
{
if ( isset( static::$$class ) )
{
$className = static::$$class;
if ( in_array( 'IPS\Content\Searchable', class_implements( $className ) ) )
{
\IPS\Content\Search\Index::i()->massUpdate( $className, NULL, $this->$idColumn, $this->searchIndexPermissions(), NULL, $container->_id );
}
}
}
/* Update caches */
$this->expireWidgetCaches();
$this->adjustSessions();
@@ -1782,11 +1810,11 @@ abstract class _Item extends \IPS\Content
$existingFlag = static::$useWriteServer;
static::$useWriteServer = TRUE;
$firstComment = $this->comments( 1, 0, 'date', 'asc', NULL, static::$firstCommentRequired ?: FALSE, NULL, NULL, TRUE );
$idColumn = static::$databaseColumnId;
if ( isset( static::$commentClass ) )
{
$firstComment = $this->comments( 1, 0, 'date', 'asc', NULL, static::$firstCommentRequired ?: FALSE, NULL, NULL, TRUE );
$idColumn = static::$databaseColumnId;
$commentClass = static::$commentClass;
$commentIdColumn = $commentClass::$databaseColumnId;
@@ -1897,6 +1925,7 @@ abstract class _Item extends \IPS\Content
/* Update container */
$this->container()->resetCommentCounts();
$this->container()->setLastComment();
$this->container()->setLastReview();
$this->container()->save();
}
@@ -1922,31 +1951,26 @@ abstract class _Item extends \IPS\Content
\IPS\Db::i()->delete( 'core_notifications', array( 'item_class=? AND item_id=?', (string) get_class( $this ), (int) $this->$idColumn ) );
foreach ( array( 'commentClass', 'reviewClass' ) as $class )
if ( $this instanceof \IPS\Content\Searchable )
{
if ( isset( static::$$class ) )
if ( $this instanceof \IPS\Content\Item AND ( isset( static::$commentClass ) OR isset( static::$reviewClass ) ) )
{
$className = static::$$class;
if ( in_array( 'IPS\Content\Hideable', class_implements( $className ) ) AND isset( $className::$databaseColumnMap['hidden'] ) )
$firstComment = NULL;
if ( static::$firstCommentRequired AND isset( static::$commentClass ) )
{
\IPS\Db::i()->update( $className::$databaseTable, array( $className::$databasePrefix . $className::$databaseColumnMap['hidden'] => 2 ), array( $className::$databasePrefix . $className::$databaseColumnMap['item'] . '=? AND ' . $className::$databasePrefix . $className::$databaseColumnMap['hidden'] . '=?', $this->$idColumn, 0 ) );
}
if ( in_array( 'IPS\Content\Searchable', class_implements( $className ) ) )
{
\IPS\Content\Search\Index::i()->massUpdate( $className, NULL, $this->$idColumn, NULL, 2 );
if ( static::$firstCommentRequired )
{
$firstComment = $this->comments( 1, NULL, 'date', 'asc' );
if( $firstComment )
{
$column = $className::$databaseColumnMap['hidden'];
$firstComment->$column = 2;
\IPS\Content\Search\Index::i()->index( $firstComment );
}
}
$className = static::$commentClass;
$firstComment = $this->firstComment();
$column = $className::$databaseColumnMap['hidden'];
$firstComment->$column = 2;
}
\IPS\Content\Search\Index::i()->index( ( static::$firstCommentRequired ) ? $firstComment : $this );
\IPS\Content\Search\Index::i()->indexSingleItem( $this );
}
else
{
/* Either this is a comment / review, or the item doesn't support comments or reviews, so we can just reindex it now. */
\IPS\Content\Search\Index::i()->index( $this );
}
}
@@ -2008,27 +2032,26 @@ abstract class _Item extends \IPS\Content
parent::unhide( $member );
/* And then update the search index */
if ( isset( static::$commentClass ) and static::$firstCommentRequired AND $this->mapped('first_comment_id') )
if ( $this instanceof \IPS\Content\Searchable )
{
$commentClass = static::$commentClass;
/* We have to do it this way because of R/W Separation */
$firstComment = $this->firstComment();
$column = $commentClass::$databaseColumnMap['hidden'];
$firstComment->$column = 0;
\IPS\Content\Search\Index::i()->index( $firstComment );
}
foreach ( array( 'commentClass', 'reviewClass' ) as $class )
{
if ( isset( static::$$class ) )
if ( $this instanceof \IPS\Content\Item AND ( isset( static::$commentClass ) OR isset( static::$reviewClass ) ) )
{
$className = static::$$class;
if ( in_array( 'IPS\Content\Searchable', class_implements( $className ) ) )
$firstComment = NULL;
if ( static::$firstCommentRequired AND isset( static::$commentClass ) )
{
\IPS\Content\Search\Index::i()->massUpdate( $className, NULL, $this->$idColumn, NULL, 0 );
$className = static::$commentClass;
$firstComment = $this->firstComment();
$column = $className::$databaseColumnMap['hidden'];
$firstComment->$column = 0;
}
\IPS\Content\Search\Index::i()->index( ( static::$firstCommentRequired ) ? $firstComment : $this );
\IPS\Content\Search\Index::i()->indexSingleItem( $this );
}
else
{
/* Either this is a comment / review, or the item doesn't support comments or reviews, so we can just reindex it now. */
\IPS\Content\Search\Index::i()->index( $this );
}
}
@@ -2247,6 +2270,28 @@ abstract class _Item extends \IPS\Content
}
}
/**
* Change IP Address
* @param string $ip The new IP address
*
* @return void
*/
public function changeIpAddress( $ip )
{
parent::changeIpAddress( $ip );
/* How about a required comment? */
if ( isset( static::$commentClass ) and static::$firstCommentRequired )
{
$commentClass = static::$commentClass;
if ( isset( static::$databaseColumnMap['first_comment_id'] ) AND $comment = $this->firstComment() )
{
$comment->changeIpAddress( $ip );
}
}
}
/**
* Change Author
*
@@ -2257,7 +2302,9 @@ abstract class _Item 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;
}
@@ -3297,7 +3344,7 @@ abstract class _Item extends \IPS\Content
$order = ( isset( $class::$databaseColumnMap[ $order ] ) ? ( $class::$databasePrefix . $class::$databaseColumnMap[ $order ] ) : $order ) . ' ' . $orderDirection;
}
$this->cachedReviews[ $cacheKey ] = $this->_comments( $class, $limit ?: static::$reviewsPerPage, $offset, $order, $member, $includeHiddenReviews, $cutoff, NULL, $extraWhereClause, $includeDeleted, $canViewWarn );
$this->cachedReviews[ $cacheKey ] = $this->_comments( $class, $limit ?: static::$reviewsPerPage, $offset, $order, $member, $includeHiddenReviews, $cutoff, $canViewWarn, $extraWhereClause, $includeDeleted );
return $this->cachedReviews[ $cacheKey ];
}
@@ -4233,7 +4280,7 @@ abstract class _Item extends \IPS\Content
public function canReview( $member=NULL )
{
$member = $member ?: \IPS\Member::loggedIn();
if ( $member->member_group_id == \IPS\Settings::i()->guest_group or $member->restrict_post or ( $this instanceof \IPS\Content\Lockable and $this->locked() and ( !$member->member_id or !static::modPermission( 'reply_to_locked', $member, $this->container() ) ) ) )
if ( $member->member_group_id == \IPS\Settings::i()->guest_group or $member->restrict_post or ( $this instanceof \IPS\Content\Lockable and $this->locked() and ( !$member->member_id or !static::modPermission( 'reply_to_locked', $member, $this->containerWrapper() ) ) ) )
{
return FALSE;
}
@@ -4303,17 +4350,7 @@ abstract class _Item extends \IPS\Content
return FALSE;
}
$container = NULL;
if ( method_exists( $this, 'container' ) )
{
try
{
$container = $this->container();
}
catch ( \BadMethodCallException $e ) { }
}
return ( static::modPermission( 'reply_to_locked', $member, $container ) and $this->can( $type, $member ) );
return ( static::modPermission( 'reply_to_locked', $member, $this->containerWrapper() ) and $this->can( $type, $member ) );
}
/* Check permissions as normal */
@@ -4694,6 +4731,9 @@ abstract class _Item extends \IPS\Content
if ( $resync )
{
$existingFlag = static::$useWriteServer;
static::$useWriteServer = TRUE;
try
{
$comment = $this->comments( 1, 0, 'date', 'desc', NULL, FALSE, NULL, NULL, TRUE );
@@ -4770,6 +4810,8 @@ abstract class _Item extends \IPS\Content
}
}
}
static::$useWriteServer = $existingFlag;
}
}
@@ -4797,6 +4839,9 @@ abstract class _Item extends \IPS\Content
if ( $resync )
{
$existingFlag = static::$useWriteServer;
static::$useWriteServer = TRUE;
try
{
$review = $this->reviews( 1, 0, 'date', 'desc', NULL, FALSE );
@@ -4856,6 +4901,8 @@ abstract class _Item extends \IPS\Content
}
}
}
static::$useWriteServer = $existingFlag;
}
}
@@ -5408,7 +5455,7 @@ abstract class _Item extends \IPS\Content
}
$member = $member ?: \IPS\Member::loggedIn();
return ( $member->member_id and static::modPermission( 'pin', $member, $this->container() ) );
return ( $member->member_id and static::modPermission( 'pin', $member, $this->containerWrapper() ) );
}
/**
@@ -5425,7 +5472,7 @@ abstract class _Item extends \IPS\Content
}
$member = $member ?: \IPS\Member::loggedIn();
return ( $member->member_id and static::modPermission( 'unpin', $member, $this->container() ) );
return ( $member->member_id and static::modPermission( 'unpin', $member, $this->containerWrapper() ) );
}
/**
@@ -5442,7 +5489,7 @@ abstract class _Item extends \IPS\Content
}
$member = $member ?: \IPS\Member::loggedIn();
return ( $member->member_id and static::modPermission( 'feature', $member, $this->container() ) );
return ( $member->member_id and static::modPermission( 'feature', $member, $this->containerWrapper() ) );
}
/**
@@ -5459,7 +5506,7 @@ abstract class _Item extends \IPS\Content
}
$member = $member ?: \IPS\Member::loggedIn();
return ( $member->member_id and static::modPermission( 'unfeature', $member, $this->container() ) );
return ( $member->member_id and static::modPermission( 'unfeature', $member, $this->containerWrapper() ) );
}
/**
@@ -5499,20 +5546,10 @@ abstract class _Item extends \IPS\Content
{
return FALSE;
}
$container = NULL;
if ( method_exists( $this, 'container' ) )
{
try
{
$container = $this->container();
}
catch ( \BadMethodCallException $e ) { }
}
$member = $member ?: \IPS\Member::loggedIn();
if( $member->member_id and static::modPermission( 'lock', $member, $container ) )
if( $member->member_id and static::modPermission( 'lock', $member, $this->containerWrapper() ) )
{
return TRUE;
}
@@ -5537,20 +5574,10 @@ abstract class _Item extends \IPS\Content
{
return FALSE;
}
$container = NULL;
if ( method_exists( $this, 'container' ) )
{
try
{
$container = $this->container();
}
catch ( \BadMethodCallException $e ) { }
}
$member = $member ?: \IPS\Member::loggedIn();
if( $member->member_id and static::modPermission( 'unlock', $member, $container ) )
if( $member->member_id and static::modPermission( 'unlock', $member, $this->containerWrapper() ) )
{
return TRUE;
}
@@ -5576,18 +5603,8 @@ abstract class _Item extends \IPS\Content
return FALSE;
}
$container = NULL;
if ( method_exists( $this, 'container' ) )
{
try
{
$container = $this->container();
}
catch ( \BadMethodCallException $e ) { }
}
$member = $member ?: \IPS\Member::loggedIn();
return ( $member->member_id and ( static::modPermission( 'hide', $member, $container ) or ( $member->member_id == $this->author()->member_id and ( $member->group['g_hide_own_posts'] == '1' or in_array( get_class( $this ), explode( ',', $member->group['g_hide_own_posts'] ) ) ) ) ) );
return ( $member->member_id and ( static::modPermission( 'hide', $member, $this->containerWrapper() ) or ( $member->member_id == $this->author()->member_id and ( $member->group['g_hide_own_posts'] == '1' or in_array( get_class( $this ), explode( ',', $member->group['g_hide_own_posts'] ) ) ) ) ) );
}
/**
@@ -5609,18 +5626,8 @@ abstract class _Item extends \IPS\Content
return FALSE;
}
$container = NULL;
if ( method_exists( $this, 'container' ) )
{
try
{
$container = $this->container();
}
catch ( \BadMethodCallException $e ) { }
}
$member = $member ?: \IPS\Member::loggedIn();
return ( $member->member_id and ( static::modPermission( 'unhide', $member, $container ) ) );
return ( $member->member_id and ( static::modPermission( 'unhide', $member, $this->containerWrapper() ) ) );
}
/**
@@ -5719,7 +5726,7 @@ abstract class _Item extends \IPS\Content
try
{
return ( $member->member_id and $this->container() and ( static::modPermission( 'move', $member, $this->container() ) ) );
return ( $member->member_id and $this->container() and ( static::modPermission( 'move', $member, $this->containerWrapper() ) ) );
}
catch( \BadMethodCallException $e )
{
@@ -5738,7 +5745,7 @@ abstract class _Item extends \IPS\Content
if ( static::$firstCommentRequired )
{
$member = $member ?: \IPS\Member::loggedIn();
return ( $member->member_id and ( static::modPermission( 'split_merge', $member, $this->container() ) ) );
return ( $member->member_id and ( static::modPermission( 'split_merge', $member, $this->containerWrapper() ) ) );
}
return FALSE;
}
@@ -5768,7 +5775,7 @@ abstract class _Item extends \IPS\Content
/* What about this? */
try
{
return static::modPermission( 'delete', $member, $this->container() );
return static::modPermission( 'delete', $member, $this->containerWrapper() );
}
catch ( \BadMethodCallException $e )
{