Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -71,14 +71,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'archive_manage' );
|
||||
|
||||
if ( \IPS\CIC2 )
|
||||
{
|
||||
return \IPS\Cicloud\getForumArchiveForm();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->manageArchivingForm();
|
||||
}
|
||||
return $this->manageArchivingForm();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,92 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Show solved posts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function showSolvedPosts()
|
||||
{
|
||||
/* 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->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' ) );
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'solved_date' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->html();
|
||||
},
|
||||
'comment_id' => function( $val, $row )
|
||||
{
|
||||
$class = $row['comment_class'];
|
||||
|
||||
try
|
||||
{
|
||||
$item = $class::load( $row['comment_id'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'ipsPad' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show solved posts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function showRecommendedPosts()
|
||||
{
|
||||
/* 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->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' ) );
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'meta_added' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->html();
|
||||
},
|
||||
'meta_data' => function( $val, $row )
|
||||
{
|
||||
$data = json_decode( $val, TRUE );
|
||||
|
||||
try
|
||||
{
|
||||
$item = \IPS\forums\Topic\Post::load( $data['comment'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'ipsPad' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
@@ -42,10 +128,56 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'posts_manage' );
|
||||
|
||||
$tabs = array( 'total' => 'stats_posts_tab_total', 'byforum' => 'stats_posts_tab_byforum' );
|
||||
$tabs = array( 'total' => 'stats_posts_tab_total', 'bytype' => 'stats_posts_by_type', 'byforum' => 'stats_posts_tab_byforum' );
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'total';
|
||||
|
||||
if ( $activeTab === 'total' )
|
||||
if ( $activeTab === 'bytype' )
|
||||
{
|
||||
$defaults = array( 'start' => \IPS\DateTime::create()->setDate( date('Y'), date('m'), 1 ), 'end' => new \IPS\DateTime );
|
||||
|
||||
if( isset( \IPS\Request::i()->badgeDateStart ) AND isset( \IPS\Request::i()->badgeDateEnd ) )
|
||||
{
|
||||
$defaults = array( 'start' => \IPS\DateTime::ts( \IPS\Request::i()->badgeDateStart ), 'end' => \IPS\DateTime::ts( \IPS\Request::i()->badgeDateEnd ) );
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
/* Get a count of solved posts in this time */
|
||||
$solvedCount = \IPS\Db::i()->select( 'count(*)', 'core_solved_index', [
|
||||
[ 'solved_date BETWEEN ? AND ?', $startTime, $endTime ],
|
||||
[ 'comment_class=?', 'IPS\forums\Topic\Post' ]
|
||||
] )->first();
|
||||
|
||||
/* Get a count of recommended posts in this time */
|
||||
$recommendedCount = \IPS\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 );
|
||||
}
|
||||
else if ( $activeTab === 'total' )
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts" ), 'forums_posts', 'post_date', '', array(
|
||||
'isStacked' => FALSE,
|
||||
@@ -112,6 +244,7 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
},
|
||||
'defaultSeries' => function()
|
||||
{
|
||||
$series = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'posts>?', 0 ), 'last_post desc', array( 0, 50 ) ) as $forum )
|
||||
{
|
||||
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $forum['id'] ), 'number', 'COUNT(*)', FALSE, $forum['id'] );
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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 = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( 'app=forums&module=stats&controller=questions' ), 'forums_question_ratings', 'date', '', array(
|
||||
'isStacked' => FALSE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
) );
|
||||
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack('stats_question_ratings_title');
|
||||
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart' );
|
||||
|
||||
$chart->groupBy = 'rating';
|
||||
|
||||
foreach( array( 1, -1 ) as $v )
|
||||
{
|
||||
$label = ( $v == -1 ) ? 'negative' : 'positive';
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('stats_question_ratings_' . $label ), 'number', 'COUNT(*)', TRUE, $label );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__forums_stats_questions');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +42,18 @@ class _topics extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'topics_manage' );
|
||||
|
||||
$tabs = array( 'total' => 'stats_topics_tab_total', 'byforum' => 'stats_topics_tab_byforum' );
|
||||
$tabs = array( 'total' => 'stats_topics_tab_total' );
|
||||
|
||||
if( \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', array( 'topics>?', 0 ) )->first() )
|
||||
{
|
||||
$tabs[ 'byforum'] = 'stats_topics_tab_byforum';
|
||||
}
|
||||
|
||||
if( \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', array( 'topics>? and ( forums_bitoptions & ? or forums_bitoptions & ? or forums_bitoptions & ? )', 0, 4, 8, 16 ) )->first() )
|
||||
{
|
||||
$tabs[ 'solved'] = 'stats_topics_tab_solved';
|
||||
}
|
||||
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'total';
|
||||
|
||||
if ( $activeTab === 'total' )
|
||||
@@ -63,6 +74,67 @@ class _topics extends \IPS\Dispatcher\Controller
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack( 'stats_topics_title' );
|
||||
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart' );
|
||||
}
|
||||
else if( $activeTab === 'solved' )
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=forums&module=stats&controller=topics&tab=" . $activeTab ), 'core_solved_index', 'solved_date', '', array(
|
||||
'isStacked' => FALSE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4,
|
||||
'chartArea' => array( 'width' => '70%', 'left' => '5%' ),
|
||||
'height' => 400,
|
||||
),
|
||||
'LineChart',
|
||||
'monthly',
|
||||
array( 'start' => ( new \IPS\DateTime )->sub( new \DateInterval('P90D') ), 'end' => new \IPS\DateTime ),
|
||||
array(),
|
||||
'solved'
|
||||
);
|
||||
|
||||
$chart->joins = array( array( 'forums_topics', array( 'comment_class=? and core_solved_index.item_id=forums_topics.tid', 'IPS\forums\Topic\Post' ) ) );
|
||||
$chart->where = array( array( \IPS\Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) ), array( \IPS\Db::i()->in( 'approved', array( -2, -3 ), TRUE ) ) );
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack( 'stats_topics_title_solved' );
|
||||
$chart->availableTypes = array( 'LineChart', 'ColumnChart' );
|
||||
|
||||
$chart->groupBy = 'forum_id';
|
||||
$customValues = ( isset( $chart->savedCustomFilters['chart_forums'] ) ? array_values( explode( ',', $chart->savedCustomFilters['chart_forums'] ) ) : 0 );
|
||||
|
||||
$chart->customFiltersForm = array(
|
||||
'form' => array(
|
||||
new \IPS\Helpers\Form\Node( 'chart_forums', $customValues, FALSE, array( 'class' => 'IPS\forums\Forum', 'zeroVal' => 'any', 'multiple' => TRUE, 'permissionCheck' => function ( $forum )
|
||||
{
|
||||
return $forum->sub_can_post and !$forum->redirect_url;
|
||||
} ), NULL, NULL, NULL, 'chart_forums' )
|
||||
),
|
||||
'where' => function( $values )
|
||||
{
|
||||
$forumIds = \is_array( $values['chart_forums'] ) ? array_keys( $values['chart_forums'] ) : explode( ',', $values['chart_forums'] );
|
||||
return \IPS\Db::i()->in( 'forum_id', $forumIds );
|
||||
},
|
||||
'groupBy' => 'forum_id',
|
||||
'series' => function( $values )
|
||||
{
|
||||
$series = array();
|
||||
$forumIds = \is_array( $values['chart_forums'] ) ? array_keys( $values['chart_forums'] ) : explode( ',', $values['chart_forums'] );
|
||||
foreach( $forumIds as $id )
|
||||
{
|
||||
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $id ), 'number', 'COUNT(*)', FALSE, $id );
|
||||
}
|
||||
return $series;
|
||||
},
|
||||
'defaultSeries' => function()
|
||||
{
|
||||
$series = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'topics>? and ( forums_bitoptions & ? or forums_bitoptions & ? or forums_bitoptions & ? )', 0, 4, 8, 16 ), 'last_post desc', array( 0, 50 ) ) as $forum )
|
||||
{
|
||||
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $forum['id'] ), 'number', 'COUNT(*)', FALSE, $forum['id'] );
|
||||
}
|
||||
|
||||
return $series;
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=forums&module=stats&controller=topics&tab=" . $activeTab ), 'forums_topics', 'start_date', '', array(
|
||||
@@ -113,11 +185,12 @@ class _topics extends \IPS\Dispatcher\Controller
|
||||
},
|
||||
'defaultSeries' => function()
|
||||
{
|
||||
$series = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'topics>?', 0 ), 'last_post desc', array( 0, 50 ) ) as $forum )
|
||||
{
|
||||
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $forum['id'] ), 'number', 'COUNT(*)', FALSE, $forum['id'] );
|
||||
}
|
||||
|
||||
|
||||
return $series;
|
||||
}
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user