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
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief adverts
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
|
||||
* @since 03 Apr 2023
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Chart\Database;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* adverts
|
||||
*/
|
||||
class adverts extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute() : void
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'adverts_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage() : void
|
||||
{
|
||||
$tabs = array(
|
||||
'impressions' => 'core_adverts_stats_impressions',
|
||||
'clicks' => 'core_adverts_stats_clicks',
|
||||
);
|
||||
|
||||
$activeTab = ( isset( Request::i()->tab ) and array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'impressions';
|
||||
|
||||
if ( $activeTab === 'impressions' )
|
||||
{
|
||||
$chart = new Database( Url::internal( 'app=core&module=activitystats&controller=adverts&tab=impressions' ), 'core_statistics', 'time', '', array(
|
||||
'isStacked' => FALSE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'hAxis' => array('gridlines' => array('color' => '#f5f5f5')),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
),
|
||||
'AreaChart',
|
||||
'daily',
|
||||
array('start' => 0, 'end' => 0),
|
||||
array(),
|
||||
$activeTab
|
||||
);
|
||||
|
||||
$chart->availableTypes = array( 'Table', 'AreaChart', 'ColumnChart', 'BarChart');
|
||||
|
||||
$chart->groupBy = 'value_1';
|
||||
$chart->title = Member::loggedIn()->language()->addToStack('core_adverts_stats_impressions');
|
||||
$chart->where[] = array( "type=?", 'advert' );
|
||||
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_advertisements' ), '\IPS\core\Advertisement' ) as $advert )
|
||||
{
|
||||
$chart->addSeries( Member::loggedIn()->language()->addToStack( "core_advert_{$advert->id}" ), 'number', 'SUM(value_2)', TRUE, $advert->id );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart = new Database( Url::internal( 'app=core&module=activitystats&controller=adverts&tab=clicks' ), 'core_statistics', 'time', '', array(
|
||||
'isStacked' => FALSE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'hAxis' => array('gridlines' => array('color' => '#f5f5f5')),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
),
|
||||
'AreaChart',
|
||||
'daily',
|
||||
array('start' => 0, 'end' => 0),
|
||||
array(),
|
||||
$activeTab
|
||||
);
|
||||
|
||||
$chart->availableTypes = array( 'Table', 'AreaChart', 'ColumnChart', 'BarChart');
|
||||
|
||||
$chart->groupBy = 'value_1';
|
||||
$chart->title = Member::loggedIn()->language()->addToStack('core_adverts_stats_impressions');
|
||||
$chart->where[] = array( "type=?", 'advert' );
|
||||
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_advertisements' ), '\IPS\core\Advertisement' ) as $advert )
|
||||
{
|
||||
$chart->addSeries( Member::loggedIn()->language()->addToStack( "core_advert_{$advert->id}" ), 'number', 'SUM(value_3)', TRUE, $advert->id );
|
||||
}
|
||||
}
|
||||
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
Output::i()->output = (string) $chart;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('core_adverts_stats');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $chart, Url::internal( "app=core&module=activitystats&controller=adverts" ), 'tab', '', 'i-padding_3' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create new methods with the same name as the 'do' parameter which should execute it
|
||||
}
|
||||
@@ -12,23 +12,27 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax
|
||||
*/
|
||||
class _ajax extends \IPS\Dispatcher\Controller
|
||||
class ajax extends Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
|
||||
parent::execute();
|
||||
@@ -39,7 +43,7 @@ class _ajax extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
// This is the default method if no 'do' parameter is specified
|
||||
}
|
||||
|
||||
@@ -11,35 +11,46 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* 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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Activity
|
||||
*/
|
||||
class _communityactivity extends \IPS\Dispatcher\Controller
|
||||
class communityactivity 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( 'communityactivity_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'communityactivity_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -49,20 +60,18 @@ class _communityactivity extends \IPS\Dispatcher\Controller
|
||||
* @return void
|
||||
* @note Activity includes posting, following, reacting
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'core', 'CommunityActivity' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=communityactivity" ) );
|
||||
$chart = Chart::loadFromExtension( 'core', 'CommunityActivity' )->getChart( Url::internal( "app=core&module=activitystats&controller=communityactivity" ) );
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
Output::i()->output = (string) $chart;
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_communityactivity');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'stats' )->activitymessage();
|
||||
\IPS\Output::i()->output .= (string) $chart;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_communityactivity');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'stats' )->activitymessage();
|
||||
Output::i()->output .= $chart;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -12,30 +12,39 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* deletedcontent
|
||||
*/
|
||||
class _deletedcontent extends \IPS\Dispatcher\Controller
|
||||
class deletedcontent 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\Dispatcher::i()->checkAcpPermission( 'deletedcontent_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'deletedcontent_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -44,11 +53,12 @@ class _deletedcontent extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'core', 'DeletedContent' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=deletedcontent" ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_deletedcontent');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
$chart = Chart::loadFromExtension( 'core', 'DeletedContent' )->getChart( Url::internal( "app=core&module=activitystats&controller=deletedcontent" ) );
|
||||
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_deletedcontent');
|
||||
Output::i()->output = (string) $chart;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,40 +11,52 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* 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 IPS\Request;
|
||||
use IPS\Settings;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Email statistics
|
||||
*/
|
||||
class _emailstats extends \IPS\Dispatcher\Controller
|
||||
class emailstats 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( 'emailstats_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'emailstats_manage' );
|
||||
|
||||
/* We can only view the stats if we have logging enabled */
|
||||
if( \IPS\Settings::i()->prune_log_emailstats == 0 )
|
||||
if( Settings::i()->prune_log_emailstats == 0 )
|
||||
{
|
||||
\IPS\Output::i()->error( 'emaillogs_not_enabled', '1C395/1', 403, '' );
|
||||
Output::i()->error( 'emaillogs_not_enabled', '1C395/1', 403, '' );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
@@ -55,20 +67,18 @@ class _emailstats extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$activeTab = $this->_getActiveTab();
|
||||
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'core', ( $activeTab === 'emails' ) ? 'Emails' : 'EmailClicks' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=emailstats&tab={$activeTab}" ) );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
$chart = Chart::loadFromExtension( 'core', ( $activeTab === 'emails' ) ? 'Emails' : 'EmailClicks' )->getChart( Url::internal( "app=core&module=activitystats&controller=emailstats&tab={$activeTab}" ) );
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
Output::i()->output = (string) $chart;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_emailstats');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $this->_getAvailableTabs(), $activeTab, (string) $chart, \IPS\Http\Url::internal( "app=core&module=activitystats&controller=emailstats" ), 'tab', '', 'ipsPad' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_emailstats');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $this->_getAvailableTabs(), $activeTab, (string) $chart, Url::internal( "app=core&module=activitystats&controller=emailstats" ), 'tab', '', 'i-padding_3' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +87,10 @@ class _emailstats extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _getActiveTab()
|
||||
protected function _getActiveTab() : string
|
||||
{
|
||||
\IPS\Request::i()->tab ??= 'emails';
|
||||
return ( array_key_exists( \IPS\Request::i()->tab, $this->_getAvailableTabs() ) ) ? \IPS\Request::i()->tab : 'emails';
|
||||
Request::i()->tab ??= 'emails';
|
||||
return ( array_key_exists( Request::i()->tab, $this->_getAvailableTabs() ) ) ? Request::i()->tab : 'emails';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +98,7 @@ class _emailstats extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _getAvailableTabs()
|
||||
protected function _getAvailableTabs() : array
|
||||
{
|
||||
return array(
|
||||
'emails' => 'stats_emailstats_emails',
|
||||
|
||||
@@ -11,35 +11,59 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\core\Statistics\Chart;
|
||||
use IPS\Content;
|
||||
use IPS\Content\Comment;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Interval;
|
||||
use IPS\Helpers\Form\Stack;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyword Tracking
|
||||
*/
|
||||
class _keywords extends \IPS\Dispatcher\Controller
|
||||
class keywords 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( 'keywords_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'keywords_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -48,109 +72,110 @@ class _keywords extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Show button to adjust settings */
|
||||
\IPS\Output::i()->sidebar['actions']['settings'] = array(
|
||||
Output::i()->sidebar['actions']['settings'] = array(
|
||||
'icon' => 'cog',
|
||||
'primary' => TRUE,
|
||||
'title' => 'manage_keywords',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=keywords&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('settings') )
|
||||
'link' => Url::internal( 'app=core&module=activitystats&controller=keywords&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('settings') )
|
||||
);
|
||||
|
||||
|
||||
$tabs = array(
|
||||
'time' => 'keywords_usage_over_time',
|
||||
'list' => 'keywords_usage_list',
|
||||
);
|
||||
\IPS\Request::i()->tab ??= 'time';
|
||||
$activeTab = ( array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'time';
|
||||
|
||||
|
||||
Request::i()->tab ??= 'time';
|
||||
$activeTab = ( array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'time';
|
||||
|
||||
if ( $activeTab === 'time' )
|
||||
{
|
||||
$output = \IPS\core\Statistics\Chart::loadFromExtension( 'core', 'Keywords' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=keywords&tab=time" ) );
|
||||
$output = Chart::loadFromExtension( 'core', 'Keywords' )->getChart( Url::internal( "app=core&module=activitystats&controller=keywords&tab=time" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_statistics', \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=keywords&tab=list' ), array( array( 'type=?', 'keyword' ) ) );
|
||||
$table = new TableDb( 'core_statistics', Url::internal( 'app=core&module=activitystats&controller=keywords&tab=list' ), array( array( 'type=?', 'keyword' ) ) );
|
||||
$table->langPrefix = 'keywordstats_';
|
||||
$table->quickSearch = 'value_4';
|
||||
|
||||
|
||||
/* Columns we need */
|
||||
$table->include = array( 'value_4', 'extra_data', 'author', 'time' );
|
||||
$table->mainColumn = 'value_4';
|
||||
$table->noSort = array( 'extra_data' );
|
||||
|
||||
|
||||
$table->sortBy = $table->sortBy ?: 'time';
|
||||
$table->sortDirection = $table->sortDirection ?: 'desc';
|
||||
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'time' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->localeDate();
|
||||
return DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
'author' => function( $val, $row )
|
||||
{
|
||||
$data = json_decode( $row['extra_data'], TRUE );
|
||||
|
||||
$data = json_decode( $row['extra_data'], true );
|
||||
|
||||
try
|
||||
{
|
||||
$class = $data['class'];
|
||||
|
||||
$class = $data['class'];
|
||||
|
||||
/* Check that the class exists */
|
||||
if( !class_exists( $class ) )
|
||||
if ( !class_exists( $class ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
throw new InvalidArgumentException;
|
||||
}
|
||||
|
||||
$item = $class::load( $data['id'] );
|
||||
|
||||
|
||||
$item = $class::load( $data['id'] );
|
||||
|
||||
return $item->author()->link();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unknown' );
|
||||
return Member::loggedIn()->language()->addToStack( 'unknown' );
|
||||
}
|
||||
},
|
||||
'extra_data' => function( $val, $row )
|
||||
{
|
||||
$data = json_decode( $val, TRUE );
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
$class = $data['class'];
|
||||
|
||||
|
||||
/* Check that the class exists */
|
||||
if( !class_exists( $class ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
throw new InvalidArgumentException;
|
||||
}
|
||||
|
||||
|
||||
$item = $class::load( $data['id'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $item->url(), TRUE, ( $item instanceof \IPS\Content\Comment ) ? $item->item()->mapped('title') : $item->mapped('title'), TRUE );
|
||||
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $item->url(), TRUE, ( $item instanceof Comment ) ? $item->item()->mapped('title') : $item->mapped('title'), TRUE );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'content_deleted' );
|
||||
return Member::loggedIn()->language()->addToStack( 'content_deleted' );
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/* Display */
|
||||
$output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table, TRUE, 'ipsPad ipsSpacer_top' );
|
||||
$output = Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table, TRUE, 'i-padding_3 i-margin-top_1' );
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = (string) $output;
|
||||
Output::i()->output = (string) $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_keywords');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $output, \IPS\Http\Url::internal( "app=core&module=activitystats&controller=keywords" ), 'tab', '', 'ipsPad' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_keywords');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $output, Url::internal( "app=core&module=activitystats&controller=keywords" ), 'tab', '', 'i-padding_3' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,46 +184,46 @@ class _keywords extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function settings()
|
||||
protected function settings() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'stats_keywords', \IPS\Settings::i()->stats_keywords ? json_decode( \IPS\Settings::i()->stats_keywords, true ) : array(), FALSE, array( 'stackFieldType' => 'Text' ), NULL, NULL, NULL, 'stats_keywords' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'stats_keywords_prune', \IPS\Settings::i()->stats_keywords_prune, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL ) );
|
||||
$form = new Form;
|
||||
$form->add( new Stack( 'stats_keywords', Settings::i()->stats_keywords ? json_decode( Settings::i()->stats_keywords, true ) : array(), FALSE, array( 'stackFieldType' => 'Text' ), NULL, NULL, NULL, 'stats_keywords' ) );
|
||||
$form->add( new Interval( 'stats_keywords_prune', Settings::i()->stats_keywords_prune, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$values['stats_keywords'] = json_encode( array_unique( $values['stats_keywords'] ) );
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Session::i()->log( 'acplog__statskeywords_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=keywords' ), 'saved' );
|
||||
Session::i()->log( 'acplog__statskeywords_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=activitystats&controller=keywords' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'settings', $form, FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('settings');
|
||||
Output::i()->output = Theme::i()->getTemplate('global')->block( 'settings', $form, FALSE );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rebuild
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function rebuild()
|
||||
protected function rebuild() : void
|
||||
{
|
||||
if ( !\IPS\Settings::i()->stats_keywords )
|
||||
if ( !Settings::i()->stats_keywords )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_keywords_to_rebuild', '2C433/1', 403, '' );
|
||||
Output::i()->error( 'no_keywords_to_rebuild', '2C433/1', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Db::i()->delete( 'core_statistics', array( 'type=?', 'keyword' ) );
|
||||
foreach( \IPS\Content::routedClasses() AS $class )
|
||||
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
Db::i()->delete( 'core_statistics', array( 'type=?', 'keyword' ) );
|
||||
foreach( Content::routedClasses() AS $class )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'RebuildKeywords', array( 'class' => $class ) );
|
||||
Task::queue( 'core', 'RebuildKeywords', array( 'class' => $class ) );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__statskeywords_rebuilt' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=keywords' ), 'saved' );
|
||||
|
||||
Session::i()->log( 'acplog__statskeywords_rebuilt' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=activitystats&controller=keywords' ), 'saved' );
|
||||
}
|
||||
}
|
||||
@@ -11,62 +11,73 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\core\modules\admin\stats\overview as StatsOverview;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Content overview statistics
|
||||
*/
|
||||
class _overview extends \IPS\core\modules\admin\stats\overview
|
||||
class overview extends StatsOverview
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Template group to use to output
|
||||
*/
|
||||
protected $templateGroup = 'activitystats';
|
||||
protected string $templateGroup = 'activitystats';
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Create the general page layout, but we will load the individual cells via AJAX to ensure there are no performance concerns loading the page
|
||||
*
|
||||
* @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' );
|
||||
|
||||
$excludedApps = array();
|
||||
|
||||
if( isset( \IPS\Request::i()->cookie['overviewExcludedApps'] ) )
|
||||
if( isset( Request::i()->cookie['overviewExcludedApps'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$excludedApps = json_decode( \IPS\Request::i()->cookie['overviewExcludedApps'] );
|
||||
$excludedApps = json_decode( Request::i()->cookie['overviewExcludedApps'] );
|
||||
|
||||
if( !\is_array( $excludedApps ) )
|
||||
if( !is_array( $excludedApps ) )
|
||||
{
|
||||
$excludedApps = array();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
\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, $excludedApps );
|
||||
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, $excludedApps );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,15 +85,15 @@ class _overview extends \IPS\core\modules\admin\stats\overview
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function loadBlockForm()
|
||||
protected function loadBlockForm() : 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', '2C416/1', 404, '' );
|
||||
Output::i()->error( 'stats_overview_block_not_found', '2C416/1', 404, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $blocks[ \IPS\Request::i()->blockKey ]->getBlockForm( \IPS\Request::i()->subBlockKey );
|
||||
Output::i()->output = $blocks[ Request::i()->blockKey ]->getBlockForm( Request::i()->subBlockKey );
|
||||
}
|
||||
}
|
||||
@@ -11,35 +11,46 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* 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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* reactions
|
||||
*/
|
||||
class _reactions extends \IPS\Dispatcher\Controller
|
||||
class reactions 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( 'reactionsstats_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reactionsstats_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -48,7 +59,7 @@ class _reactions extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$tabs = array(
|
||||
'type' => 'stats_reactions_by_type',
|
||||
@@ -57,152 +68,19 @@ class _reactions extends \IPS\Dispatcher\Controller
|
||||
'givers' => 'stats_reactions_top_givers',
|
||||
'getters' => 'stats_reactions_top_receivers',
|
||||
);
|
||||
\IPS\Request::i()->tab ??= 'type';
|
||||
$activeTab = ( array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'type';
|
||||
|
||||
if ( $activeTab === 'type' OR $activeTab === 'app' )
|
||||
Request::i()->tab ??= 'type';
|
||||
$activeTab = ( array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'type';
|
||||
$chart = Chart::loadFromExtension( 'core', ( $activeTab === 'type' ) ? 'Reactions' : 'ReactionsApp' )->getChart( Url::internal( "app=core&module=activitystats&controller=reactions&tab=" . $activeTab ) );
|
||||
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'core', ( $activeTab === 'type' ) ? 'Reactions' : 'ReactionsApp' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=reactions&tab=" . $activeTab ) );
|
||||
Output::i()->output = (string) $chart;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $activeTab == 'givers' OR $activeTab == 'getters' )
|
||||
{
|
||||
$start = NULL;
|
||||
$end = NULL;
|
||||
|
||||
$defaults = array( 'start' => \IPS\DateTime::create()->setDate( date('Y'), date('m'), 1 ), 'end' => new \IPS\DateTime );
|
||||
|
||||
if( isset( \IPS\Request::i()->repDateStart ) AND isset( \IPS\Request::i()->repDateEnd ) )
|
||||
{
|
||||
$defaults = array( 'start' => \IPS\DateTime::ts( \IPS\Request::i()->repDateStart ), 'end' => \IPS\DateTime::ts( \IPS\Request::i()->repDateEnd ) );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( $activeTab, 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'date', $defaults, TRUE ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
/* Determine start and end time */
|
||||
$startTime = $values['date']['start']->getTimestamp();
|
||||
$endTime = $values['date']['end']->getTimestamp();
|
||||
|
||||
$start = $values['date']['start']->html();
|
||||
$end = $values['date']['end']->html();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Determine start and end time */
|
||||
$startTime = $defaults['start']->getTimestamp();
|
||||
$endTime = $defaults['end']->getTimestamp();
|
||||
|
||||
$start = $defaults['start']->html();
|
||||
$end = $defaults['end']->html();
|
||||
}
|
||||
|
||||
$where = array( array( 'rep_date BETWEEN ? AND ?', $startTime, $endTime ) );
|
||||
}
|
||||
|
||||
/* Database table helpers don't support grouping, so we will manually fetch the results and then let the table helper display */
|
||||
$contentWhere = array();
|
||||
$idToRatingMap = array();
|
||||
|
||||
if( $activeTab == 'list' )
|
||||
{
|
||||
$query = \IPS\Db::i()->select( 'MAX(id) as id, SUM(rep_rating) as rating', 'core_reputation_index', NULL, 'rating DESC', array( 0, 20 ), array( 'app', 'type', 'type_id' ) );
|
||||
}
|
||||
elseif( $activeTab == 'givers' )
|
||||
{
|
||||
$query = \IPS\Db::i()->select( 'MAX(id) as id, SUM(rep_rating) as rating', 'core_reputation_index', $where, 'rating DESC', array( 0, 20 ), array( 'member_id' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = \IPS\Db::i()->select( 'MAX(id) as id, SUM(rep_rating) as rating', 'core_reputation_index', $where, 'rating DESC', array( 0, 20 ), array( 'member_received' ) );
|
||||
}
|
||||
|
||||
foreach( $query as $reputation )
|
||||
{
|
||||
$contentWhere[] = $reputation['id'];
|
||||
$idToRatingMap[ $reputation['id'] ] = $reputation['rating'];
|
||||
}
|
||||
|
||||
/* Create the table */
|
||||
$chart = new \IPS\Helpers\Table\Db( 'core_reputation_index', \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=reactions&type=list' ), array( \IPS\Db::i()->in( 'id', $contentWhere ) ) );
|
||||
$chart->quickSearch = NULL;
|
||||
|
||||
/* Columns we need */
|
||||
if( $activeTab == 'list' )
|
||||
{
|
||||
$chart->langPrefix = 'reactstats_';
|
||||
$chart->include = array( 'type_id', 'rep_date', 'member_id', 'rating' );
|
||||
$chart->mainColumn = 'type_id';
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart->langPrefix = 'reactstatsm_';
|
||||
$column = ( $activeTab == 'givers' ) ? 'member_id' : 'member_received';
|
||||
$chart->include = array( $column, 'rep_date', 'rating' );
|
||||
$chart->mainColumn = $column;
|
||||
|
||||
$chart->baseUrl = $chart->baseUrl->setQueryString( array( 'repDateStart' => $startTime, 'repDateEnd' => $endTime, 'tab' => $activeTab ) );
|
||||
}
|
||||
|
||||
$chart->noSort = array( 'member_id', 'type_id', 'rep_date', 'rating' );
|
||||
|
||||
$chart->sortBy = $chart->sortBy ?: 'rating';
|
||||
$chart->sortDirection = $chart->sortDirection ?: 'desc';
|
||||
|
||||
/* Custom parsers */
|
||||
$chart->parsers = array(
|
||||
'rep_date' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
'member_id' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Member::load( $val )->link();
|
||||
},
|
||||
'member_received' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Member::load( $val )->link();
|
||||
},
|
||||
'rating' => function( $val, $row ) use ( $idToRatingMap )
|
||||
{
|
||||
/* Return the reputation total */
|
||||
return $idToRatingMap[ $row['id'] ];
|
||||
},
|
||||
'type_id' => function( $val, $row )
|
||||
{
|
||||
$class = $row['rep_class'];
|
||||
|
||||
try
|
||||
{
|
||||
$item = $class::load( $row['type_id'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'activitystats' )->contentCell( $item );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if( $activeTab == 'givers' OR $activeTab == 'getters' )
|
||||
{
|
||||
$formHtml = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'stats' ), 'filtersFormTemplate' ) );
|
||||
$chart = \IPS\Theme::i()->getTemplate( 'activitystats', 'core' )->repWrapper( $formHtml, \count( $contentWhere ), (string) $chart );
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_reactions');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $chart, \IPS\Http\Url::internal( "app=core&module=activitystats&controller=reactions" ), 'tab', '', 'ipsPad' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_reactions');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $chart, Url::internal( "app=core&module=activitystats&controller=reactions" ), 'tab', '', 'i-padding_3' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,34 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* reports
|
||||
*/
|
||||
class _reports extends \IPS\Dispatcher\Controller
|
||||
class reports extends Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reportstats_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reportstats_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -39,11 +48,12 @@ class _reports extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'core', 'Reports' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=reports" ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_reports');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
$chart = Chart::loadFromExtension( 'core', 'Reports' )->getChart( Url::internal( "app=core&module=activitystats&controller=reports" ) );
|
||||
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_reports');
|
||||
Output::i()->output = (string) $chart;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,35 +11,52 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Statistics\Chart;
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Interval;
|
||||
use IPS\Helpers\Table\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Statistics
|
||||
*/
|
||||
class _search extends \IPS\Dispatcher\Controller
|
||||
class search 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( 'search_stats_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'search_stats_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -48,34 +65,34 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Show button to adjust settings */
|
||||
\IPS\Output::i()->sidebar['actions']['settings'] = array(
|
||||
Output::i()->sidebar['actions']['settings'] = array(
|
||||
'icon' => 'cog',
|
||||
'primary' => TRUE,
|
||||
'title' => 'manage_searchstats',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=search&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('settings') )
|
||||
'link' => Url::internal( 'app=core&module=activitystats&controller=search&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('settings') )
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sidebar['actions']['log'] = array(
|
||||
Output::i()->sidebar['actions']['log'] = array(
|
||||
'icon' => 'search',
|
||||
'title' => 'searchstats_log',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=search&do=log' ),
|
||||
'link' => Url::internal( 'app=core&module=activitystats&controller=search&do=log' ),
|
||||
);
|
||||
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'core', 'Search' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=search" ) );
|
||||
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
$chart = Chart::loadFromExtension( 'core', 'Search' )->getChart( Url::internal( "app=core&module=activitystats&controller=search" ) );
|
||||
|
||||
if( \IPS\Request::i()->noheader AND \IPS\Request::i()->isAjax() )
|
||||
Output::i()->output = (string) $chart;
|
||||
|
||||
if( Request::i()->noheader AND Request::i()->isAjax() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_search');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_search');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,20 +100,20 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function settings()
|
||||
protected function settings() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'stats_search_prune', \IPS\Settings::i()->stats_search_prune, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL ) );
|
||||
$form = new Form;
|
||||
$form->add( new Interval( 'stats_search_prune', Settings::i()->stats_search_prune, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Session::i()->log( 'acplog__statssearch_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=search' ), 'saved' );
|
||||
Session::i()->log( 'acplog__statssearch_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=activitystats&controller=search' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'settings', $form, FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('settings');
|
||||
Output::i()->output = Theme::i()->getTemplate('global')->block( 'settings', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,10 +121,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function log()
|
||||
protected function log() : void
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_statistics', \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=search&do=log' ), array( array( 'type=?', 'search' ) ) );
|
||||
$table = new Db( 'core_statistics', Url::internal( 'app=core&module=activitystats&controller=search&do=log' ), array( array( 'type=?', 'search' ) ) );
|
||||
$table->langPrefix = 'searchstats_';
|
||||
$table->quickSearch = 'value_4';
|
||||
|
||||
@@ -122,14 +139,14 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$table->parsers = array(
|
||||
'time' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val );
|
||||
return DateTime::ts( $val );
|
||||
}
|
||||
);
|
||||
|
||||
/* The table filters won't without this */
|
||||
\IPS\Output::i()->bypassCsrfKeyCheck = true;
|
||||
Output::i()->bypassCsrfKeyCheck = true;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('searchstats_log');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('searchstats_log');
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
}
|
||||
@@ -11,35 +11,44 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag Usage
|
||||
*/
|
||||
class _tags extends \IPS\Dispatcher\Controller
|
||||
class tags 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( 'tagsusage_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'tagsusage_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -48,10 +57,11 @@ class _tags extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'core', 'Tags' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=tags" ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_tags');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
$chart = Chart::loadFromExtension( 'core', 'Tags' )->getChart( Url::internal( "app=core&module=activitystats&controller=tags" ) );
|
||||
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_tags');
|
||||
Output::i()->output = (string) $chart;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user