From 4244acfb4d1f17f0b5b4b51475fc8b2666375a54 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 24 Dec 2023 14:08:41 +0100 Subject: [PATCH] Header/Footer items config: Add configurable permissions --- config/config.default.php | 12 ++++++++++-- resources/views/layouts/parts/footer.twig | 14 +++++++++----- resources/views/layouts/parts/navbar.twig | 18 ++++++++++++------ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index 0972a2ff..2988fc48 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -32,14 +32,22 @@ return [ // Available link placeholders: %lang% // To disable a header_item in the config.php, you can set its value to null 'header_items' => [ - //'Foo' => 'https://foo.bar/batz-%lang%.html', + // 'Name' => 'URL', + // 'Name' => ['URL', 'permission'], + // Name can be a translation string, permission is a engelsystem privilege + + //'Foo' => ['https://foo.bar/batz-%lang%.html', 'logout'], // Permission: for logged-in users ], // Footer links // To disable a footer item in the config.php, you can set its value to null 'footer_items' => [ + // 'Name' => 'URL', + // 'Name' => ['URL', 'permission'], + // Name can be a translation string, permission is a engelsystem privilege + // URL to the angel faq and job description - 'FAQ' => env('FAQ_URL', '/faq'), + 'faq.faq' => [env('FAQ_URL', '/faq'), 'faq.view'], // Contact email address, linked on every page 'Contact' => env('CONTACT_EMAIL', 'mailto:ticket@c3heaven.de'), diff --git a/resources/views/layouts/parts/footer.twig b/resources/views/layouts/parts/footer.twig index 72d9ff61..a266af5f 100644 --- a/resources/views/layouts/parts/footer.twig +++ b/resources/views/layouts/parts/footer.twig @@ -36,11 +36,15 @@ {% endif %} {% endblock %} - {% for name,url in config('footer_items') %} - - {% if '@' in url %}{{ m.icon('envelope') }}{% endif %} - {{ __(name) }} - · + {% for name,opt in config('footer_items') %} + {% set url = opt is iterable ? opt[0] : opt %} + {% set permission = opt is iterable ? opt[1] : null %} + {% if not permission or has_permission_to(permission) %} + + {% if '@' in url %}{{ m.icon('envelope') }}{% endif %} + {{ __(name) }} + · + {% endif %} {% endfor %} {{ __('footer.issues') }} · {{ __('footer.github') }} diff --git a/resources/views/layouts/parts/navbar.twig b/resources/views/layouts/parts/navbar.twig index e9eb07b2..3f8d1281 100644 --- a/resources/views/layouts/parts/navbar.twig +++ b/resources/views/layouts/parts/navbar.twig @@ -45,12 +45,18 @@ {% if config('header_items') %} {% endif %}