2026-04-02 17:48:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Module\Helpdesk\Providers;
|
|
|
|
|
|
|
|
|
|
use MintyPHP\App\AppContainer;
|
|
|
|
|
use MintyPHP\App\Module\Contracts\LayoutContextProvider;
|
|
|
|
|
use MintyPHP\Service\Access\AuthorizationService;
|
|
|
|
|
|
|
|
|
|
final class HelpdeskLayoutProvider implements LayoutContextProvider
|
|
|
|
|
{
|
|
|
|
|
public function provide(array $session, AppContainer $container): array
|
|
|
|
|
{
|
|
|
|
|
$userId = (int) ($session['user']['id'] ?? 0);
|
|
|
|
|
if ($userId <= 0) {
|
|
|
|
|
return ['helpdesk.nav' => ['can_manage_settings' => false]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$authorizationService = $container->get(AuthorizationService::class);
|
2026-04-05 18:46:54 +02:00
|
|
|
$actorContext = ['actor_user_id' => $userId];
|
|
|
|
|
$canManageSettings = $authorizationService->authorize('helpdesk.settings.manage', $actorContext)->isAllowed();
|
|
|
|
|
$canViewTeam = $authorizationService->authorize('helpdesk.team-workload.view', $actorContext)->isAllowed();
|
2026-04-06 00:24:48 +02:00
|
|
|
$canViewRiskRadar = $authorizationService->authorize('helpdesk.risk-radar.view', $actorContext)->isAllowed();
|
2026-04-14 22:16:21 +02:00
|
|
|
$canManageSoftwareProducts = $authorizationService->authorize('helpdesk.software-products.manage', $actorContext)->isAllowed();
|
2026-04-02 17:48:27 +02:00
|
|
|
} catch (\Throwable) {
|
|
|
|
|
$canManageSettings = false;
|
2026-04-05 18:46:54 +02:00
|
|
|
$canViewTeam = false;
|
2026-04-06 00:24:48 +02:00
|
|
|
$canViewRiskRadar = false;
|
2026-04-14 22:16:21 +02:00
|
|
|
$canManageSoftwareProducts = false;
|
2026-04-02 17:48:27 +02:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 18:46:54 +02:00
|
|
|
return ['helpdesk.nav' => [
|
|
|
|
|
'can_manage_settings' => $canManageSettings,
|
|
|
|
|
'can_view_team' => $canViewTeam,
|
2026-04-06 00:24:48 +02:00
|
|
|
'can_view_risk_radar' => $canViewRiskRadar,
|
2026-04-14 22:16:21 +02:00
|
|
|
'can_manage_software_products' => $canManageSoftwareProducts,
|
2026-04-05 18:46:54 +02:00
|
|
|
]];
|
2026-04-02 17:48:27 +02:00
|
|
|
}
|
|
|
|
|
}
|