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
@@ -11,50 +11,67 @@
|
||||
namespace IPS\core\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Date;
|
||||
use IPS\Helpers\Form\DateRange;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* User activity statistics overview
|
||||
*/
|
||||
class _overview extends \IPS\Dispatcher\Controller
|
||||
class overview 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 Date range to restrict to, or NULL for no restriction
|
||||
*/
|
||||
protected $dateRange = '7';
|
||||
protected string $dateRange = '7';
|
||||
|
||||
/**
|
||||
* @brief Form object
|
||||
*/
|
||||
protected $form = NULL;
|
||||
protected ?Form $form = NULL;
|
||||
|
||||
/**
|
||||
* @brief Template group to use to output
|
||||
*/
|
||||
protected $templateGroup = 'stats';
|
||||
protected string $templateGroup = 'stats';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'overview_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'overview_manage' );
|
||||
|
||||
$options = array(
|
||||
'7' => 'last_week',
|
||||
@@ -66,9 +83,9 @@ class _overview extends \IPS\Dispatcher\Controller
|
||||
'-1' => 'custom'
|
||||
);
|
||||
|
||||
$this->form = new \IPS\Helpers\Form( 'posts', 'update' );
|
||||
$this->form->add( new \IPS\Helpers\Form\Select( 'predate', '7', FALSE, array( 'options' => $options, 'toggles' => array( '-1' => array( 'dateFilterInputs' ) ) ) ) );
|
||||
$this->form->add( new \IPS\Helpers\Form\DateRange( 'date', NULL, FALSE, array(), NULL, NULL, NULL, 'dateFilterInputs' ) );
|
||||
$this->form = new Form( 'posts', 'update' );
|
||||
$this->form->add( new Select( 'predate', '7', FALSE, array( 'options' => $options, 'toggles' => array( '-1' => array( 'dateFilterInputs' ) ) ) ) );
|
||||
$this->form->add( new DateRange( 'date', NULL, FALSE, array(), NULL, NULL, NULL, 'dateFilterInputs' ) );
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
@@ -78,15 +95,15 @@ class _overview extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$formHtml = $this->form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'stats' ), 'filtersOverviewForm' ) );
|
||||
$blocks = \IPS\Application::allExtensions( 'core', 'OverviewStatistics', TRUE, 'core', 'Registrations' );
|
||||
$formHtml = $this->form->customTemplate( array( Theme::i()->getTemplate( 'stats' ), 'filtersOverviewForm' ) );
|
||||
$blocks = Application::allExtensions( 'core', 'OverviewStatistics', TRUE, 'core', 'Registrations' );
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_stats.js', 'core' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/statistics.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_stats_overview');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( $this->templateGroup )->overview( $formHtml, $blocks );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_stats.js', 'core' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'system/statistics.css', 'core', 'admin' ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_stats_overview');
|
||||
Output::i()->output = Theme::i()->getTemplate( $this->templateGroup )->overview( $formHtml, $blocks );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,38 +111,38 @@ class _overview extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function loadBlock()
|
||||
protected function loadBlock() : void
|
||||
{
|
||||
$blocks = \IPS\Application::allExtensions( 'core', 'OverviewStatistics', TRUE, 'core', 'Registrations' );
|
||||
$blocks = Application::allExtensions( 'core', 'OverviewStatistics', TRUE, 'core', 'Registrations' );
|
||||
|
||||
if( !isset( $blocks[ \IPS\Request::i()->blockKey ] ) )
|
||||
if( !isset( $blocks[ Request::i()->blockKey ] ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'stats_overview_block_not_found', '2C412/1', 404, '' );
|
||||
Output::i()->error( 'stats_overview_block_not_found', '2C412/1', 404, '' );
|
||||
}
|
||||
|
||||
$dateFilters = NULL;
|
||||
|
||||
if( \IPS\Request::i()->range )
|
||||
if( Request::i()->range )
|
||||
{
|
||||
$dateFilters = \IPS\Request::i()->range;
|
||||
$dateFilters = Request::i()->range;
|
||||
}
|
||||
elseif( \IPS\Request::i()->start )
|
||||
elseif( Request::i()->start )
|
||||
{
|
||||
try
|
||||
{
|
||||
$timezone = \IPS\Member::loggedIn()->timezone ? new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) : NULL;
|
||||
$timezone = Member::loggedIn()->timezone ? new DateTimeZone( Member::loggedIn()->timezone ) : NULL;
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$timezone = NULL;
|
||||
}
|
||||
|
||||
$dateFilters = array(
|
||||
'start' => new \IPS\DateTime( \IPS\Helpers\Form\Date::_convertDateFormat( \IPS\Request::i()->start ), $timezone ),
|
||||
'end' => ( new \IPS\DateTime( \IPS\Helpers\Form\Date::_convertDateFormat( \IPS\Request::i()->end ), $timezone ) )->setTime( 23, 59, 59 )
|
||||
'start' => new DateTime( Date::_convertDateFormat( Request::i()->start ), $timezone ),
|
||||
'end' => ( new DateTime( Date::_convertDateFormat( Request::i()->end ), $timezone ) )->setTime( 23, 59, 59 )
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sendOutput( $blocks[ \IPS\Request::i()->blockKey ]->getBlock( $dateFilters, \IPS\Request::i()->subblock ) );
|
||||
Output::i()->sendOutput( $blocks[ Request::i()->blockKey ]->getBlock( $dateFilters, Request::i()->subblock ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user