Version 4.7.6

This commit is contained in:
Neo committed 2025-12-19 16:05:19 -08:00
1 parent 8ba7d43898
commit 7b7404e741
1085 files changed
+30590 -7837

No files matched your search

+52
View File
@@ -116,6 +116,58 @@ trait Statistics
return $return;
}
/**
* Most Recent Participans
*
* @param string|NULL $name If we are looking for a specific user.
* @param int $limit The amount of results to return.
* @return \IPS\Patterns\ActiveRecordIterator
*/
public function mostRecent( ?string $name = NULL, int $limit = 10 )
{
$commentClass = static::$commentClass;
if ( !isset( $commentClass::$databaseColumnMap['author'] ) )
{
throw new \BadMethodCallException;
}
if ( $name )
{
$cacheKey = 'mostRecent_' . $limit . '_' . $name;
}
else
{
$cacheKey = 'mostRecent_' . $limit;
}
try
{
$members = $this->_getCached( $cacheKey );
}
catch( \OutOfRangeException $e )
{
/* Get the ten most recent posters in this content that match input. */
$where = $this->_getVisibleWhere();
if ( $name )
{
$subQuery = \IPS\Db::i()->select( 'core_members.member_id', 'core_members', \IPS\Db::i()->like( 'core_members.name', $name ) );
$where[] = [ $commentClass::$databaseTable . '.' . $commentClass::$databaseColumnMap['author'] . ' IN(?)', $subQuery ];
}
$members = iterator_to_array( \IPS\Db::i()->select(
$commentClass::$databaseColumnMap['author'],
$commentClass::$databaseTable,
$where,
NULL,
$limit ) );
$this->_storeCached( $cacheKey, $members );
}
return new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $members ) ) ), 'IPS\Member' );
}
/**
* Members with most posts