Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,10 +2,10 @@
/**
* @brief topSubmitters Widget
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage downloads
* @package IPS Community Suite
* @subpackage Downloads
* @since 09 Jan 2014
* @version SVN_VERSION_NUMBER
*/
@@ -39,6 +39,18 @@ class _topSubmitters extends \IPS\Widget\PermissionCache
*/
public $plugin = '';
/**
* Init the widget
*
* @return void
*/
public function init()
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'downloads', 'front' ) );
parent::init();
}
/**
* Specify widget configuration
*
@@ -65,14 +77,43 @@ class _topSubmitters extends \IPS\Widget\PermissionCache
{
foreach ( array( 'week' => 'P1W', 'month' => 'P1M', 'year' => 'P1Y', 'all' => NULL ) as $time => $interval )
{
$select = \IPS\Db::i()->select( 'core_members.*, downloads_files.file_submitter, COUNT(*) AS files, AVG(file_rating) as rating', 'downloads_files', $interval ? array( 'file_submitted>? and file_submitter != ? and file_rating > ?', \IPS\DateTime::create()->sub( new \DateInterval( $interval ) )->getTimestamp(), 0, 0 ) : array( 'file_submitter != ? and file_rating > ?', 0, 0 ), 'files DESC', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, 'file_submitter' )->join( 'core_members', 'downloads_files.file_submitter=core_members.member_id' );
${$time} = array();
foreach( $select as $key => $values )
/* What's the time period we care about? */
$intervalWhere = NULL;
if ( $interval )
{
${$time}[$key]['member'] = \IPS\Member::constructFromData( $values );
${$time}[$key]['files'] = $values['files'];
${$time}[$key]['rating'] = $values['rating'];
$intervalWhere = array( 'file_submitted>?', \IPS\DateTime::create()->sub( new \DateInterval( $interval ) )->getTimestamp() );
}
/* Get the submitters ordered by their rating */
$where = array( array( 'file_submitter != ? and file_rating > ?', 0, 0 ) );
if ( $interval )
{
$where[] = $intervalWhere;
}
$ratings = iterator_to_array( \IPS\Db::i()->select(
'downloads_files.file_submitter, AVG(file_rating) as rating, COUNT(file_id) AS files',
'downloads_files',
$where,
'files DESC, rating DESC',
isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, 'file_submitter'
)->setKeyField('file_submitter')->setValueField('rating') );
/* Get their file counts */
$where = array( array( \IPS\Db::i()->in( 'file_submitter', array_keys( $ratings ) ) ) );
if ( $interval )
{
$where[] = $intervalWhere;
}
$fileCounts = iterator_to_array( \IPS\Db::i()->select( 'file_submitter, COUNT(*) AS count', 'downloads_files', $where, NULL, NULL, 'file_submitter' )->setKeyField('file_submitter')->setValueField('count') );
/* Get member data and put it together */
${$time} = array();
foreach( \IPS\Db::i()->select( '*', 'core_members', \IPS\Db::i()->in( 'member_id', array_keys( $ratings ) ) ) as $key => $memberData )
{
${$time}[$key]['member'] = \IPS\Member::constructFromData( $memberData );
${$time}[$key]['files'] = isset( $fileCounts[ $memberData['member_id'] ] ) ? $fileCounts[ $memberData['member_id'] ] : 0;
${$time}[$key]['rating'] = $ratings[ $memberData['member_id'] ];
}
}