don't show SU link for yourself

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann 2022-02-25 10:10:47 +01:00
parent c2ec309a01
commit 5b675c25a3
No known key found for this signature in database
GPG Key ID: 08A83830520FCECB

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Froxlor\UI\Callbacks; namespace Froxlor\UI\Callbacks;
use Froxlor\UI\Panel\UI; use Froxlor\UI\Panel\UI;
@ -21,38 +22,41 @@ use Froxlor\UI\Panel\UI;
class Impersonate class Impersonate
{ {
public static function admin(string $data, array $attributes): array public static function admin(string $data, array $attributes): mixed
{ {
$linker = UI::getLinker(); if (UI::getCurrentUser()['adminid'] != $attributes['adminid']) {
return [ $linker = UI::getLinker();
'type' => 'link', return [
'data' => [ 'type' => 'link',
'text' => $data, 'data' => [
'href' => $linker->getLink([ 'text' => $data,
'section' => 'admins', 'href' => $linker->getLink([
'page' => 'admins', 'section' => 'admins',
'action' => 'su', 'page' => 'admins',
'id' => $attributes['adminid'], 'action' => 'su',
]), 'id' => $attributes['adminid'],
] ]),
]; ]
} ];
}
return $data;
}
public static function customer(string $data, array $attributes): array public static function customer(string $data, array $attributes): array
{ {
$linker = UI::getLinker(); $linker = UI::getLinker();
return [ return [
'type' => 'link', 'type' => 'link',
'data' => [ 'data' => [
'text' => $data, 'text' => $data,
'href' => $linker->getLink([ 'href' => $linker->getLink([
'section' => 'customers', 'section' => 'customers',
'page' => 'customers', 'page' => 'customers',
'action' => 'su', 'action' => 'su',
'sort' => $attributes['loginname'], 'sort' => $attributes['loginname'],
'id' => $attributes['customerid'], 'id' => $attributes['customerid'],
]), ]),
] ]
]; ];
} }
} }