Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -1425,7 +1425,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
* @param \IPS\Helpers\Form $form The form helper object
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param string $nodeClass Node class
|
||||
* @param \IPS\Node\Mode $node Node we are working with
|
||||
* @param \IPS\Node\Model $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return \IPS\Helpers\Form
|
||||
*/
|
||||
@@ -1437,7 +1437,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
}, $data['additional']['author'] ) : NULL, FALSE, array( 'nullLang' => 'node_mass_move_anyone', 'multiple' => NULL ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Date( 'node_move_date', isset( $data['additional']['date'] ) ? $data['additional']['date'] : 0, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'node_mass_move_any_time' ) ) );
|
||||
if ( isset( $contentItemClass::$commentClass ) )
|
||||
{
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'node_move_comments', isset( $data['additional']['num_comments'] ) ? $data['additional']['num_comments'] : -1, FALSE, array( 'unlimited' => -1 ), NULL, NULL, NULL, 'node_move_comments_less' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Date( 'node_move_last_post', isset( $data['additional']['last_post'] ) ? $data['additional']['last_post'] : 0, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'node_mass_move_any_time' ) ) );
|
||||
}
|
||||
@@ -1469,7 +1469,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
* @param array $values Values from form submission
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param string $nodeClass Node class
|
||||
* @param \IPS\Node\Mode $node Node we are working with
|
||||
* @param \IPS\Node\Model $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return array Wizard helper data
|
||||
*/
|
||||
@@ -1560,7 +1560,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
* Actually perform the mass move operation (called from the wizard helper)
|
||||
*
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param \IPS\Node\Mode $node Node we are working with
|
||||
* @param \IPS\Node\Model $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief DelayedCount
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage
|
||||
* @since 6/25/2024
|
||||
*/
|
||||
namespace IPS\Node;
|
||||
|
||||
use BadMethodCallException;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Redis;
|
||||
use OutOfRangeException;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
trait DelayedCount
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getStorageId() : string
|
||||
{
|
||||
return \get_called_class() . '_' . $this->_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var bool Prevent loops continually setting the update flag
|
||||
*/
|
||||
public bool $inDelayedCount = FALSE;
|
||||
|
||||
/**
|
||||
* Store the update time in Redis so that we know it needs to be
|
||||
* synced later
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function storeUpdateTime() : void
|
||||
{
|
||||
if( $this->inDelayedCount )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check Redis to see if we already have this node stored.
|
||||
If not, set it with a timestamp. */
|
||||
try
|
||||
{
|
||||
if( ! Redis::isEnabled() )
|
||||
{
|
||||
throw new BadMethodCallException;
|
||||
}
|
||||
|
||||
/* hGet will return a false value if it doesn't exist, or the key doesn't exist in the Redis database */
|
||||
$timestamp = Redis::i()->hGet( 'nodeSyncTimes', $this->getStorageId() );
|
||||
|
||||
if( empty( $timestamp ) )
|
||||
{
|
||||
Redis::i()->hSet( 'nodeSyncTimes', $this->getStorageId(), time() );
|
||||
|
||||
/* Only store for 2 hours maximum, if it's not updated by then, then it's not going to be */
|
||||
Redis::i()->expire( 'nodeSyncTimes', ( 2 * 3600 ) );
|
||||
}
|
||||
}
|
||||
catch( BadMethodCallException | \RedisException )
|
||||
{
|
||||
try
|
||||
{
|
||||
$key = 'nodeSyncTimes';
|
||||
$timestamps = Store::i()->$key;
|
||||
}
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
$timestamps = [];
|
||||
}
|
||||
|
||||
if( !array_key_exists( $this->getStorageId(), $timestamps ) )
|
||||
{
|
||||
$timestamps[ $this->getStorageId() ] = time();
|
||||
Store::i()->$key = $timestamps;
|
||||
}
|
||||
}
|
||||
|
||||
/* Bubble up to parent nodes */
|
||||
try
|
||||
{
|
||||
if( $parent = $this->parent() )
|
||||
{
|
||||
$parent->storeUpdateTime();
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException )
|
||||
{}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the node from Redis
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clearUpdateTime() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
if( ! Redis::isEnabled() )
|
||||
{
|
||||
throw new BadMethodCallException;
|
||||
}
|
||||
|
||||
Redis::i()->hDel( 'nodeSyncTimes', $this->getStorageId() );
|
||||
}
|
||||
catch( BadMethodCallException | RedisException )
|
||||
{
|
||||
try
|
||||
{
|
||||
$key = 'nodeSyncTimes';
|
||||
|
||||
/* @var array $timestamps */
|
||||
$timestamps = Store::i()->$key;
|
||||
if( array_key_exists( $this->getStorageId(), $timestamps ) )
|
||||
{
|
||||
unset( $timestamps[ $this->getStorageId() ] );
|
||||
Store::i()->$key = $timestamps;
|
||||
}
|
||||
}
|
||||
catch( OutOfRangeException ){}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the rebuild methods
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function runScheduledRebuild(): void
|
||||
{
|
||||
/* Recount items, comments, and reviews */
|
||||
$this->recount();
|
||||
|
||||
/* Set flag so we don't cause a loop */
|
||||
$this->inDelayedCount = TRUE;
|
||||
|
||||
/* Force a reset of the last comment */
|
||||
$this->setLastComment();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count all comments, items, etc
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function recount();
|
||||
}
|
||||
+79
-18
@@ -10,6 +10,10 @@
|
||||
|
||||
namespace IPS\Node;
|
||||
|
||||
use IPS\Content\Comment;
|
||||
use IPS\Login;
|
||||
use IPS\Settings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
@@ -19,6 +23,9 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
/**
|
||||
* Node Model
|
||||
* @mixin \IPS\Node\DelayedCount
|
||||
* @mixin \IPS\Node\Colorize
|
||||
* @mixin \IPS\Node\Statistics
|
||||
*/
|
||||
abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
@@ -105,6 +112,11 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public static $maxFormHelperResults = NULL;
|
||||
|
||||
/**
|
||||
* @brief [Node] Cache Total Followers Count
|
||||
*/
|
||||
public int $followerCount = 0;
|
||||
|
||||
/**
|
||||
* @brief [Node] ACP Restrictions
|
||||
* @code
|
||||
@@ -428,10 +440,11 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$order = static::$databaseColumnOrder !== NULL ? static::$databasePrefix . static::$databaseColumnOrder : NULL;
|
||||
if ( \in_array( 'IPS\Node\Permissions', class_implements( \get_called_class() ) ) and $permissionCheck !== NULL )
|
||||
{
|
||||
$where[] = array( '(' . \IPS\Db::i()->findInSet( 'perm_' . static::$permissionMap[ $permissionCheck ], $member->permissionArray() ) . ' OR ' . 'perm_' . static::$permissionMap[ $permissionCheck ] . '=? )', '*' );
|
||||
$where[] = array(
|
||||
'(' . static::$databaseTable . '.' . static::$databasePrefix . static::$databaseColumnId . ' IN(?) )',
|
||||
\IPS\Db::i()->select( 'perm_type_id', 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND ( ( " . \IPS\Db::i()->findInSet( 'perm_' . static::$permissionMap[ $permissionCheck ], $member->permissionArray() ) . ' ) OR perm_' . static::$permissionMap[ $permissionCheck ] . '=? )', static::$permApp, static::$permType, '*' ) ) );
|
||||
|
||||
$select = \IPS\Db::i()->select( '*', static::$databaseTable, $where, $order, NULL, NULL, NULL, \IPS\Db::SELECT_MULTIDIMENSIONAL_JOINS )
|
||||
->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=" . static::$databaseTable . "." . static::$databasePrefix . static::$databaseColumnId, static::$permApp, static::$permType ) );
|
||||
$select = \IPS\Db::i()->select( '*', static::$databaseTable, $where, $order, NULL, NULL, NULL, \IPS\Db::SELECT_MULTIDIMENSIONAL_JOINS );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1045,12 +1058,50 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Set last comment
|
||||
*
|
||||
* @param \IPS\Content\Comment|NULL $comment The latest comment or NULL to work it out
|
||||
* @return int
|
||||
* @param \IPS\Content\Comment|null $comment The latest comment or NULL to work it out
|
||||
* @param \IPS\Content\Item|null $updatedItem We sometimes run setLastComment() when an item has been edited, if so, that item will be here
|
||||
* @return void
|
||||
*/
|
||||
public function setLastComment( \IPS\Content\Comment $comment=NULL )
|
||||
public function setLastComment( ?\IPS\Content\Comment $comment=NULL, ?\IPS\Content\Item $updatedItem=NULL )
|
||||
{
|
||||
// Don't do anything by default, but nodes could extract data
|
||||
/* If either the comment or item are hidden, set to null so that we will load the correct one */
|
||||
if( $comment !== null and $comment->hidden() <> 0 )
|
||||
{
|
||||
$comment = null;
|
||||
}
|
||||
|
||||
if( ( $updatedItem !== null and $updatedItem->hidden() <> 0 ) )
|
||||
{
|
||||
$updatedItem = null;
|
||||
}
|
||||
|
||||
/* If we have a comment and no item, use the item from the comment */
|
||||
if( $comment !== null and $updatedItem === null and $comment->item()->hidden() === 0 )
|
||||
{
|
||||
$updatedItem = $comment->item();
|
||||
}
|
||||
|
||||
/* Let each node set the last comment data */
|
||||
$this->_setLastComment( $comment, $updatedItem );
|
||||
|
||||
$this->save();
|
||||
|
||||
if( \IPS\IPS::classUsesTrait( $this, 'IPS\Node\DelayedCount' ) )
|
||||
{
|
||||
$this->storeUpdateTime();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from Model::setLastComment(), must be implemented by each class
|
||||
*
|
||||
* @param Comment|null $comment
|
||||
* @param \IPS\Content\Item|null $updatedItem
|
||||
* @return void
|
||||
*/
|
||||
protected function _setLastComment( \IPS\Content\Comment $comment=null, \IPS\Content\Item $updatedItem=null )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2054,7 +2105,8 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$groupsToCheck = $member->groups;
|
||||
|
||||
/* Work out which to use taking Post Before Registering into consideration and return */
|
||||
$considerPostBeforeRegistering = ( $considerPostBeforeRegistering and \IPS\Settings::i()->post_before_registering and \IPS\Login::registrationType() != 'disabled' );
|
||||
$considerPostBeforeRegistering = ( $considerPostBeforeRegistering and \IPS\Settings::i()->post_before_registering
|
||||
and \IPS\Login::registrationType() != 'disabled' and \IPS\Settings::i()->bot_antispam_type !== 'none' );
|
||||
if ( !$member->member_id and $considerPostBeforeRegistering )
|
||||
{
|
||||
$groupsToCheck[] = \IPS\Settings::i()->member_group;
|
||||
@@ -2429,7 +2481,8 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$relevantPermissionArray = array_filter( explode( ',', $relevantPermissionString ) );
|
||||
|
||||
/* Work out which to use taking Post Before Registering into consideration and return */
|
||||
$considerPostBeforeRegistering = ( $considerPostBeforeRegistering and \IPS\Settings::i()->post_before_registering and \IPS\Login::registrationType() != 'disabled' );
|
||||
$considerPostBeforeRegistering = ( $considerPostBeforeRegistering and Settings::i()->post_before_registering
|
||||
and Login::registrationType() != 'disabled' and Settings::i()->bot_antispam_type !== 'none' );
|
||||
if( $member instanceof \IPS\Member\Group )
|
||||
{
|
||||
if ( $considerPostBeforeRegistering and $member->g_id == \IPS\Settings::i()->guest_group )
|
||||
@@ -2581,9 +2634,10 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
/* Number of comments is less than */
|
||||
if ( isset( $data['additional']['num_comments'] ) AND $data['additional']['num_comments'] > 0 )
|
||||
if ( isset( $data['additional']['num_comments'] ) AND $data['additional']['num_comments'] >= 0 )
|
||||
{
|
||||
$where[] = array( $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnMap['num_comments'].'<=?', $data['additional']['num_comments'] );
|
||||
$number = $contentItemClass::$firstCommentRequired ? $data['additional']['num_comments'] +1 : $data['additional']['num_comments'];
|
||||
$where[] = array( $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnMap['num_comments'].'<=?', $number );
|
||||
}
|
||||
|
||||
/* Last post was before */
|
||||
@@ -2683,7 +2737,14 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
if ( !isset( static::$contentItemClass ) )
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we have delayed counts, don't slam the write server now, we'll handle it later */
|
||||
iF( \IPS\IPS::classUsesTrait( $this, 'IPS\Node\DelayedCount' ) )
|
||||
{
|
||||
$this->storeUpdateTime();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update container */
|
||||
@@ -2774,7 +2835,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
}
|
||||
|
||||
$this->_comments = (int) \IPS\Db::i()->select( "SUM({$itemClass::$databasePrefix}{$itemClass::$databaseColumnMap['num_comments']})", $itemClass::$databaseTable, $commentWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$this->_comments = (int) \IPS\Db::i()->select( "SUM({$itemClass::$databasePrefix}{$itemClass::$databaseColumnMap['num_comments']})", $itemClass::$databaseTable, $commentWhere )->first();
|
||||
}
|
||||
|
||||
if ( $this->_reviews !== NULL AND $reviewClass !== NULL )
|
||||
@@ -2796,7 +2857,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$this->_reviews = \IPS\Db::i()->select( 'COUNT(*)', array(
|
||||
array( $reviewClass::$databaseTable, $reviewClass::$databaseTable ),
|
||||
array( $itemClass::$databaseTable, $itemClass::$databaseTable )
|
||||
), $reviewWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
), $reviewWhere )->first();
|
||||
}
|
||||
|
||||
if ( \in_array( 'IPS\Content\Hideable', class_implements( $itemClass ) ) )
|
||||
@@ -2844,7 +2905,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$this->_unapprovedComments = \IPS\Db::i()->select( 'COUNT(*)', array(
|
||||
array( $commentClass::$databaseTable, $commentClass::$databaseTable ),
|
||||
array( $itemClass::$databaseTable, $itemClass::$databaseTable )
|
||||
), $commentWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
), $commentWhere )->first();
|
||||
}
|
||||
/* If we have a cached value, use that instead */
|
||||
elseif( $this->_unapprovedComments !== NULL AND isset( $itemClass::$databaseColumnMap['unapproved_comments'] ) )
|
||||
@@ -2865,7 +2926,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
}
|
||||
|
||||
$this->_unapprovedComments = (int) \IPS\Db::i()->select( "SUM({$itemClass::$databasePrefix}{$itemClass::$databaseColumnMap['unapproved_comments']})", $itemClass::$databaseTable, $commentWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$this->_unapprovedComments = (int) \IPS\Db::i()->select( "SUM({$itemClass::$databasePrefix}{$itemClass::$databaseColumnMap['unapproved_comments']})", $itemClass::$databaseTable, $commentWhere )->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2888,7 +2949,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$this->_unapprovedReviews = \IPS\Db::i()->select( 'COUNT(*)', array(
|
||||
array( $reviewClass::$databaseTable, $reviewClass::$databaseTable ),
|
||||
array( $itemClass::$databaseTable, $itemClass::$databaseTable )
|
||||
), $reviewWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
), $reviewWhere )->first();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3901,4 +3962,4 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,9 @@
|
||||
namespace IPS\Node;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use Exception;
|
||||
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
@@ -233,11 +236,11 @@ trait Statistics
|
||||
$commentItemField = $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'];
|
||||
$authorColumn = $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['author'];
|
||||
$where = array();
|
||||
$memberIds = array();
|
||||
|
||||
$deleteWhere = array( array( \IPS\Db::i()->in( 'map_item_id', $inSet ) ) );
|
||||
if ( \count( $members ) )
|
||||
{
|
||||
$memberIds = array();
|
||||
foreach ( $members as $member )
|
||||
{
|
||||
$memberIds[] = $member->member_id;
|
||||
@@ -272,6 +275,12 @@ trait Statistics
|
||||
\IPS\Db::i()->replace( 'core_item_member_map', $insertFromSelect, TRUE );
|
||||
}
|
||||
|
||||
/* If forums are being used for Pages comments, we don't want to look at those */
|
||||
if( mb_substr( $commentClass, 0, 32 ) === 'IPS\\cms\\Records\\CommentTopicSync' )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do the comments */
|
||||
if ( isset( $commentClass::$databaseColumnMap['approved'] ) )
|
||||
{
|
||||
@@ -291,8 +300,37 @@ trait Statistics
|
||||
|
||||
$where[] = array(\IPS\Db::i()->in( $commentItemField, $inSet ));
|
||||
|
||||
$insertFromSelect = \IPS\Db::i()->select( "DISTINCT `{$authorColumn}`, `{$commentItemField}`, UNIX_TIMESTAMP(), '" . str_replace( '\\', '\\\\', $contentItemClass ) . "'", $commentClass::$databaseTable, $where );
|
||||
\IPS\Db::i()->replace( 'core_item_member_map', [ 'map_member_id, map_item_id, map_latest_date, map_class', $insertFromSelect ], TRUE );
|
||||
try
|
||||
{
|
||||
$seen = array();
|
||||
|
||||
/* If we don't have member(s) in the where clause, or we have a lot of member ids in the where clause, we can't do individual inserts as this could be 10,000+ inserts on very large topics */
|
||||
if ( ! count( $memberIds ) or ( count( $memberIds ) > 100 ) )
|
||||
{
|
||||
$insertFromSelect = \IPS\Db::i()->select( "DISTINCT `{$authorColumn}`, `{$commentItemField}`, UNIX_TIMESTAMP(), '" . str_replace( '\\', '\\\\', $contentItemClass ) . "'", $commentClass::$databaseTable, $where );
|
||||
\IPS\Db::i()->replace( 'core_item_member_map', [ 'map_member_id, map_item_id, map_latest_date, map_class', $insertFromSelect ], TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( "DISTINCT `{$authorColumn}` as {$authorColumn}, `{$commentItemField}`", $commentClass::$databaseTable, $where ) as $row )
|
||||
{
|
||||
$key = $row[ $authorColumn ] . '_' . $row[ $commentItemField ];
|
||||
if ( isset( $seen[ $key ] ) or ! $row[ $authorColumn ] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$seen[ $key ] = true;
|
||||
|
||||
\IPS\Db::i()->insert( 'core_item_member_map', [
|
||||
'map_member_id' => $row[ $authorColumn ],
|
||||
'map_item_id' => $row[ $commentItemField ],
|
||||
'map_latest_date' => time(),
|
||||
'map_class' => $contentItemClass
|
||||
] );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Exception ) { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user