From 5b675c25a329fed528e4c1b44e4e02448fa6e377 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 25 Feb 2022 10:10:47 +0100 Subject: [PATCH] don't show SU link for yourself Signed-off-by: Michael Kaufmann --- lib/Froxlor/UI/Callbacks/Impersonate.php | 70 +++++++++++++----------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/lib/Froxlor/UI/Callbacks/Impersonate.php b/lib/Froxlor/UI/Callbacks/Impersonate.php index c9b508f1..3d3bea32 100644 --- a/lib/Froxlor/UI/Callbacks/Impersonate.php +++ b/lib/Froxlor/UI/Callbacks/Impersonate.php @@ -1,4 +1,5 @@ 'link', - 'data' => [ - 'text' => $data, - 'href' => $linker->getLink([ - 'section' => 'admins', - 'page' => 'admins', - 'action' => 'su', - 'id' => $attributes['adminid'], - ]), - ] - ]; - } + public static function admin(string $data, array $attributes): mixed + { + if (UI::getCurrentUser()['adminid'] != $attributes['adminid']) { + $linker = UI::getLinker(); + return [ + 'type' => 'link', + 'data' => [ + 'text' => $data, + 'href' => $linker->getLink([ + 'section' => 'admins', + 'page' => 'admins', + 'action' => 'su', + 'id' => $attributes['adminid'], + ]), + ] + ]; + } + return $data; + } - public static function customer(string $data, array $attributes): array - { - $linker = UI::getLinker(); - return [ - 'type' => 'link', - 'data' => [ - 'text' => $data, - 'href' => $linker->getLink([ - 'section' => 'customers', - 'page' => 'customers', - 'action' => 'su', - 'sort' => $attributes['loginname'], - 'id' => $attributes['customerid'], - ]), - ] - ]; - } + public static function customer(string $data, array $attributes): array + { + $linker = UI::getLinker(); + return [ + 'type' => 'link', + 'data' => [ + 'text' => $data, + 'href' => $linker->getLink([ + 'section' => 'customers', + 'page' => 'customers', + 'action' => 'su', + 'sort' => $attributes['loginname'], + 'id' => $attributes['customerid'], + ]), + ] + ]; + } }