Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\activitystats;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _reactions extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -89,6 +94,43 @@ class _reactions extends \IPS\Dispatcher\Controller
}
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();
@@ -99,11 +141,11 @@ class _reactions extends \IPS\Dispatcher\Controller
}
elseif( $activeTab == 'givers' )
{
$query = \IPS\Db::i()->select( 'MAX(id) as id, SUM(rep_rating) as rating', 'core_reputation_index', NULL, 'rating DESC', array( 0, 20 ), array( 'member_id' ) );
$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', NULL, 'rating DESC', array( 0, 20 ), array( 'member_received' ) );
$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 )
@@ -129,6 +171,8 @@ class _reactions extends \IPS\Dispatcher\Controller
$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' );
@@ -165,7 +209,7 @@ class _reactions extends \IPS\Dispatcher\Controller
return \IPS\Theme::i()->getTemplate( 'activitystats' )->contentCell( $item );
}
catch( \Exception $e )
catch ( \Throwable $e )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
}
@@ -173,12 +217,18 @@ class _reactions extends \IPS\Dispatcher\Controller
);
}
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' );
}