Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

@@ -115,7 +115,7 @@ class _Announcement extends \IPS\Content\Item
$announcement = static::constructFromData( $announce );
/* Check page location, active status and permissions */
if( !in_array( $location, $announcement->page_location ) OR !$announcement->active OR ( $announcement->end !== 0 AND $announcement->end <= time() ) OR !$announcement->canView() )
if( !in_array( $location, $announcement->page_location ) OR !$announcement->active OR ( $announcement->start !== 0 AND $announcement->start >= time() ) OR ( $announcement->end !== 0 AND $announcement->end <= time() ) OR !$announcement->canView() )
{
continue;
}
@@ -127,36 +127,64 @@ class _Announcement extends \IPS\Content\Item
continue;
}
/* App and container specific announcements */
foreach ( \IPS\Dispatcher::i()->application->extensions( 'core', 'Announcements' ) as $key => $extension )
/* If the dispatcher did not finish loading (perhaps we hit an error that occurred early in execution) we can't check per-app locations */
if( !\IPS\Dispatcher::i()->application )
{
$id = $extension::$idField;
continue;
}
if ( isset( \IPS\Request::i()->$id ) )
$extensions = \IPS\Dispatcher::i()->application->extensions( 'core', 'Announcements' );
/* If we have no extension, we can only check the global setting */
if ( !$extensions AND $announcement->app == \IPS\Dispatcher::i()->application->directory )
{
$return[] = $announcement;
}
else
{
/* App and container specific announcements */
foreach ( $extensions as $key => $extension )
{
if ( \IPS\Dispatcher::i()->dispatcherController instanceof \IPS\Content\Controller )
$id = $extension::$idField;
if ( $announcement->ids AND isset( \IPS\Request::i()->$id ) )
{
foreach( \IPS\Dispatcher::i()->application->extensions( 'core', 'ContentRouter' ) AS $contentRouter )
/* Are we viewing a content item */
if ( \IPS\Dispatcher::i()->dispatcherController instanceof \IPS\Content\Controller )
{
foreach( $contentRouter->classes AS $class )
foreach( \IPS\Dispatcher::i()->application->extensions( 'core', 'ContentRouter' ) AS $contentRouter )
{
try
foreach( $contentRouter->classes AS $class )
{
if( $announcement->location == $key AND in_array( $class::load( \IPS\Request::i()->$id )->mapped('container'), explode( ',', $announcement->ids ) ) )
try
{
$return[] = $announcement;
if( $announcement->location == $key AND in_array( $class::load( \IPS\Request::i()->$id )->mapped('container'), explode( ',', $announcement->ids ) ) )
{
$return[] = $announcement;
}
}
catch( \OutOfRangeException $e ){}
}
catch( \OutOfRangeException $e ){}
break 2;
}
}
/* Or are we inside an allowed controller */
else if ( in_array( get_class( \IPS\Dispatcher::i()->dispatcherController ), $extension::$controllers ) )
{
try
{
if( $announcement->location == $key AND in_array( \IPS\Request::i()->$id , explode( ',', $announcement->ids ) ) )
{
$return[] = $announcement;
}
}
catch( \OutOfRangeException $e ){}
}
}
/* App specific, doesn't matter which container we're in */
elseif( $announcement->location == $key AND !$announcement->ids )
{
$return[] = $announcement;
}
}
/* App specific, doesn't matter which container we're in */
elseif( $announcement->location == $key )
{
$return[] = $announcement;
}
}
}
@@ -281,6 +309,10 @@ class _Announcement extends \IPS\Content\Item
$obj->page_location = $values['announce_page_location'];
$obj->color = $values['announce_color'];
/* We need to set the data, before we then iterate over the toggled extension form fields */
$obj->location = "*";
$obj->ids = NULL;
if( in_array( $obj->app, array_keys(\IPS\Application::applications() ) ) )
{
foreach ( \IPS\Application::load( $obj->app )->extensions( 'core', 'Announcements' ) as $key => $extension )
@@ -293,11 +325,6 @@ class _Announcement extends \IPS\Content\Item
}
}
}
else
{
$obj->location = "*";
$obj->ids = NULL;
}
$obj->save();
@@ -357,7 +384,7 @@ class _Announcement extends \IPS\Content\Item
*/
protected function unclaimAttachments()
{
\IPS\File::unclaimAttachments( 'core_Admin', $this->id, NULL, 'announcement' );
\IPS\File::unclaimAttachments( 'core_Announcement', $this->id, NULL, 'announcement' );
}
/**
@@ -377,7 +404,8 @@ class _Announcement extends \IPS\Content\Item
if( $type == 'hide' OR $type == 'unhide' OR $type == 'active' OR $type == 'inactive' )
{
return TRUE;
$member = $member ?: \IPS\Member::loggedIn();
return $member->modPermission( "can_manage_announcements" );
}
return parent::modPermission( $type, $member, $container );