Header/Footer items config: Add configurable permissions
This commit is contained in:
parent
4fa99b8a04
commit
4244acfb4d
|
@ -32,14 +32,22 @@ return [
|
||||||
// Available link placeholders: %lang%
|
// Available link placeholders: %lang%
|
||||||
// To disable a header_item in the config.php, you can set its value to null
|
// To disable a header_item in the config.php, you can set its value to null
|
||||||
'header_items' => [
|
'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
|
// Footer links
|
||||||
// To disable a footer item in the config.php, you can set its value to null
|
// To disable a footer item in the config.php, you can set its value to null
|
||||||
'footer_items' => [
|
'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
|
// 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 email address, linked on every page
|
||||||
'Contact' => env('CONTACT_EMAIL', 'mailto:ticket@c3heaven.de'),
|
'Contact' => env('CONTACT_EMAIL', 'mailto:ticket@c3heaven.de'),
|
||||||
|
|
|
@ -36,11 +36,15 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% for name,url in config('footer_items') %}
|
{% 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) %}
|
||||||
<a href="{% if url starts with '/' %}{{ url(url) }}{% else %}{{ url }}{% endif %}">
|
<a href="{% if url starts with '/' %}{{ url(url) }}{% else %}{{ url }}{% endif %}">
|
||||||
{% if '@' in url %}{{ m.icon('envelope') }}{% endif %}
|
{% if '@' in url %}{{ m.icon('envelope') }}{% endif %}
|
||||||
{{ __(name) }}
|
{{ __(name) }}
|
||||||
</a> ·
|
</a> ·
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<a href="https://github.com/engelsystem/engelsystem/issues">{{ __('footer.issues') }}</a>
|
<a href="https://github.com/engelsystem/engelsystem/issues">{{ __('footer.issues') }}</a>
|
||||||
· <a href="https://github.com/engelsystem/engelsystem/">{{ __('footer.github') }}</a>
|
· <a href="https://github.com/engelsystem/engelsystem/">{{ __('footer.github') }}</a>
|
||||||
|
|
|
@ -45,12 +45,18 @@
|
||||||
|
|
||||||
{% if config('header_items') %}
|
{% if config('header_items') %}
|
||||||
<ul class="navbar-nav mb-2 mb-lg-0">
|
<ul class="navbar-nav mb-2 mb-lg-0">
|
||||||
{% for text,link in config('header_items', {}) %}
|
{% for name,opt in config('header_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) %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{{ link|replace({'%lang%': session_get('locale')|split('_')[0]})|escape('html_attr') }}">
|
<a class="nav-link"
|
||||||
{{ text }}
|
href="{{ url|replace({'%lang%': session_get('locale')|split('_')[0]})|escape('html_attr') }}"
|
||||||
|
>
|
||||||
|
{{ __(name) }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue