Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -12,7 +12,7 @@
namespace IPS\downloads\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -58,10 +58,7 @@ class _topSubmitters extends \IPS\Widget\PermissionCache
*/
public function configuration( &$form=null )
{
if ( $form === null )
{
$form = new \IPS\Helpers\Form;
}
$form = parent::configuration( $form );
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE ) );
return $form;
@@ -90,29 +87,33 @@ class _topSubmitters extends \IPS\Widget\PermissionCache
$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.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 )
if( \count( $ratings ) )
{
${$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'] ];
/* 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 */
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'] ];
}
}
}