Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+48 -2
View File
@@ -239,6 +239,16 @@ abstract class _Widget
return method_exists( $this, 'configuration' );
}
/**
* Before the widget is removed, we can do some clean up
*
* @return void
*/
public function delete()
{
/* Does nothing by default but can be overridden */
}
/**
* Factory Method
*
@@ -702,6 +712,15 @@ abstract class _Widget
/* Wrap the whole thing in a try/catch because exceptions in __toString confuses PHP */
try
{
/* Put the app check here as it needs to check the member's secondary groups but the PermissionCache only stores the primary group IDs */
if ( $this->app )
{
if ( ! $this->application()->canAccess( \IPS\Member::loggedIn() ) )
{
return '';
}
}
/* If we're not caching (e.g. dynamic blocks in Pages), just return it */
if ( $this->neverCache === TRUE )
{
@@ -717,7 +736,7 @@ abstract class _Widget
/* How long does the store last (in seconds)? Individual widgets can set a higher expiration where sensible (e.g. upcoming calendar events
can be cached for a day regardless of this setting) but not lower */
$expiration = \IPS\Settings::i()->widget_cache_ttl;
if ( isset( $this->cacheExpiration ) and $this->cacheExpiration < $expiration )
if ( isset( $this->cacheExpiration ) and $this->cacheExpiration > $expiration )
{
$expiration = $this->cacheExpiration;
}
@@ -831,7 +850,34 @@ abstract class _Widget
return $output;
}
/**
* Empty the widget trash
*
* @param int $seconds Seconds old to remove
* @return void
*/
public static function emptyTrash( $seconds=86400 )
{
foreach( \IPS\Db::i()->select( '*', 'core_widget_trash', array( array( 'date < ?', time() - $seconds ) ) ) as $row )
{
$data = json_decode( $row['data'], TRUE );
if ( ! empty( $data['app'] ) and ! empty( $data['key'] ) and ! empty( $data['unique'] ) )
{
$widget = static::load( \IPS\Application::load( $data['app'] ), $data['key'], $data['unique'], isset( $data['configuration'] ) ? $data['configuration'] : NULL );
try
{
$widget->delete();
}
catch( \Exception $ex ) { }
}
}
\IPS\Db::i()->delete( 'core_widget_trash', array( 'date < ?', time() - $seconds ) );
}
/**
* Build the where clause based on key, app, plugin
*