Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,68 +11,85 @@
|
||||
namespace IPS\core\modules\front\system;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\Controller;
|
||||
use IPS\core\Announcements\Announcement as AnnouncementClass;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Http\Url\Exception;
|
||||
use IPS\Http\Url\Friendly;
|
||||
use IPS\Http\Url\Internal;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Announcement
|
||||
*/
|
||||
class _announcement extends \IPS\Content\Controller
|
||||
class announcement extends Controller
|
||||
{
|
||||
/**
|
||||
* [Content\Controller] Class
|
||||
*/
|
||||
protected static $contentModel = 'IPS\core\Announcements\Announcement';
|
||||
protected static string $contentModel = 'IPS\core\Announcements\Announcement';
|
||||
|
||||
/**
|
||||
* View Announcement
|
||||
*
|
||||
* @return void
|
||||
* @return mixed
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : mixed
|
||||
{
|
||||
parent::manage();
|
||||
|
||||
/* Load announcement */
|
||||
try
|
||||
{
|
||||
$announcement = \IPS\core\Announcements\Announcement::load( \IPS\Request::i()->id );
|
||||
$announcement = AnnouncementClass::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'announcement_missing', '2C199/1', 404, '' );
|
||||
Output::i()->error( 'announcement_missing', '2C199/1', 404, '' );
|
||||
}
|
||||
if ( !$announcement->canView() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error_no_perm', '2C199/2', 403, '' );
|
||||
Output::i()->error( 'node_error_no_perm', '2C199/2', 403, '' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$announcementHtml = \IPS\Theme::i()->getTemplate( 'system' )->announcement( $announcement );
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
$announcementHtml = Theme::i()->getTemplate( 'system' )->announcement( $announcement );
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $announcementHtml );
|
||||
Output::i()->sendOutput( $announcementHtml );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if the site is offline, use the minimal layout */
|
||||
if ( ( !\IPS\Settings::i()->site_online and !\IPS\Member::loggedIn()->group['g_access_offline'] ) OR ( !\IPS\Member::loggedIn()->member_id AND !\IPS\Member::loggedIn()->group['g_view_board'] ) )
|
||||
if ( ( !Settings::i()->site_online and !Member::loggedIn()->group['g_access_offline'] ) OR ( !Member::loggedIn()->member_id AND !Member::loggedIn()->group['g_view_board'] ) )
|
||||
{
|
||||
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
\IPS\Output::i()->allowDefaultWidgets = FALSE;
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
Output::i()->allowDefaultWidgets = FALSE;
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
}
|
||||
|
||||
/* Set Session Location */
|
||||
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=core&module=system&controller=announcement&id=' . $announcement->id, NULL, 'announcement', $announcement->seo_title ), array(), 'loc_viewing_announcement', array( $announcement->title => FALSE ) );
|
||||
Session::i()->setLocation( Url::internal( 'app=core&module=system&controller=announcement&id=' . $announcement->id, NULL, 'announcement', $announcement->seo_title ), array(), 'loc_viewing_announcement', array( $announcement->title => FALSE ) );
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $announcement->title );
|
||||
\IPS\Output::i()->output = $announcementHtml;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( $announcement->title );
|
||||
Output::i()->output = $announcementHtml;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,35 +97,35 @@ class _announcement extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function permissionCheck()
|
||||
protected function permissionCheck() : void
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->modPermission( 'can_manage_announcements' ) )
|
||||
if ( !Member::loggedIn()->modPermission( 'can_manage_announcements' ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2C185/1', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '2C185/1', 403, '' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$url = \IPS\Http\Url::createFromString( \IPS\Request::i()->url, TRUE );
|
||||
$url = Url::createFromString( Request::i()->url );
|
||||
}
|
||||
catch( \IPS\Http\Url\Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'status' => 'unexpected_format' ) );
|
||||
Output::i()->json( array( 'status' => 'unexpected_format' ) );
|
||||
}
|
||||
|
||||
/* Make sure this is a local URL */
|
||||
if( !( $url instanceof \IPS\Http\Url\Internal ) )
|
||||
if( !( $url instanceof Internal ) )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'status' => 'not_local' ) );
|
||||
Output::i()->json( array( 'status' => 'not_local' ) );
|
||||
}
|
||||
|
||||
/* Get the definition */
|
||||
$furlDefinition = \IPS\Http\Url\Friendly::furlDefinition();
|
||||
$furlDefinition = Friendly::furlDefinition();
|
||||
|
||||
/* If we don't have a validate callback, we can return NULL */
|
||||
if ( !isset( $furlDefinition[ $url->seoTemplate ]['verify'] ) or !$furlDefinition[ $url->seoTemplate ]['verify'] )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'status' => 'not_verified' ) );
|
||||
Output::i()->json( array( 'status' => 'not_verified' ) );
|
||||
}
|
||||
|
||||
$class = $furlDefinition[ $url->seoTemplate ]['verify'];
|
||||
@@ -117,7 +134,7 @@ class _announcement extends \IPS\Content\Controller
|
||||
/* If the class does not have our method, return a not_verified status */
|
||||
if( !method_exists( $item, 'cannotViewGroups' ) )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'status' => 'not_verified' ) );
|
||||
Output::i()->json( array( 'status' => 'not_verified' ) );
|
||||
}
|
||||
|
||||
/* Get groups that cannot view the item */
|
||||
@@ -125,9 +142,9 @@ class _announcement extends \IPS\Content\Controller
|
||||
|
||||
if( !$groups )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'status' => 'all_permissions' ) );
|
||||
Output::i()->json( array( 'status' => 'all_permissions' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( array( 'html' => \IPS\Theme::i()->getTemplate( 'modcp', 'core', 'front' )->announcementGroupCheck( $groups ) ) );
|
||||
Output::i()->json( array( 'html' => Theme::i()->getTemplate( 'modcp', 'core', 'front' )->announcementGroupCheck( $groups ) ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user