mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Fix missing link to admin.
This commit is contained in:
@@ -24,6 +24,7 @@ namespace FireflyIII\Support\Twig;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Twig\Extension\Account as AccountExtension;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use Route;
|
||||
@@ -45,7 +46,7 @@ class General extends Twig_Extension
|
||||
$this->balance(),
|
||||
$this->formatFilesize(),
|
||||
$this->mimeIcon(),
|
||||
$this->markdown(),
|
||||
$this->markdown()
|
||||
];
|
||||
}
|
||||
|
||||
@@ -64,6 +65,7 @@ class General extends Twig_Extension
|
||||
$this->activeRoutePartialWhat(),
|
||||
$this->formatDate(),
|
||||
new Twig_SimpleFunction('accountGetMetaField', [AccountExtension::class, 'getMetaField']),
|
||||
$this->hasRole(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -235,6 +237,25 @@ class General extends Twig_Extension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return true if the user is of role X.
|
||||
*
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
protected function hasRole(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'hasRole',
|
||||
function (string $role): bool {
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
if ($repository->hasRole(auth()->user(), $role)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFilter
|
||||
*/
|
||||
|
@@ -149,7 +149,7 @@
|
||||
<a class="{{ activeRoutePartial('currencies') }}" href="{{ route('currencies.index') }}"><i class="fa fa-usd fa-fw"></i> {{ 'currencies'|_ }}
|
||||
</a>
|
||||
</li>
|
||||
{% if Auth.user.hasRole('owner') %}
|
||||
{% if hasRole('owner') %}
|
||||
<li class="{{ activeRoutePartial('admin') }}">
|
||||
<a class="{{ activeRoutePartial('admin') }}" href="{{ route('admin.index') }}"><i
|
||||
class="fa fa-hand-spock-o fa-fw"></i> {{ 'administration'|_ }}</a>
|
||||
|
Reference in New Issue
Block a user