Skip to content

Commit

Permalink
System: fixed login access required message to always display the log…
Browse files Browse the repository at this point in the history
…in form
  • Loading branch information
SKuipers committed Feb 2, 2024
1 parent 092da3f commit 74373a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

/**
Expand Down Expand Up @@ -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'),
]);
Expand Down
5 changes: 5 additions & 0 deletions src/View/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit 74373a7

Please sign in to comment.