diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2003296ea2..351b0d9107 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -48,6 +48,7 @@ v27.0.00 System: fixed PHP 8+ compatibility in CustomFieldIDs migration file System: fixed input serialization of form data in Import from File page System: fixed the file uploader to handle exif image rotation from mobile devices + System: fixed login access required message to always display the login form Activities: fixed highlight colour for Waiting List activities in View Activities Attendance: fixed handling of double periods in Set Future Absence tool Staff: fixed My Coverage page showing coverage from past years diff --git a/index.php b/index.php index 445b9f0881..8c0f6647d3 100644 --- a/index.php +++ b/index.php @@ -225,13 +225,13 @@ $session->set('sidebarExtraPosition', 'top'); // Check the current Action 'entrySidebar' to see if we should display a sidebar -$showSidebar = $page->getAction() +$page['showSidebar'] = $page->getAction() ? $page->getAction()['entrySidebar'] != 'N' : true; // Override showSidebar if the URL 'sidebar' param is explicitly set if (!empty($_GET['sidebar'])) { - $showSidebar = strtolower($_GET['sidebar']) !== 'false'; + $page['showSidebar'] = strtolower($_GET['sidebar']) !== 'false'; } /** @@ -734,18 +734,19 @@ } } } + /** * GET SIDEBAR CONTENT * * TODO: rewrite the Sidebar class as a template file. */ $sidebarContents = ''; -if ($showSidebar) { +if ($page['showSidebar']) { $page->addSidebarExtra($session->get('sidebarExtra')); $session->set('sidebarExtra', ''); $page->addData([ - 'sidebar' => $showSidebar, + 'sidebar' => $page['showSidebar'], 'sidebarContents' => $container->get(Gibbon\UI\Components\Sidebar::class)->getOutput(), 'sidebarPosition' => $session->get('sidebarExtraPosition'), ]); diff --git a/src/View/Page.php b/src/View/Page.php index 21793ae4d7..7b88547f37 100644 --- a/src/View/Page.php +++ b/src/View/Page.php @@ -267,6 +267,11 @@ public function getAllScripts(string $context = null): array */ public function addError(string $text) { + // Override to always display the sidebar when pages are inaccessible + if ($text == __('You do not have access to this action.') && empty($this['isLoggedIn'])) { + $this['showSidebar'] = true; + } + $this->addAlert($text, 'error'); }