Version 4.7.23

This commit is contained in:
Neo committed 2025-12-19 16:21:27 -08:00
1 parent 7124a02564
commit 25ddeb65d6
1791 files changed
+76990 -44452

No files matched your search

@@ -49,7 +49,7 @@ class _Cards
try
{
$forum = \IPS\forums\Forum::constructFromData( $file );
$forum->icon = \IPS\File::get( $oldConfiguration ?: 'forums_Cards', $forum->icon )->move( $storageConfiguration );
$forum->card_image = \IPS\File::get( $oldConfiguration ?: 'forums_Cards', $forum->card_image )->move( $storageConfiguration );
$forum->save();
}
catch( \Exception $e )
@@ -68,9 +68,9 @@ class _Cards
{
$forum = \IPS\forums\Forum::constructFromData( \IPS\Db::i()->select( '*', 'forums_forums', 'card_image IS NOT NULL', 'id', array( $offset, 1 ) )->first() );
if ( $new = \IPS\File::repairUrl( $forum->icon ) )
if ( $new = \IPS\File::repairUrl( $forum->card_image ) )
{
$forum->icon = $new;
$forum->card_image = $new;
$forum->save();
}
}
@@ -105,7 +105,7 @@ class _Cards
{
try
{
\IPS\File::get( 'forums_Cards', $forum['icon'] )->delete();
\IPS\File::get( 'forums_Cards', $forum['card_image'] )->delete();
}
catch( \Exception $e ){}
}
@@ -25,7 +25,7 @@ class _PercentageSolved extends \IPS\core\Statistics\Chart
/**
* @brief Controller
*/
public $controller = NULL;
public $controller = 'forums_stats_solved_percentage';
/**
* Render Chart
@@ -86,7 +86,7 @@ class _PostsByForum extends \IPS\core\Statistics\Chart
'defaultSeries' => function()
{
$series = array();
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'posts>?', 0 ), 'last_post desc', array( 0, 50 ) ) as $forum )
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'posts>? AND club_id IS NULL', 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'] );
}
@@ -25,7 +25,7 @@ class _SolvedByForum extends \IPS\core\Statistics\Chart
/**
* @brief Controller
*/
public $controller = NULL;
public $controller = 'forums_stats_solved_solved';
/**
* Render Chart
@@ -89,16 +89,33 @@ class _SolvedByForum extends \IPS\core\Statistics\Chart
'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 );
if ( count( $forumIds ) )
{
return \IPS\Db::i()->in( 'forum_id', $forumIds );
}
else
{
return '';
}
},
'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 )
$forumIds = array_filter( \is_array( $values['chart_forums'] ) ? array_keys( $values['chart_forums'] ) : explode( ',', $values['chart_forums'] ) );
if ( count( $forumIds ) )
{
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $id ), 'number', 'COUNT(*)', FALSE, $id );
foreach( $forumIds as $id )
{
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $id ), 'number', 'COUNT(*)', FALSE, $id );
}
}
else
{
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;
},
@@ -0,0 +1,166 @@
<?php
/**
* @brief Statistics Chart Extension
* @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/
* @subpackage Forums
* @since 15 Dec 2023
*/
namespace IPS\forums\extensions\core\Statistics;
use IPS\core\Statistics\Chart as ParentClass;
use IPS\Db;
use IPS\Helpers\Chart;
use IPS\Helpers\Chart\Database as DbChart;
use IPS\Http\Url;
use IPS\DateTime as IPSDateTime;
use IPS\Member;
use IPS\Helpers\Form\Select;
use IPS\Member\Group;
use UnderflowException;
use DateInterval;
use Exception;
use function defined;
use function header;
/* 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;
}
/**
* Statistics Chart Extension
*/
class _SolvedByGroup extends ParentClass
{
/**
* @brief Controller
*/
public $controller = 'forums_stats_solved_groups';
/**
* Render Chart
*
* @param \IPS\Http\Url $url URL the chart is being shown on.
* @return \IPS\Helpers\Chart
*/
public function getChart( Url $url ): Chart
{
/* Determine minimum date */
$minimumDate = NULL;
/* We can't retrieve any stats prior to the new tracking being implemented */
try
{
$oldestLog = \IPS\Db::i()->select( 'MIN(time)', 'core_statistics', array( 'type=?', 'solved' ) )->first();
if( !$minimumDate OR $oldestLog < $minimumDate->getTimestamp() )
{
$minimumDate = \IPS\DateTime::ts( $oldestLog );
}
}
catch( \UnderflowException $e )
{
/* We have nothing tracked, set minimum date to today */
$minimumDate = \IPS\DateTime::create();
}
$chart = new \IPS\Helpers\Chart\Database( $url, '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->setExtension( $this );
$chart->joins = array( array( 'forums_posts', array( 'comment_class=? and core_solved_index.comment_id=forums_posts.pid', 'IPS\forums\Topic\Post' ) ), array( 'core_members', array( "core_members.member_id=forums_posts.author_id" ) ) );
$chart->where = array( array( 'queued=?', 0 ) );
$chart->title = \IPS\Member::loggedIn()->language()->addToStack( 'stats_topics_tab_groups' );
$chart->availableTypes = array( 'LineChart', 'ColumnChart' );
$chart->groupBy = 'member_group_id';
$customValues = ( isset( $chart->savedCustomFilters['chart_groups'] ) ? array_values( explode( ',', $chart->savedCustomFilters['chart_groups'] ) ) : 0 );
$chart->customFiltersForm = array(
'form' => array(
new \IPS\Helpers\Form\Select( 'chart_groups', $customValues, FALSE, array( 'options' => $this->_getGroups(), 'zeroVal' => 'any', 'multiple' => TRUE ), NULL, NULL, NULL, 'chart_groups' )
),
'where' => function( $values )
{
$groups = \is_array( $values['chart_groups'] ) ? array_values( $values['chart_groups'] ) : explode( ',', $values['chart_groups'] );
if ( count( $groups ) )
{
return \IPS\Db::i()->in( 'member_group_id', $groups );
}
else
{
return '';
}
},
'groupBy' => 'member_group_id',
'series' => function( $values )
{
$series = array();
$groups = array_filter( \is_array( $values['chart_groups'] ) ? array_values( $values['chart_groups'] ) : explode( ',', $values['chart_groups'] ) );
if ( count( $groups ) )
{
foreach( $groups as $id )
{
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'core_group_' . $id ), 'number', 'COUNT(*)', FALSE, $id );
}
}
else
{
foreach( $this->_getGroups() AS $id => $group )
{
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'core_group_' . $id ), 'number', 'COUNT(*)', FALSE, $id );
}
}
return $series;
},
'defaultSeries' => function()
{
$series = array();
foreach( $this->_getGroups() AS $id => $group )
{
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'core_group_' . $id ), 'number', 'COUNT(*)', FALSE, $id );
}
return $series;
}
);
return $chart;
}
/**
* Groups
*
* @return array
*/
protected function _getGroups(): array
{
$return = array();
foreach( \IPS\Member\Group::groups( TRUE, FALSE ) AS $group )
{
$return[ $group->g_id ] = $group->name;
}
return $return;
}
}
@@ -25,7 +25,7 @@ class _TimeSolved extends \IPS\core\Statistics\Chart
/**
* @brief Controller
*/
public $controller = NULL;
public $controller = 'forums_stats_solved_time';
/**
* Render Chart
@@ -91,11 +91,12 @@ class _TimeSolved extends \IPS\core\Statistics\Chart
protected function getValidForumIds()
{
$validForumIds = [];
foreach( \IPS\Db::i()->select( 'value_1', 'core_statistics', [ 'type=?', 'solved' ], NULL, NULL, 'value_1' ) as $forumId )
foreach( \IPS\Db::i()->select( 'value_1', 'core_statistics', [ 'value_4 IS NOT NULL and type=?', 'solved' ], NULL, [ 0,100 ], 'value_1' ) as $forumId )
{
try
{
/* @var $forumId int */
$validForumIds[ $forumId ] = \IPS\forums\Forum::load( $forumId );
}
catch( \Exception $e ) { }
@@ -52,7 +52,7 @@ class _TopicsByForum extends \IPS\core\Statistics\Chart
);
$chart->setExtension( $this );
$chart->where = array( array( \IPS\Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) ), array( \IPS\Db::i()->in( 'approved', array( -2, -3 ), TRUE ) ) );
$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_byforum' );
$chart->availableTypes = array( 'ColumnChart' );
@@ -85,7 +85,7 @@ class _TopicsByForum extends \IPS\core\Statistics\Chart
'defaultSeries' => function()
{
$series = array();
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'topics>?', 0 ), 'last_post desc', array( 0, 50 ) ) as $forum )
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'topics>? AND club_id IS NULL', 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'] );
}