2026-02-04 23:31:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use MintyPHP\Router;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\Access\AccessServicesFactory;
|
2026-02-11 19:28:12 +01:00
|
|
|
use MintyPHP\Service\Access\PermissionService;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\Settings\SettingServicesFactory;
|
|
|
|
|
use MintyPHP\Service\User\UserServicesFactory;
|
|
|
|
|
use MintyPHP\Support\Guard;
|
2026-02-04 23:31:53 +01:00
|
|
|
|
|
|
|
|
Guard::requireLogin();
|
|
|
|
|
Guard::requirePermission(PermissionService::ROLES_VIEW);
|
|
|
|
|
|
|
|
|
|
$limit = (int) ($_GET['limit'] ?? 10);
|
|
|
|
|
$offset = (int) ($_GET['offset'] ?? 0);
|
|
|
|
|
$search = trim((string) ($_GET['search'] ?? ''));
|
|
|
|
|
$order = (string) ($_GET['order'] ?? 'description');
|
|
|
|
|
$dir = (string) ($_GET['dir'] ?? 'asc');
|
2026-02-11 19:28:12 +01:00
|
|
|
$active = (string) ($_GET['active'] ?? '');
|
2026-02-04 23:31:53 +01:00
|
|
|
|
2026-02-23 12:58:19 +01:00
|
|
|
$result = directoryServicesFactory()->createRoleService()->listPaged([
|
2026-02-04 23:31:53 +01:00
|
|
|
'limit' => $limit,
|
|
|
|
|
'offset' => $offset,
|
|
|
|
|
'search' => $search,
|
|
|
|
|
'order' => $order,
|
|
|
|
|
'dir' => $dir,
|
2026-02-11 19:28:12 +01:00
|
|
|
'active' => $active,
|
2026-02-04 23:31:53 +01:00
|
|
|
]);
|
|
|
|
|
|
2026-02-23 12:58:19 +01:00
|
|
|
$settingsFactory = new SettingServicesFactory();
|
|
|
|
|
$settingGateway = $settingsFactory->createSettingGateway();
|
|
|
|
|
$defaultRoleId = $settingGateway->getDefaultRoleId();
|
|
|
|
|
$rolePermissionRepository = (new AccessServicesFactory())->createRolePermissionRepository();
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
$roleIds = [];
|
|
|
|
|
foreach ($result['rows'] as $roleRow) {
|
|
|
|
|
$roleId = (int) ($roleRow['id'] ?? 0);
|
|
|
|
|
if ($roleId > 0) {
|
|
|
|
|
$roleIds[] = $roleId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$roleIds = array_values(array_unique($roleIds));
|
2026-02-23 12:58:19 +01:00
|
|
|
$userRoleRepository = (new UserServicesFactory())->createUserRoleRepository();
|
|
|
|
|
$roleUserCounts = $userRoleRepository->countUsersByRoleIds($roleIds);
|
|
|
|
|
$roleActiveUserCounts = $userRoleRepository->countActiveUsersByRoleIds($roleIds);
|
|
|
|
|
$rolePermissionCounts = $rolePermissionRepository->countPermissionsByRoleIds($roleIds);
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
|
2026-02-04 23:31:53 +01:00
|
|
|
$rows = [];
|
|
|
|
|
foreach ($result['rows'] as $row) {
|
|
|
|
|
$roleId = (int) ($row['id'] ?? 0);
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
$usersTotal = (int) ($roleUserCounts[$roleId] ?? 0);
|
|
|
|
|
$usersActive = (int) ($roleActiveUserCounts[$roleId] ?? 0);
|
|
|
|
|
$usersInactive = max(0, $usersTotal - $usersActive);
|
2026-02-04 23:31:53 +01:00
|
|
|
$rows[] = [
|
|
|
|
|
'id' => $row['id'] ?? null,
|
|
|
|
|
'uuid' => $row['uuid'] ?? '',
|
|
|
|
|
'is_default' => $roleId > 0 && $defaultRoleId === $roleId,
|
|
|
|
|
'description' => $row['description'] ?? '',
|
2026-02-11 19:28:12 +01:00
|
|
|
'code' => $row['code'] ?? '',
|
|
|
|
|
'active' => (int) ($row['active'] ?? 1),
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
'active_users' => $usersActive,
|
|
|
|
|
'inactive_users' => $usersInactive,
|
|
|
|
|
'permission_count' => (int) ($rolePermissionCounts[$roleId] ?? 0),
|
2026-02-04 23:31:53 +01:00
|
|
|
'created' => dt($row['created'] ?? ''),
|
|
|
|
|
'modified' => dt($row['modified'] ?? ''),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Router::json([
|
|
|
|
|
'data' => $rows,
|
|
|
|
|
'total' => $result['total'] ?? 0,
|
|
|
|
|
]);
|