Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Categories
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
@@ -12,35 +13,50 @@
|
||||
namespace IPS\downloads\modules\admin\downloads;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\downloads\Category;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories
|
||||
*/
|
||||
class _categories extends \IPS\Node\Controller
|
||||
class categories extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\downloads\Category';
|
||||
protected string $nodeClass = 'IPS\downloads\Category';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'categories_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'categories_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -49,23 +65,23 @@ class _categories extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function recountDownloads()
|
||||
protected function recountDownloads() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'categories_recount_downloads' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'categories_recount_downloads' );
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$category = \IPS\downloads\Category::load( \IPS\Request::i()->id );
|
||||
$category = Category::load( Request::i()->id );
|
||||
|
||||
\IPS\Db::i()->update( 'downloads_files', array( 'file_downloads' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_downloads', array( 'dfid=file_id' ) ) ), array( 'file_cat=?', $category->id ) );
|
||||
\IPS\Session::i()->log( 'acplogs__downloads_recount_downloads', array( $category->_title => FALSE ) );
|
||||
Db::i()->update( 'downloads_files', array( 'file_downloads' => Db::i()->select( 'COUNT(*)', 'downloads_downloads', array( 'dfid=file_id' ) ) ), array( 'file_cat=?', $category->id ) );
|
||||
Session::i()->log( 'acplogs__downloads_recount_downloads', array( $category->_title => FALSE ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=downloads&module=downloads&controller=categories&do=form&id=" . \IPS\Request::i()->id ), 'clog_recount_done' );
|
||||
Output::i()->redirect( Url::internal( "app=downloads&module=downloads&controller=categories&do=form&id=" . Request::i()->id ), 'clog_recount_done' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2D180/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2D180/1', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,17 +90,17 @@ class _categories extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function form()
|
||||
protected function form() : void
|
||||
{
|
||||
parent::form();
|
||||
|
||||
if ( \IPS\Request::i()->id )
|
||||
if ( Request::i()->id )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('edit_category') . ': ' . \IPS\Output::i()->title;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('edit_category') . ': ' . Output::i()->title;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('add_category');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('add_category');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,13 +109,15 @@ class _categories extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rebuildTopicContent()
|
||||
public function rebuildTopicContent() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
$class = $this->nodeClass;
|
||||
\IPS\Task::queue( 'core', 'ResyncTopicContent', array( 'class' => $class, 'categoryId' => \IPS\Request::i()->id ), 3, array( 'categoryId' ) );
|
||||
\IPS\Session::i()->log( 'acplogs__downloads_resync_topics', array( $class::$titleLangPrefix . \IPS\Request::i()->id => TRUE ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=categories&do=form&id=' . \IPS\Request::i()->id ), \IPS\Member::loggedIn()->language()->addToStack('rebuilding_stuff', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'category_forums_integration' ) ) ) ) );
|
||||
Task::queue( 'core', 'ResyncTopicContent', array( 'class' => $class, 'categoryId' => Request::i()->id ), 3, array( 'categoryId' ) );
|
||||
|
||||
/* @var Model $class */
|
||||
Session::i()->log( 'acplogs__downloads_resync_topics', array( $class::$titleLangPrefix . Request::i()->id => TRUE ) );
|
||||
Output::i()->redirect( Url::internal( 'app=downloads&module=downloads&controller=categories&do=form&id=' . Request::i()->id ), Member::loggedIn()->language()->addToStack('rebuilding_stuff', FALSE, array( 'sprintf' => array( Member::loggedIn()->language()->addToStack( 'category_forums_integration' ) ) ) ) );
|
||||
}
|
||||
}
|
||||
@@ -12,35 +12,40 @@
|
||||
namespace IPS\downloads\modules\admin\downloads;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Node\Controller;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* fields
|
||||
*/
|
||||
class _fields extends \IPS\Node\Controller
|
||||
class fields extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\downloads\Field';
|
||||
protected string $nodeClass = 'IPS\downloads\Field';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'fields_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'fields_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
}
|
||||
@@ -12,113 +12,127 @@
|
||||
namespace IPS\downloads\modules\admin\downloads;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Stack;
|
||||
use IPS\Helpers\Form\Upload;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Form\Money;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings as SettingsClass;
|
||||
use IPS\Task;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*/
|
||||
class _settings extends \IPS\Dispatcher\Controller
|
||||
class settings extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Manage Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
|
||||
$form = $this->_getForm();
|
||||
|
||||
if ( $values = $form->values( TRUE ) )
|
||||
if ( $values = $form->values(TRUE) )
|
||||
{
|
||||
$this->_saveSettingsForm( $form, $values, $redirectMessage );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__downloads_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=settings' ), $redirectMessage );
|
||||
Session::i()->log( 'acplogs__downloads_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=downloads&module=downloads&controller=settings' ), $redirectMessage );
|
||||
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('settings');
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and return the settings form
|
||||
*
|
||||
* @note Abstracted to allow third party devs to extend easier
|
||||
* @return \IPS\Helpers\Form
|
||||
* @return Form
|
||||
*/
|
||||
protected function _getForm()
|
||||
protected function _getForm(): Form
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_settings.js', 'downloads', 'admin' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_settings.js', 'downloads', 'admin' ) );
|
||||
$form->attributes['data-controller'] = 'downloads.admin.settings.settings';
|
||||
$form->hiddenValues['rebuildWatermarkScreenshots'] = \IPS\Request::i()->rebuildWatermarkScreenshots ?: 0;
|
||||
$form->hiddenValues['rebuildWatermarkScreenshots'] = Request::i()->rebuildWatermarkScreenshots ?: 0;
|
||||
|
||||
$form->addTab( 'idm_landing_page' );
|
||||
$form->addHeader( 'featured_downloads' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_featured', \IPS\Settings::i()->idm_show_featured, FALSE, array( 'togglesOn' => array( 'idm_featured_count' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'idm_featured_count', \IPS\Settings::i()->idm_featured_count, FALSE, array(), NULL, NULL, NULL, 'idm_featured_count' ) );
|
||||
$form->add( new YesNo( 'idm_show_featured', SettingsClass::i()->idm_show_featured, FALSE, array( 'togglesOn' => array( 'idm_featured_count' ) ) ) );
|
||||
$form->add( new Number( 'idm_featured_count', SettingsClass::i()->idm_featured_count, FALSE, array(), NULL, NULL, NULL, 'idm_featured_count' ) );
|
||||
|
||||
$form->addHeader('browse_whats_new');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_newest', \IPS\Settings::i()->idm_show_newest, FALSE, array('togglesOn' => array( 'idm_newest_categories') ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'idm_newest_categories', ( \IPS\Settings::i()->idm_newest_categories AND \IPS\Settings::i()->idm_newest_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_newest_categories ) : 0, FALSE, array(
|
||||
$form->add( new YesNo( 'idm_show_newest', SettingsClass::i()->idm_show_newest, FALSE, array('togglesOn' => array( 'idm_newest_categories') ) ) );
|
||||
$form->add( new Node( 'idm_newest_categories', ( SettingsClass::i()->idm_newest_categories AND SettingsClass::i()->idm_newest_categories != 0 ) ? explode( ',', SettingsClass::i()->idm_newest_categories ) : 0, FALSE, array(
|
||||
'class' => 'IPS\downloads\Category',
|
||||
'zeroVal' => 'any',
|
||||
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_newest_categories') );
|
||||
|
||||
$form->addHeader('browse_highest_rated');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_highest_rated', \IPS\Settings::i()->idm_show_highest_rated, FALSE, array( 'togglesOn' => array( 'idm_highest_rated_categories' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'idm_highest_rated_categories', ( \IPS\Settings::i()->idm_highest_rated_categories AND \IPS\Settings::i()->idm_highest_rated_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_highest_rated_categories ) : 0, FALSE, array(
|
||||
$form->add( new YesNo( 'idm_show_highest_rated', SettingsClass::i()->idm_show_highest_rated, FALSE, array( 'togglesOn' => array( 'idm_highest_rated_categories' ) ) ) );
|
||||
$form->add( new Node( 'idm_highest_rated_categories', ( SettingsClass::i()->idm_highest_rated_categories AND SettingsClass::i()->idm_highest_rated_categories != 0 ) ? explode( ',', SettingsClass::i()->idm_highest_rated_categories ) : 0, FALSE, array(
|
||||
'class' => 'IPS\downloads\Category',
|
||||
'zeroVal' => 'any',
|
||||
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_highest_rated_categories') );
|
||||
|
||||
$form->addHeader('browse_most_downloaded');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_most_downloaded', \IPS\Settings::i()->idm_show_most_downloaded, FALSE, array( 'togglesOn' => array( 'idm_show_most_downloaded_categories' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'idm_show_most_downloaded_categories', ( \IPS\Settings::i()->idm_show_most_downloaded_categories AND \IPS\Settings::i()->idm_show_most_downloaded_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_show_most_downloaded_categories ) : 0, FALSE, array(
|
||||
$form->add( new YesNo( 'idm_show_most_downloaded', SettingsClass::i()->idm_show_most_downloaded, FALSE, array( 'togglesOn' => array( 'idm_show_most_downloaded_categories' ) ) ) );
|
||||
$form->add( new Node( 'idm_show_most_downloaded_categories', ( SettingsClass::i()->idm_show_most_downloaded_categories AND SettingsClass::i()->idm_show_most_downloaded_categories != 0 ) ? explode( ',', SettingsClass::i()->idm_show_most_downloaded_categories ) : 0, FALSE, array(
|
||||
'class' => 'IPS\downloads\Category',
|
||||
'zeroVal' => 'any',
|
||||
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_show_most_downloaded_categories') );
|
||||
|
||||
|
||||
$form->addTab( 'basic_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'idm_watermarkpath', \IPS\Settings::i()->idm_watermarkpath ? \IPS\File::get( 'core_Theme', \IPS\Settings::i()->idm_watermarkpath ) : NULL, FALSE, array( 'image' => TRUE, 'storageExtension' => 'core_Theme' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'idm_link_blacklist', explode( ',', \IPS\Settings::i()->idm_link_blacklist ), FALSE, array( 'placeholder' => 'example.com' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_antileech', \IPS\Settings::i()->idm_antileech ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_rss', \IPS\Settings::i()->idm_rss ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'idm_default_view', \IPS\Settings::i()->idm_default_view, FALSE, array(
|
||||
'options' => array(
|
||||
'table' => 'downloads_default_view_table',
|
||||
'grid' => 'downloads_default_view_grid',
|
||||
),
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_default_view_choose', \IPS\Settings::i()->idm_default_view_choose ) );
|
||||
$form->add( new Upload( 'idm_watermarkpath', SettingsClass::i()->idm_watermarkpath ? File::get( 'core_Theme', SettingsClass::i()->idm_watermarkpath ) : NULL, FALSE, array( 'image' => TRUE, 'storageExtension' => 'core_Theme' ) ) );
|
||||
$form->add( new Stack( 'idm_link_blacklist', explode( ',', SettingsClass::i()->idm_link_blacklist ), FALSE, array( 'placeholder' => 'example.com' ) ) );
|
||||
$form->add( new YesNo( 'idm_antileech', SettingsClass::i()->idm_antileech ) );
|
||||
$form->add( new YesNo( 'idm_rss', SettingsClass::i()->idm_rss ) );
|
||||
|
||||
if ( \IPS\Application::appIsEnabled( 'nexus' ) )
|
||||
if ( Application::appIsEnabled( 'nexus' ) )
|
||||
{
|
||||
$form->addTab( 'paid_file_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_nexus_on', \IPS\Settings::i()->idm_nexus_on, FALSE, array( 'togglesOn' => array( 'idm_nexus_tax', 'idm_nexus_percent', 'idm_nexus_transfee', 'idm_nexus_mincost', 'idm_nexus_gateways', 'idm_nexus_display' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'idm_nexus_tax', \IPS\Settings::i()->idm_nexus_tax ?:0, FALSE, array( 'class' => '\IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'idm_nexus_tax' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'idm_nexus_percent', \IPS\Settings::i()->idm_nexus_percent, FALSE, array( 'min' => 0, 'max' => 100 ), NULL, NULL, '%', 'idm_nexus_percent' ) );
|
||||
$form->add( new \IPS\nexus\Form\Money( 'idm_nexus_transfee', json_decode( \IPS\Settings::i()->idm_nexus_transfee, TRUE ), FALSE, array(), NULL, NULL, NULL, 'idm_nexus_transfee' ) );
|
||||
$form->add( new \IPS\nexus\Form\Money( 'idm_nexus_mincost', json_decode( \IPS\Settings::i()->idm_nexus_mincost, TRUE ), FALSE, array(), NULL, NULL, NULL, 'idm_nexus_mincost' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'idm_nexus_gateways', ( \IPS\Settings::i()->idm_nexus_gateways ) ? explode( ',', \IPS\Settings::i()->idm_nexus_gateways ) : 0, FALSE, array( 'class' => '\IPS\nexus\Gateway', 'zeroVal' => 'no_restriction', 'multiple' => TRUE ), NULL, NULL, NULL, 'idm_nexus_gateways' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'idm_nexus_display', explode( ',', \IPS\Settings::i()->idm_nexus_display ), FALSE, array( 'options' => array( 'purchases' => 'idm_purchases', 'downloads' => 'downloads' ) ), NULL, NULL, NULL, 'idm_nexus_display' ) );
|
||||
$form->add( new YesNo( 'idm_nexus_on', SettingsClass::i()->idm_nexus_on, FALSE, array( 'togglesOn' => array( 'idm_nexus_tax', 'idm_nexus_percent', 'idm_nexus_transfee', 'idm_nexus_mincost', 'idm_nexus_gateways', 'idm_nexus_display' ) ) ) );
|
||||
$form->add( new Node( 'idm_nexus_tax', SettingsClass::i()->idm_nexus_tax ?:0, FALSE, array( 'class' => '\IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'idm_nexus_tax' ) );
|
||||
$form->add( new Number( 'idm_nexus_percent', SettingsClass::i()->idm_nexus_percent, FALSE, array( 'min' => 0, 'max' => 100 ), NULL, NULL, '%', 'idm_nexus_percent' ) );
|
||||
$form->add( new Money( 'idm_nexus_transfee', json_decode( SettingsClass::i()->idm_nexus_transfee, TRUE ), FALSE, array(), NULL, NULL, NULL, 'idm_nexus_transfee' ) );
|
||||
$form->add( new Money( 'idm_nexus_mincost', json_decode( SettingsClass::i()->idm_nexus_mincost, TRUE ), FALSE, array(), NULL, NULL, NULL, 'idm_nexus_mincost' ) );
|
||||
$form->add( new Node( 'idm_nexus_gateways', ( SettingsClass::i()->idm_nexus_gateways ) ? explode( ',', SettingsClass::i()->idm_nexus_gateways ) : 0, FALSE, array( 'class' => '\IPS\nexus\Gateway', 'zeroVal' => 'no_restriction', 'multiple' => TRUE ), NULL, NULL, NULL, 'idm_nexus_gateways' ) );
|
||||
$form->add( new CheckboxSet( 'idm_nexus_display', explode( ',', SettingsClass::i()->idm_nexus_display ), FALSE, array( 'options' => array( 'purchases' => 'idm_purchases', 'downloads' => 'downloads' ) ), NULL, NULL, NULL, 'idm_nexus_display' ) );
|
||||
}
|
||||
|
||||
return $form;
|
||||
@@ -127,14 +141,15 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Save the settings form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The Form Object
|
||||
* @param array $values Values
|
||||
* @param string $redirectMessage Message to show on redirect
|
||||
* @param Form $form The Form Object
|
||||
* @param array $values Values
|
||||
* @param string|null $redirectMessage
|
||||
* @return void
|
||||
*/
|
||||
protected function _saveSettingsForm( \IPS\Helpers\Form $form, array $values, ?string &$redirectMessage )
|
||||
protected function _saveSettingsForm( Form $form, array $values, ?string &$redirectMessage ) : void
|
||||
{
|
||||
/* We can't store '' for idm_nexus_display as it will fall back to the default */
|
||||
if ( \IPS\Application::appIsEnabled( 'nexus' ) and !$values['idm_nexus_display'] )
|
||||
if ( Application::appIsEnabled( 'nexus' ) and !$values['idm_nexus_display'] )
|
||||
{
|
||||
$values['idm_nexus_display'] = 'none';
|
||||
}
|
||||
@@ -148,9 +163,9 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
/* Save the form first, then queue the rebuild */
|
||||
if( $rebuildScreenshots )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_queue', array( '`app`=? OR `key`=?', 'downloads', 'RebuildScreenshotWatermarks' ) );
|
||||
Db::i()->delete( 'core_queue', array( '`app`=? OR `key`=?', 'downloads', 'RebuildScreenshotWatermarks' ) );
|
||||
|
||||
\IPS\Task::queue( 'downloads', 'RebuildScreenshotWatermarks', array( ), 5 );
|
||||
Task::queue( 'downloads', 'RebuildScreenshotWatermarks', array( ), 5 );
|
||||
$redirectMessage = 'download_settings_saved_rebuilding';
|
||||
}
|
||||
else
|
||||
|
||||
@@ -12,26 +12,43 @@
|
||||
namespace IPS\downloads\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\DateRange;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function intval;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Top Downloaders
|
||||
*/
|
||||
class _downloaders extends \IPS\Dispatcher\Controller
|
||||
class downloaders extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Number of results per page
|
||||
@@ -43,9 +60,9 @@ class _downloaders extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'downloaders_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'downloaders_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -54,32 +71,32 @@ class _downloaders extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$where = array( array( 'dmid>0' ) );
|
||||
|
||||
if ( isset( \IPS\Request::i()->form ) )
|
||||
if ( isset( Request::i()->form ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', 'go' );
|
||||
$form = new Form( 'form', 'go' );
|
||||
|
||||
$default = array(
|
||||
'start' => \IPS\Request::i()->start ? \IPS\DateTime::ts( \IPS\Request::i()->start ) : NULL,
|
||||
'end' => \IPS\Request::i()->end ? \IPS\DateTime::ts( \IPS\Request::i()->end ) : NULL
|
||||
'start' => Request::i()->start ? DateTime::ts( Request::i()->start ) : NULL,
|
||||
'end' => Request::i()->end ? DateTime::ts( Request::i()->end ) : NULL
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
|
||||
$form->add( new DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
|
||||
|
||||
if ( !$values = $form->values() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Figure out start and end parameters for links */
|
||||
$params = array(
|
||||
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : \IPS\Request::i()->start,
|
||||
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : \IPS\Request::i()->end
|
||||
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : Request::i()->start,
|
||||
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : Request::i()->end
|
||||
);
|
||||
|
||||
if( $params['start'] )
|
||||
@@ -92,7 +109,7 @@ class _downloaders extends \IPS\Dispatcher\Controller
|
||||
$where[] = array( 'dtime<?', $params['end'] );
|
||||
}
|
||||
|
||||
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
|
||||
$page = isset( Request::i()->page ) ? intval( Request::i()->page ) : 1;
|
||||
|
||||
if( $page < 1 )
|
||||
{
|
||||
@@ -101,26 +118,26 @@ class _downloaders extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$total = \IPS\Db::i()->select( 'COUNT(DISTINCT(dmid))', 'downloads_downloads', $where )->first();
|
||||
$total = Db::i()->select( 'COUNT(DISTINCT(dmid))', 'downloads_downloads', $where )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException $e )
|
||||
{
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
/* Add the date range button */
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'stats_date_range',
|
||||
'icon' => 'calendar',
|
||||
'link' => \IPS\Http\Url::internal( 'app=downloads&module=stats&controller=downloaders&form=1' )->setQueryString( $params ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('stats_date_range') )
|
||||
'link' => Url::internal( 'app=downloads&module=stats&controller=downloaders&form=1' )->setQueryString( $params ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('stats_date_range') )
|
||||
)
|
||||
);
|
||||
|
||||
if( $total > 0 )
|
||||
{
|
||||
$select = \IPS\Db::i()->select( 'dmid, count(*) as downloads', 'downloads_downloads', $where, 'downloads DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'dmid' );
|
||||
$select = Db::i()->select( 'dmid, count(*) as downloads', 'downloads_downloads', $where, 'downloads DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'dmid' );
|
||||
$mids = array();
|
||||
|
||||
foreach( $select as $row )
|
||||
@@ -130,26 +147,26 @@ class _downloaders extends \IPS\Dispatcher\Controller
|
||||
|
||||
$members = array();
|
||||
|
||||
if ( \count( $mids ) )
|
||||
if ( count( $mids ) )
|
||||
{
|
||||
$members = iterator_to_array( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
|
||||
$members = iterator_to_array( Db::i()->select( '*', 'core_members', array( Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
|
||||
}
|
||||
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
\IPS\Http\Url::internal( 'app=downloads&module=stats&controller=downloaders' )->setQueryString( $params ),
|
||||
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
Url::internal( 'app=downloads&module=stats&controller=downloaders' )->setQueryString( $params ),
|
||||
ceil( $total / static::PER_PAGE ),
|
||||
$page,
|
||||
static::PER_PAGE,
|
||||
FALSE
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats')->downloadsTable( $select, $pagination, $members, $total );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__downloads_stats_downloaders');
|
||||
Output::i()->output = Theme::i()->getTemplate('stats')->downloadsTable( $select, $pagination, $members, $total );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__downloads_stats_downloaders');
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return the no results message */
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('menu__downloads_stats_downloaders'), \IPS\Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'ipsPad', NULL, TRUE );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->block( Member::loggedIn()->language()->addToStack('menu__downloads_stats_downloaders'), Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'i-padding_3', NULL, TRUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,35 +12,44 @@
|
||||
namespace IPS\downloads\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Statistics\Chart;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* downloads
|
||||
*/
|
||||
class _downloads extends \IPS\Dispatcher\Controller
|
||||
class downloads extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'downloads_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'downloads_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -49,11 +58,10 @@ class _downloads extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'downloads', 'Downloads' )->getChart( \IPS\Http\Url::internal( "app=downloads&module=stats&controller=downloads" ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('downloads_stats');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('downloads_stats');
|
||||
Output::i()->output = (string) $chart = Chart::loadFromExtension( 'downloads', 'Downloads' )->getChart( Url::internal( "app=downloads&module=stats&controller=downloads" ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,9 +12,16 @@
|
||||
namespace IPS\downloads\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -23,20 +30,20 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class _member extends \IPS\Dispatcher\Controller
|
||||
class member extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("app=core&module=members&controller=members&do=view&id=" . \IPS\Request::i()->id . "&blockKey=core_ContentStatistics&block[core_ContentStatistics]=downloads_Downloads") );
|
||||
Output::i()->redirect( Url::internal("app=core&module=members&controller=members&do=view&id=" . Request::i()->id . "&blockKey=core_ContentStatistics&block[core_ContentStatistics]=downloads_Downloads") );
|
||||
}
|
||||
}
|
||||
@@ -12,26 +12,43 @@
|
||||
namespace IPS\downloads\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\DateRange;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function intval;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Top Submitters
|
||||
*/
|
||||
class _submitters extends \IPS\Dispatcher\Controller
|
||||
class submitters extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Number of results per page
|
||||
@@ -43,9 +60,9 @@ class _submitters extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'submitters_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'submitters_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -54,32 +71,32 @@ class _submitters extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( isset( \IPS\Request::i()->form ) )
|
||||
if ( isset( Request::i()->form ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', 'go' );
|
||||
$form = new Form( 'form', 'go' );
|
||||
|
||||
$default = array(
|
||||
'start' => \IPS\Request::i()->start ? \IPS\DateTime::ts( \IPS\Request::i()->start ) : NULL,
|
||||
'end' => \IPS\Request::i()->end ? \IPS\DateTime::ts( \IPS\Request::i()->end ) : NULL
|
||||
'start' => Request::i()->start ? DateTime::ts( Request::i()->start ) : NULL,
|
||||
'end' => Request::i()->end ? DateTime::ts( Request::i()->end ) : NULL
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
|
||||
$form->add( new DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
|
||||
|
||||
if ( !$values = $form->values() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Figure out start and end parameters for links */
|
||||
$params = array(
|
||||
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : \IPS\Request::i()->start,
|
||||
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : \IPS\Request::i()->end
|
||||
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : Request::i()->start,
|
||||
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : Request::i()->end
|
||||
);
|
||||
|
||||
if( $params['start'] )
|
||||
@@ -92,7 +109,7 @@ class _submitters extends \IPS\Dispatcher\Controller
|
||||
$where[] = array( 'file_submitted<?', $params['end'] );
|
||||
}
|
||||
|
||||
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
|
||||
$page = isset( Request::i()->page ) ? intval( Request::i()->page ) : 1;
|
||||
|
||||
if( $page < 1 )
|
||||
{
|
||||
@@ -101,26 +118,26 @@ class _submitters extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$total = \IPS\Db::i()->select( 'COUNT(DISTINCT(file_submitter))', 'downloads_files', $where )->first();
|
||||
$total = Db::i()->select( 'COUNT(DISTINCT(file_submitter))', 'downloads_files', $where )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException $e )
|
||||
{
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
/* Add the date range button */
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'stats_date_range',
|
||||
'icon' => 'calendar',
|
||||
'link' => \IPS\Http\Url::internal( 'app=downloads&module=stats&controller=submitters&form=1' )->setQueryString( $params ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('stats_date_range') )
|
||||
'link' => Url::internal( 'app=downloads&module=stats&controller=submitters&form=1' )->setQueryString( $params ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('stats_date_range') )
|
||||
)
|
||||
);
|
||||
|
||||
if( $total > 0 )
|
||||
{
|
||||
$select = \IPS\Db::i()->select( 'file_submitter, count(*) as files', 'downloads_files', $where, 'files DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'file_submitter' )->join( 'core_members', 'core_members.member_id=downloads_files.file_submitter' );
|
||||
$select = Db::i()->select( 'file_submitter, count(*) as files', 'downloads_files', $where, 'files DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'file_submitter' )->join( 'core_members', 'core_members.member_id=downloads_files.file_submitter' );
|
||||
$mids = array();
|
||||
|
||||
foreach( $select as $row )
|
||||
@@ -130,27 +147,27 @@ class _submitters extends \IPS\Dispatcher\Controller
|
||||
|
||||
$members = array();
|
||||
|
||||
if ( \count( $mids ) )
|
||||
if ( count( $mids ) )
|
||||
{
|
||||
$members = iterator_to_array( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
|
||||
$members = iterator_to_array( Db::i()->select( '*', 'core_members', array( Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
|
||||
}
|
||||
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
\IPS\Http\Url::internal( 'app=downloads&module=stats&controller=submitters' )->setQueryString( $params ),
|
||||
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
Url::internal( 'app=downloads&module=stats&controller=submitters' )->setQueryString( $params ),
|
||||
ceil( $total / static::PER_PAGE ),
|
||||
$page,
|
||||
static::PER_PAGE,
|
||||
FALSE
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate('stats')->submittersTable( $select, $pagination, $members, $total );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__downloads_stats_submitters');
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
|
||||
Output::i()->output .= Theme::i()->getTemplate('stats')->submittersTable( $select, $pagination, $members, $total );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__downloads_stats_submitters');
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return the no results message */
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('menu__downloads_stats_submitters'), \IPS\Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'ipsPad', NULL, TRUE );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->block( Member::loggedIn()->language()->addToStack('menu__downloads_stats_submitters'), Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'i-padding_3', NULL, TRUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,26 +12,44 @@
|
||||
namespace IPS\downloads\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\downloads\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\DateRange;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function intval;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* topdownloads
|
||||
*/
|
||||
class _topdownloads extends \IPS\Dispatcher\Controller
|
||||
class topdownloads extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Number of results per page
|
||||
@@ -43,9 +61,9 @@ class _topdownloads extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'topdownloads_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'topdownloads_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -54,32 +72,32 @@ class _topdownloads extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( isset( \IPS\Request::i()->form ) )
|
||||
if ( isset( Request::i()->form ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', 'go' );
|
||||
$form = new Form( 'form', 'go' );
|
||||
|
||||
$default = array(
|
||||
'start' => \IPS\Request::i()->start ? \IPS\DateTime::ts( \IPS\Request::i()->start ) : NULL,
|
||||
'end' => \IPS\Request::i()->end ? \IPS\DateTime::ts( \IPS\Request::i()->end ) : NULL
|
||||
'start' => Request::i()->start ? DateTime::ts( Request::i()->start ) : NULL,
|
||||
'end' => Request::i()->end ? DateTime::ts( Request::i()->end ) : NULL
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
|
||||
$form->add( new DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
|
||||
|
||||
if ( !$values = $form->values() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Figure out start and end parameters for links */
|
||||
$params = array(
|
||||
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : \IPS\Request::i()->start,
|
||||
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : \IPS\Request::i()->end
|
||||
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : Request::i()->start,
|
||||
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : Request::i()->end
|
||||
);
|
||||
|
||||
if ( $params['start'] )
|
||||
@@ -92,7 +110,7 @@ class _topdownloads extends \IPS\Dispatcher\Controller
|
||||
$where[] = array( 'dtime<?', $params['end'] );
|
||||
}
|
||||
|
||||
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
|
||||
$page = isset( Request::i()->page ) ? intval( Request::i()->page ) : 1;
|
||||
|
||||
if ( $page < 1 )
|
||||
{
|
||||
@@ -101,57 +119,57 @@ class _topdownloads extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$total = \IPS\Db::i()->select( 'COUNT(DISTINCT(dfid))', 'downloads_downloads', $where )->first();
|
||||
$total = Db::i()->select( 'COUNT(DISTINCT(dfid))', 'downloads_downloads', $where )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException $e )
|
||||
{
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
/* Add date range selector */
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'stats_date_range',
|
||||
'icon' => 'calendar',
|
||||
'link' => \IPS\Http\Url::internal( 'app=downloads&module=stats&controller=topdownloads&form=1' )->setQueryString( $params ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack( 'stats_date_range' ) )
|
||||
'link' => Url::internal( 'app=downloads&module=stats&controller=topdownloads&form=1' )->setQueryString( $params ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack( 'stats_date_range' ) )
|
||||
)
|
||||
);
|
||||
|
||||
if ( $total > 0 )
|
||||
{
|
||||
$select = iterator_to_array( \IPS\Db::i()->select( 'dfid, count(*) as downloads', 'downloads_downloads', $where, 'downloads DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'dfid' )->join( 'downloads_files', 'downloads_files.file_id=downloads_downloads.dfid' ) );
|
||||
$files = iterator_to_array( \IPS\Db::i()->select( '*', 'downloads_files', \IPS\Db::i()->in( 'file_id', array_column( $select, 'dfid' ) ) )->setKeyField( 'file_id' ) );
|
||||
$select = iterator_to_array( Db::i()->select( 'dfid, count(*) as downloads', 'downloads_downloads', $where, 'downloads DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'dfid' )->join( 'downloads_files', 'downloads_files.file_id=downloads_downloads.dfid' ) );
|
||||
$files = iterator_to_array( Db::i()->select( '*', 'downloads_files', Db::i()->in( 'file_id', array_column( $select, 'dfid' ) ) )->setKeyField( 'file_id' ) );
|
||||
$downloads = array();
|
||||
if ( \count( $select ) )
|
||||
if ( count( $select ) )
|
||||
{
|
||||
foreach ( $select as $row )
|
||||
{
|
||||
$file = \IPS\downloads\File::constructFromData( $files[ $row['dfid'] ] );
|
||||
$file = File::constructFromData( $files[ $row['dfid'] ] );
|
||||
$downloads[] = array(
|
||||
'dfid' => $row['dfid'],
|
||||
'downloads' => $row['downloads'],
|
||||
'file' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $file->url(), TRUE, $file->name )
|
||||
'file' => Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $file->url(), TRUE, $file->name )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
\IPS\Http\Url::internal( 'app=downloads&module=stats&controller=topdownloads' )->setQueryString( $params ),
|
||||
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
Url::internal( 'app=downloads&module=stats&controller=topdownloads' )->setQueryString( $params ),
|
||||
ceil( $total / static::PER_PAGE ),
|
||||
$page,
|
||||
static::PER_PAGE,
|
||||
FALSE
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'stats' )->topDownloadsTable( $downloads, $pagination );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'menu__downloads_stats_topdownloads' );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'stats' )->topDownloadsTable( $downloads, $pagination );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'menu__downloads_stats_topdownloads' );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return the no results message */
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack( 'menu__downloads_stats_topdownloads' ), \IPS\Member::loggedIn()->language()->addToStack( 'no_results' ), FALSE, 'ipsPad', NULL, TRUE );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->block( Member::loggedIn()->language()->addToStack( 'menu__downloads_stats_topdownloads' ), Member::loggedIn()->language()->addToStack( 'no_results' ), FALSE, 'i-padding_3', NULL, TRUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user