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