Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+34 -18
View File
@@ -17,6 +17,7 @@ use Exception;
use IPS\Application;
use IPS\Application\Module;
use IPS\cms\Pages\Page;
use IPS\cms\Records;
use IPS\Content\Item;
use IPS\core\AdminNotification;
use IPS\core\DataLayer;
@@ -445,7 +446,7 @@ class ajax extends Controller
}
/* Render */
$output = Theme::i()->getTemplate( 'widgets' )->topContributorRows( $topContributors, $timeframe, Request::i()->orientation );
$output = Theme::i()->getTemplate( 'widgets' )->topContributorRows( $topContributors, $timeframe, Request::i()->layout, Request::i()->isCarousel );
if ( Request::i()->isAjax() )
{
Output::i()->sendOutput( $output );
@@ -511,7 +512,7 @@ class ajax extends Controller
}
/* Render */
$output = Theme::i()->getTemplate( 'widgets' )->mostSolvedRows( $topSolved, $timeframe, Request::i()->orientation );
$output = Theme::i()->getTemplate( 'widgets' )->mostSolvedRows( $topSolved, $timeframe, Request::i()->layout, Request::i()->isCarousel );
if ( Request::i()->isAjax() )
{
Output::i()->sendOutput( $output );
@@ -827,13 +828,14 @@ class ajax extends Controller
public function getDataLayerEvents() : void
{
$payload = '{}';
if ( Settings::i()->core_datalayer_enabled AND Member::loggedIn()->member_id )
if ( DataLayer::enabled() AND Member::loggedIn()->member_id )
{
$payload = DataLayer::i()->jsonEvents;
DataLayer::i()->clearCache();
}
/* Using this instead of \IPS\Output::i()->json because it's already JSON encoded */
/* We have to set this before invoking sendOutput to prevent the data layer events from being cached all over again in the session */
Output::i()->bypassDataLayer = true;
Output::i()->sendOutput( Member::loggedIn()->language()->stripVLETags( $payload ), 200, 'application/json', Output::i()->httpHeaders );
}
@@ -867,17 +869,19 @@ class ajax extends Controller
Output::i()->redirect( Url::internal( '' ) );
}
/* Is there a widget in the request? */
if ( !is_string( Request::i()->blockID ) or empty( Request::i()->blockID ) )
{
Output::i()->json( [ "No block id present in the request" ], 400 );
}
/* In this case, let's see if the block exists at all */
foreach ( ['pageApp', 'pageModule', 'pageController', 'pageID', 'pageArea'] as $pageParam )
/* Note - pageID is the ID of the CMS page (if there is one) while pageElse is the ID of the content in the page (e.g. records, topics, blogs, etc) */
foreach ( ['pageApp', 'pageModule', 'pageController', 'pageID', 'pageArea', 'pageElse', 'pageContentClass'] as $pageParam )
{
$$pageParam = Request::i()->$pageParam;
}
$item = null;
try
{
// If they're not a member, they definitely don't have permission
@@ -892,18 +896,28 @@ class ajax extends Controller
}
$canEdit = false;
$itemId = $pageID ?: Request::i()->pageElse;
if ( $pageApp and $pageModule and $pageController and is_numeric( $itemId ) )
$itemId = $pageID ?: $pageElse;
if ( is_numeric( $itemId ) )
{
$controllerClass = "\\IPS\\{$pageApp}\\modules\\front\\{$pageModule}\\{$pageController}";
if ( class_exists( $controllerClass ) && is_subclass_of( $controllerClass, ContentController::class ) )
// first, check the content class directly
if ( is_numeric( $pageElse ) and isset( $pageContentClass ) and class_exists( $pageContentClass ) and is_subclass_of( $pageContentClass, Item::class ) )
{
$item = $controllerClass::loadItem( (int) $itemId );
if ( $item instanceof Item and $item->author()?->member_id === Member::loggedIn()->member_id ) /* todo we may want to add a mod permission as well; for now we just do an author check */
$item = $pageContentClass::load( $pageElse );
}
else if ( $pageApp and $pageModule and $pageController ) // Still haven't verified permission? Check permissions to edit the CMS page itself
{
$controllerClass = "\\IPS\\{$pageApp}\\modules\\front\\{$pageModule}\\{$pageController}";
if ( class_exists( $controllerClass ) && is_subclass_of( $controllerClass, ContentController::class ) )
{
$canEdit = true;
$item = $controllerClass::loadItem( (int)$itemId );
}
}
if ( $item instanceof Item and $item->author()?->member_id === Member::loggedIn()->member_id )
{
$canEdit = true;
}
}
if ( !$canEdit && $app->canManageWidgets() )
@@ -959,15 +973,17 @@ class ajax extends Controller
$items = json_decode( Request::i()->items, true ) ?: [];
if ( is_array( $items ) )
{
Db::i()->replace( 'core_table_of_contents', [
$contentId = strval( $pageElse ?: $pageID ) ?: null;
$insert = [
'contents' => json_encode( $items ),
'app' => $pageApp,
'controller' => $pageController,
'module' => $pageModule,
'key' => strval( $pageID ?: Request::i()->pageElse ) ?: null
]);
'key' => $contentId ? ( $item instanceof Records ? $item::class . "_" : '' ) . $contentId : null
];
Db::i()->insert( 'core_table_of_contents', $insert, true );
Widget::deleteCaches( Request::i()->blockID );
Widget::deleteCaches( 'tableofcontents' );
}
else
{
@@ -1006,7 +1022,7 @@ class ajax extends Controller
$timestamps = array_map( "intval", explode( ",", Request::i()->timestamps ) );
if ( count( $timestamps ) )
{
$lang = Lang::defaultLanguage() ? Lang::load( Lang::defaultLanguage() ) : Member::loggedIn()->language();
$lang = Member::loggedIn()->language() ?: Lang::load( Lang::defaultLanguage() );
foreach ( $timestamps as $timestamp )
{
// we cache based on how different the time is compared to the current time