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 downloadStats 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
*/
@@ -1,46 +1,63 @@
<?php
/**
* @brief downloadsCommentFeed Widget
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @subpackage Downloads
* @since 13 Jul 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* downloadsCommentFeed Widget
*/
class _downloadsCommentFeed extends \IPS\Content\WidgetComment
{
/**
* @brief downloadsCommentFeed Widget
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage blog
* @since 13 Jul 2015
* @version SVN_VERSION_NUMBER
* @brief Widget Key
*/
public $key = 'downloadsCommentFeed';
namespace IPS\downloads\widgets;
/**
* @brief App
*/
public $app = 'downloads';
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
/**
* @brief Plugin
*/
public $plugin = '';
/**
* Class
*/
protected static $class = 'IPS\downloads\File\Comment';
/**
* @brief Moderator permission to generate caches on [optional]
*/
protected $moderatorPermissions = array( 'can_view_hidden_content', 'can_view_hidden_downloads_file_comment' );
/**
* Init the widget
*
* @return void
*/
public function init()
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'downloads', 'front' ) );
parent::init();
}
/**
* downloadsCommentFeed Widget
*/
class _downloadsCommentFeed extends \IPS\Content\WidgetComment
{
/**
* @brief Widget Key
*/
public $key = 'downloadsCommentFeed';
/**
* @brief App
*/
public $app = 'downloads';
/**
* @brief Plugin
*/
public $plugin = '';
/**
* Class
*/
protected static $class = 'IPS\downloads\File\Comment';
}
}
@@ -2,10 +2,10 @@
/**
* @brief downloadsReviewFeed 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 blog
* @package IPS Community Suite
* @subpackage Downloads
* @since 13 Jul 2015
* @version SVN_VERSION_NUMBER
*/
@@ -43,4 +43,21 @@ class _downloadsReviewFeed extends \IPS\Content\WidgetComment
* Class
*/
protected static $class = 'IPS\downloads\File\Review';
/**
* @brief Moderator permission to generate caches on [optional]
*/
protected $moderatorPermissions = array( 'can_view_hidden_content', 'can_view_hidden_downloads_file_review' );
/**
* 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();
}
}
+67 -3
View File
@@ -2,10 +2,10 @@
/**
* @brief Files Feed 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 forums
* @package IPS Community Suite
* @subpackage Downloads
* @since 22 Jun 2015
* @version SVN_VERSION_NUMBER
*/
@@ -43,4 +43,68 @@ class _fileFeed extends \IPS\Content\Widget
* Class
*/
protected static $class = 'IPS\downloads\File';
/**
* 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
*
* @param null|\IPS\Helpers\Form $form Form object
* @return null|\IPS\Helpers\Form
*/
public function configuration( &$form=null )
{
$form = parent::configuration( $form );
if ( \IPS\Application::appIsEnabled( 'nexus' ) and \IPS\Settings::i()->idm_nexus_on )
{
$options = array(
'free' => 'file_free',
'paid' => 'file_paid',
'any' => 'any'
);
$form->add( new \IPS\Helpers\Form\Radio( 'file_cost_type', isset( $this->configuration['file_cost_type'] ) ? $this->configuration['file_cost_type'] : 'any', TRUE, array( 'options' => $options ) ) );
}
return $form;
}
/**
* Get where clause
*
* @return array
*/
protected function buildWhere()
{
$where = parent::buildWhere();
if ( \IPS\Application::appIsEnabled( 'nexus' ) and \IPS\Settings::i()->idm_nexus_on )
{
if( isset( $this->configuration['file_cost_type'] ) )
{
switch( $this->configuration['file_cost_type'] )
{
case 'free':
$where[] = array( "( ( file_cost='' OR file_cost IS NULL ) AND ( file_nexus='' OR file_nexus IS NULL ) )" );
break;
case 'paid':
$where[] = array( "( file_cost<>'' OR file_nexus>0 )" );
break;
}
}
}
return $where;
}
}
+40 -16
View File
@@ -2,10 +2,10 @@
/**
* @brief topDownloads 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
*/
@@ -45,6 +45,18 @@ class _topDownloads extends \IPS\Widget\PermissionCache
*/
public $cacheExpiration = 172800;
/**
* 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
*
@@ -89,19 +101,31 @@ class _topDownloads extends \IPS\Widget\PermissionCache
$where[] = array( 'dtime>?', \IPS\DateTime::create()->sub( new \DateInterval( $interval ) )->getTimestamp() );
}
$$time = new \IPS\Patterns\ActiveRecordIterator(
\IPS\Db::i()->select(
'*, COUNT(*) AS downloads',
'downloads_files',
$where,
'downloads DESC',
isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5,
'file_id'
)
->join( 'downloads_downloads', 'dfid=file_id' ),
'IPS\downloads\File'
);
$ids = array();
$cases = array();
foreach( \IPS\Db::i()->select( 'dfid, COUNT(*) AS downloads', 'downloads_downloads', $where, 'downloads DESC', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, array( 'dfid' ) )->join( 'downloads_files', 'dfid=file_id' ) as $download )
{
$ids[] = $download['dfid'];
$cases[] = "WHEN file_id={$download['dfid']} THEN {$download['downloads']}";
}
if( count( $ids ) )
{
$$time = new \IPS\Patterns\ActiveRecordIterator(
\IPS\Db::i()->select(
'*, CASE ' . implode( ' ', $cases ) . ' END AS file_downloads',
'downloads_files',
'file_id IN(' . implode( ',', $ids ) . ')',
'file_downloads DESC'
),
'IPS\downloads\File'
);
}
else
{
$$time = array();
}
}
return $this->output( $week, $month, $year, $all );
@@ -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'] ];
}
}