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
@@ -12,49 +12,66 @@
|
||||
namespace IPS\forums\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\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\forums\Topic\Post;
|
||||
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 Throwable;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* posts
|
||||
*/
|
||||
class _posts extends \IPS\Dispatcher\Controller
|
||||
class posts 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;
|
||||
|
||||
/**
|
||||
* Show solved posts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function showSolvedPosts()
|
||||
protected function showSolvedPosts() : void
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_solved_index', \IPS\Http\Url::internal( 'app=forums&module=stats&controller=posts&do=showSolvedPosts' ), [ 'solved_date BETWEEN ? AND ?', \IPS\Request::i()->startTime, \IPS\Request::i()->endTime ] );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_solved_index', Url::internal( 'app=forums&module=stats&controller=posts&do=showSolvedPosts' ), [ 'solved_date BETWEEN ? AND ? AND type=?', Request::i()->startTime, Request::i()->endTime, 'solved' ] );
|
||||
$table->quickSearch = NULL;
|
||||
$table->sortBy = $table->sortBy ?: 'solved_date';
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
$table->langPrefix = 'stats_posts_type_';
|
||||
$table->include = [ 'comment_id', 'solved_date' ];
|
||||
$table->widths = array( 'solved_date' => 25, 'comment_id' => 75 );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( array( 'startTime' => \IPS\Request::i()->startTime, 'endTime' => \IPS\Request::i()->endTime, 'tab' => 'bytype' ) );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( array( 'startTime' => Request::i()->startTime, 'endTime' => Request::i()->endTime, 'tab' => 'bytype' ) );
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'solved_date' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->html();
|
||||
return DateTime::ts( $val )->html();
|
||||
},
|
||||
'comment_id' => function( $val, $row )
|
||||
{
|
||||
@@ -64,16 +81,16 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$item = $class::load( $row['comment_id'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
return Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
catch ( Throwable $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
return Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'ipsPad' );
|
||||
Output::i()->output = Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'i-padding_3' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,23 +98,23 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function showRecommendedPosts()
|
||||
protected function showRecommendedPosts() : void
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_content_meta', \IPS\Http\Url::internal( 'app=forums&module=stats&controller=posts&do=showRecommendedPosts' ), [ 'meta_type=? AND meta_added BETWEEN ? AND ?', 'core_FeaturedComments', \IPS\Request::i()->startTime, \IPS\Request::i()->endTime ] );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_content_meta', Url::internal( 'app=forums&module=stats&controller=posts&do=showRecommendedPosts' ), [ 'meta_type=? AND meta_added BETWEEN ? AND ?', 'core_FeaturedComments', Request::i()->startTime, Request::i()->endTime ] );
|
||||
$table->quickSearch = NULL;
|
||||
$table->sortBy = $table->sortBy ?: 'meta_added';
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
$table->langPrefix = 'stats_posts_type_';
|
||||
$table->include = [ 'meta_data', 'meta_added' ];
|
||||
$table->widths = array( 'meta_added' => 25, 'meta_data' => 75 );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( array( 'startTime' => \IPS\Request::i()->startTime, 'endTime' => \IPS\Request::i()->endTime, 'tab' => 'bytype' ) );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( array( 'startTime' => Request::i()->startTime, 'endTime' => Request::i()->endTime, 'tab' => 'bytype' ) );
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'meta_added' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->html();
|
||||
return DateTime::ts( $val )->html();
|
||||
},
|
||||
'meta_data' => function( $val, $row )
|
||||
{
|
||||
@@ -105,18 +122,18 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$item = \IPS\forums\Topic\Post::load( $data['comment'] );
|
||||
$item = Post::load( $data['comment'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
return Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
catch ( Throwable $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
return Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'ipsPad' );
|
||||
Output::i()->output = Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'i-padding_3' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,25 +141,25 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'posts_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'posts_manage' );
|
||||
|
||||
$tabs = array( 'total' => 'stats_posts_tab_total', 'bytype' => 'stats_posts_by_type', 'byforum' => 'stats_posts_tab_byforum' );
|
||||
\IPS\Request::i()->tab ??= 'total';
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'total';
|
||||
Request::i()->tab ??= 'total';
|
||||
$activeTab = ( isset( Request::i()->tab ) and array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'total';
|
||||
|
||||
if ( $activeTab === 'bytype' )
|
||||
{
|
||||
$defaults = array( 'start' => \IPS\DateTime::create()->setDate( date('Y'), date('m'), 1 ), 'end' => new \IPS\DateTime );
|
||||
$defaults = array( 'start' => DateTime::create()->setDate( date('Y'), date('m'), 1 ), 'end' => new DateTime );
|
||||
|
||||
if( isset( \IPS\Request::i()->badgeDateStart ) AND isset( \IPS\Request::i()->badgeDateEnd ) )
|
||||
if( isset( Request::i()->badgeDateStart ) AND isset( Request::i()->badgeDateEnd ) )
|
||||
{
|
||||
$defaults = array( 'start' => \IPS\DateTime::ts( \IPS\Request::i()->badgeDateStart ), 'end' => \IPS\DateTime::ts( \IPS\Request::i()->badgeDateEnd ) );
|
||||
$defaults = array( 'start' => DateTime::ts( Request::i()->badgeDateStart ), 'end' => DateTime::ts( Request::i()->badgeDateEnd ) );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( $activeTab, 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'date', $defaults, TRUE ) );
|
||||
$form = new Form( $activeTab, 'continue' );
|
||||
$form->add( new DateRange( 'date', $defaults, TRUE ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
@@ -164,37 +181,38 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Get a count of solved posts in this time */
|
||||
$solvedCount = \IPS\Db::i()->select( 'count(*)', 'core_solved_index', [
|
||||
$solvedCount = Db::i()->select( 'count(*)', 'core_solved_index', [
|
||||
[ 'solved_date BETWEEN ? AND ?', $startTime, $endTime ],
|
||||
[ 'comment_class=?', 'IPS\forums\Topic\Post' ]
|
||||
[ 'comment_class=?', 'IPS\forums\Topic\Post' ],
|
||||
[ 'type=?', 'solved' ]
|
||||
] )->first();
|
||||
|
||||
/* Get a count of recommended posts in this time */
|
||||
$recommendedCount = \IPS\Db::i()->select( 'count(*)', 'core_content_meta', [
|
||||
$recommendedCount = Db::i()->select( 'count(*)', 'core_content_meta', [
|
||||
[ 'meta_added BETWEEN ? AND ?', $startTime, $endTime ],
|
||||
[ 'meta_type=?', 'core_FeaturedComments' ]
|
||||
] )->first();
|
||||
|
||||
$formHtml = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'stats', 'core' ), 'filtersFormTemplate' ) );
|
||||
$chart = \IPS\Theme::i()->getTemplate( 'stats', 'forums' )->statsTypeWrapper( $formHtml, $solvedCount, $recommendedCount, $startTime, $endTime );
|
||||
$formHtml = $form->customTemplate( array( Theme::i()->getTemplate( 'stats', 'core' ), 'filtersFormTemplate' ) );
|
||||
$chart = Theme::i()->getTemplate( 'stats', 'forums' )->statsTypeWrapper( $formHtml, $solvedCount, $recommendedCount, $startTime, $endTime );
|
||||
}
|
||||
else if ( $activeTab === 'total' )
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'forums', 'Posts' )->getChart( \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts&tab={$activeTab}" ) );
|
||||
$chart = Chart::loadFromExtension( 'forums', 'Posts' )->getChart( Url::internal( "app=forums&module=stats&controller=posts&tab={$activeTab}" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'forums', 'PostsByForum' )->getChart( \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts&tab={$activeTab}" ) );
|
||||
$chart = Chart::loadFromExtension( 'forums', 'PostsByForum' )->getChart( Url::internal( "app=forums&module=stats&controller=posts&tab={$activeTab}" ) );
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
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__forums_stats_posts');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $chart, \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts" ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__forums_stats_posts');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $chart, Url::internal( "app=forums&module=stats&controller=posts" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief questions
|
||||
* @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
|
||||
* @subpackage Forums
|
||||
* @since 21 Sep 2021
|
||||
*/
|
||||
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* questions
|
||||
*/
|
||||
class _questions extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'questions_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'forums', 'Questions' )->getChart( \IPS\Http\Url::internal( "app=forums&module=stats&controller=questions" ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__forums_stats_questions');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Output;
|
||||
@@ -35,34 +38,33 @@ use const IPS\Helpers\Table\SEARCH_NODE;
|
||||
use const IPS\Helpers\Table\SEARCH_MEMBER;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* solved
|
||||
*/
|
||||
class _solved extends Controller
|
||||
class solved 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
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'topics_manage' );
|
||||
parent::execute();
|
||||
@@ -81,7 +83,7 @@ class _solved extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$tabs = array(
|
||||
'time' => 'forums_solved_stats_time',
|
||||
@@ -98,44 +100,44 @@ class _solved extends Controller
|
||||
'link' => Url::internal( 'app=forums&module=stats&controller=solved&do=rebuildStats' )->csrf(),
|
||||
'data' => array( 'confirm' => '' )
|
||||
);
|
||||
|
||||
|
||||
Request::i()->tab ??= 'time';
|
||||
$activeTab = ( isset( Request::i()->tab ) and array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'time';
|
||||
|
||||
$url = Url::internal( "app=forums&module=stats&controller=solved&tab={$activeTab}" );
|
||||
$output = match( $activeTab ) {
|
||||
'percentage' => Chart::loadFromExtension( 'forums', 'PercentageSolved' )->getChart( $url ),
|
||||
'solved' => Chart::loadFromExtension( 'forums', 'SolvedByForum' )->getChart( $url ),
|
||||
'groups' => CHart::LoadFromExtension( 'forums', 'SolvedByGroup' )->getChart( $url ),
|
||||
'unsolved' => $this->_unsolved(),
|
||||
default => Chart::loadFromExtension( 'forums', 'TimeSolved' )->getChart( $url )
|
||||
|
||||
$url = Url::internal( "app=forums&module=stats&controller=solved&tab={$activeTab}" );
|
||||
$chart = match( $activeTab ) {
|
||||
'percentage' => Chart::loadFromExtension( 'forums', 'PercentageSolved' )->getChart( $url ),
|
||||
'solved' => Chart::loadFromExtension( 'forums', 'SolvedByForum' )->getChart( $url ),
|
||||
'groups' => Chart::LoadFromExtension( 'forums', 'SolvedByGroup' )->getChart( $url ),
|
||||
'unsolved' => $this->_unsolved(),
|
||||
default => Chart::loadFromExtension( 'forums', 'TimeSolved' )->getChart( $url )
|
||||
};
|
||||
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
Output::i()->output = (string) $output;
|
||||
Output::i()->output = (string)$chart;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'menu__forums_stats_solved' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $output, Url::internal( "app=forums&module=stats&controller=solved" ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string)$chart, Url::internal( "app=forums&module=stats&controller=solved" ), 'tab', '', 'i-padding_3' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsolved Topics
|
||||
*
|
||||
* @return \IPS\Helpers\Table\Db
|
||||
* @return TableDb
|
||||
*/
|
||||
protected function _unsolved(): TableDb
|
||||
{
|
||||
/* Load Forums into Memory */
|
||||
Forum::loadIntoMemory( NULL );
|
||||
|
||||
|
||||
$table = new TableDb( 'forums_topics', Url::internal( "app=forums&module=stats&controller=solved&tab=unsolved" ), static::_unsolvedWHere() );
|
||||
$table->langPrefix = 'topics_noposts_';
|
||||
$table->include = array( 'tid', 'title', 'state', 'start_date', 'starter_id', 'views', 'forum_id', 'approved' );
|
||||
|
||||
|
||||
$table->parsers = array(
|
||||
'title' => function( $val, $row )
|
||||
{
|
||||
@@ -152,7 +154,7 @@ class _solved extends Controller
|
||||
},
|
||||
'start_date' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
return (string) DateTime::ts( $val );
|
||||
},
|
||||
'starter_id' => function( $val, $row )
|
||||
{
|
||||
@@ -174,7 +176,7 @@ class _solved extends Controller
|
||||
{
|
||||
$guest->name = $row['starter_name'];
|
||||
}
|
||||
|
||||
|
||||
return $guest->name;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +196,7 @@ class _solved extends Controller
|
||||
{
|
||||
$title = $forum->_title;
|
||||
}
|
||||
|
||||
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $forum->url(), TRUE, $title );
|
||||
},
|
||||
'approved' => function( $val )
|
||||
@@ -209,21 +211,21 @@ class _solved extends Controller
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$table->filters = array(
|
||||
'open' => "state='open'",
|
||||
'locked' => "state='closed'",
|
||||
'approved' => "approved=1",
|
||||
'unapproved' => "approved=0"
|
||||
);
|
||||
|
||||
|
||||
$table->advancedSearch['forum_id'] = array( SEARCH_NODE, array( 'class' => 'IPS\\forums\\Forum', 'clubs' => TRUE ) );
|
||||
$table->advancedSearch['starter_id'] = SEARCH_MEMBER;
|
||||
$table->advancedSearch['start_date'] = SEARCH_DATE_RANGE;
|
||||
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Unsolved Topics Where Clause
|
||||
*
|
||||
@@ -238,15 +240,15 @@ class _solved extends Controller
|
||||
$where[] = array( Db::i()->in( 'approved', array( 0, 1 ) ) );
|
||||
$where[] = array( Db::i()->in( 'forum_id', Db::i()->select( 'id', 'forums_forums' ) ) );
|
||||
$where[] = array( Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) );
|
||||
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Kick off a rebuild of the stats
|
||||
*
|
||||
*/
|
||||
public function rebuildStats()
|
||||
public function rebuildStats() : void
|
||||
{
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
@@ -255,7 +257,7 @@ class _solved extends Controller
|
||||
Task::queue( 'forums', 'RebuildSolvedStats', array( 'forum_id' => $forum['id'] ) );
|
||||
}
|
||||
|
||||
Output::i()->redirect( \IPS\Http\Url::internal('app=forums&module=stats&controller=solved'), 'solved_stats_rebuild_started' );
|
||||
Output::i()->redirect( Url::internal('app=forums&module=stats&controller=solved'), 'solved_stats_rebuild_started' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +265,7 @@ class _solved extends Controller
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getValidForumIds()
|
||||
protected function getValidForumIds(): array
|
||||
{
|
||||
$validForumIds = [];
|
||||
|
||||
|
||||
@@ -11,13 +11,14 @@
|
||||
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Http\Url\Friendly;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Theme;
|
||||
use IPS\Output;
|
||||
|
||||
@@ -30,33 +31,33 @@ use const IPS\Helpers\Table\SEARCH_SELECT;
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* solvers
|
||||
*/
|
||||
class _solvers extends Controller
|
||||
class solvers 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
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'solvers_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'topics_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -65,17 +66,17 @@ class _solvers extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$table = new TableDb( 'core_solved_index', Url::internal( "app=forums&module=stats&controller=solvers" ) );
|
||||
$table->langPrefix = 'top_solvers_';
|
||||
$table->groupBy = array( 'core_members.member_id', 'core_members.name', 'core_members.member_group_id' );
|
||||
$table->selects = array( 'COUNT(core_members.member_id) AS count', 'core_members.member_id', 'core_members.name', 'MAX(core_solved_index.solved_date) AS date', 'core_members.member_group_id' );
|
||||
$table->joins = array( array( 'from' => 'core_members', 'where' => 'core_solved_index.member_id=core_members.member_id', 'type' => 'RIGHT' ) );
|
||||
$table->groupBy = array( 'core_solved_index.member_id', /*'core_members.name', 'core_members.member_group_id'*/ );
|
||||
$table->selects = array( 'COUNT(core_solved_index.member_id) AS count', 'core_solved_index.member_id', 'core_members.name', 'MAX(core_solved_index.solved_date) AS date', 'core_members.member_group_id' );
|
||||
$table->joins = array( array( 'from' => 'core_members', 'where' => 'core_solved_index.member_id=core_members.member_id', 'type' => 'LEFT' ) );
|
||||
$table->include = array( 'name', 'count', 'date', 'member_group_id' );
|
||||
$table->parsers = array(
|
||||
'name' => function( $val, $row ) {
|
||||
return Theme::i()->getTemplate( 'global', 'core' )->userLinkWithPhoto( \IPS\Member::load( $row['member_id'] ) );
|
||||
return Theme::i()->getTemplate( 'global', 'core' )->userLinkWithPhoto( Member::load( $row['member_id'] ) );
|
||||
},
|
||||
'count' => function( $val, $row ) {
|
||||
$url = Url::internal( "app=core&module=members&controller=profile&id={$row['member_id']}&do=solutions", 'front', 'profile_solutions', array( Friendly::seoTitle( $row['name'] ) ) );
|
||||
@@ -83,15 +84,18 @@ class _solvers extends Controller
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $url, TRUE, $count );
|
||||
},
|
||||
'date' => function( $val ) {
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
if( $val )
|
||||
{
|
||||
return (string) DateTime::ts( $val );
|
||||
}
|
||||
},
|
||||
'member_group_id' => function( $val ) {
|
||||
return \IPS\Member\Group::load( $val )->name;
|
||||
return Group::load( $val )->name;
|
||||
}
|
||||
);
|
||||
|
||||
$groups = array();
|
||||
foreach( \IPS\Member\Group::groups( showGuestGroups: FALSE ) AS $group )
|
||||
foreach( Group::groups( showGuestGroups: FALSE ) AS $group )
|
||||
{
|
||||
$groups[ $group->g_id ] = $group->name;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Db;
|
||||
@@ -32,48 +35,47 @@ use const IPS\Helpers\Table\SEARCH_NODE;
|
||||
use const IPS\Helpers\Table\SEARCH_MEMBER;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* topics
|
||||
*/
|
||||
class _topics extends Controller
|
||||
class topics 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;
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'topics_manage' );
|
||||
|
||||
$tabs = array( 'total' => 'stats_topics_tab_total' );
|
||||
|
||||
if( Db::i()->select( 'COUNT(*)', 'forums_forums', array( 'topics>?', 0 ) )->first() )
|
||||
{
|
||||
$tabs['byforum'] = 'stats_topics_tab_byforum';
|
||||
}
|
||||
|
||||
if ( Db::i()->select( 'COUNT(*)', 'forums_topics', static::_noPostsWhere() )->first() )
|
||||
{
|
||||
$tabs['noposts'] = 'stats_topics_tab_noposts';
|
||||
}
|
||||
if( Db::i()->select( 'COUNT(*)', 'forums_forums', array( 'topics>?', 0 ) )->first() )
|
||||
{
|
||||
$tabs['byforum'] = 'stats_topics_tab_byforum';
|
||||
}
|
||||
|
||||
if ( Db::i()->select( 'COUNT(*)', 'forums_topics', static::_noPostsWhere() )->first() )
|
||||
{
|
||||
$tabs['noposts'] = 'stats_topics_tab_noposts';
|
||||
}
|
||||
|
||||
Request::i()->tab ??= 'total';
|
||||
$activeTab = ( array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'total';
|
||||
@@ -89,26 +91,26 @@ class _topics extends Controller
|
||||
Output::i()->output = (string) $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__forums_stats_topics');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $output, Url::internal( "app=forums&module=stats&controller=topics" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Topics with No Posts Table
|
||||
*
|
||||
* @return \IPS\Helpers\Table\Db
|
||||
* @return TableDb
|
||||
*/
|
||||
protected function _noPostsTable(): TableDb
|
||||
{
|
||||
/* Load Forums into Memory */
|
||||
Forum::loadIntoMemory( NULL );
|
||||
|
||||
|
||||
$table = new TableDb( 'forums_topics', Url::internal( "app=forums&module=stats&controller=topics&tab=noposts" ), static::_noPostsWhere() );
|
||||
$table->langPrefix = 'topics_noposts_';
|
||||
$table->include = array( 'tid', 'title', 'state', 'start_date', 'starter_id', 'views', 'forum_id', 'approved' );
|
||||
|
||||
|
||||
$table->parsers = array(
|
||||
'title' => function( $val, $row )
|
||||
{
|
||||
@@ -125,7 +127,7 @@ class _topics extends Controller
|
||||
},
|
||||
'start_date' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
return (string) DateTime::ts( $val );
|
||||
},
|
||||
'starter_id' => function( $val, $row )
|
||||
{
|
||||
@@ -147,7 +149,7 @@ class _topics extends Controller
|
||||
{
|
||||
$guest->name = $row['starter_name'];
|
||||
}
|
||||
|
||||
|
||||
return $guest->name;
|
||||
}
|
||||
}
|
||||
@@ -167,7 +169,7 @@ class _topics extends Controller
|
||||
{
|
||||
$title = $forum->_title;
|
||||
}
|
||||
|
||||
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $forum->url(), TRUE, $title );
|
||||
},
|
||||
'approved' => function( $val )
|
||||
@@ -182,21 +184,21 @@ class _topics extends Controller
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$table->filters = array(
|
||||
'open' => "state='open'",
|
||||
'locked' => "state='closed'",
|
||||
'approved' => "approved=1",
|
||||
'unapproved' => "approved=0"
|
||||
);
|
||||
|
||||
|
||||
$table->advancedSearch['forum_id'] = array( SEARCH_NODE, array( 'class' => 'IPS\\forums\\Forum', 'clubs' => TRUE ) );
|
||||
$table->advancedSearch['starter_id'] = SEARCH_MEMBER;
|
||||
$table->advancedSearch['start_date'] = SEARCH_DATE_RANGE;
|
||||
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get No Posts Where Clause
|
||||
*
|
||||
@@ -211,7 +213,7 @@ class _topics extends Controller
|
||||
$where[] = array( Db::i()->in( 'approved', array( 0, 1 ) ) );
|
||||
$where[] = array( Db::i()->in( 'forum_id', Db::i()->select( 'id', 'forums_forums' ) ) );
|
||||
$where[] = array( Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) );
|
||||
|
||||
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user