Files

160 lines
6.0 KiB
PHTML
Raw Permalink Normal View History

2026-02-04 23:31:53 +01:00
<?php
use MintyPHP\Router;
use MintyPHP\Session;
use MintyPHP\Http\Request;
2026-02-04 23:31:53 +01:00
2026-03-04 15:56:58 +01:00
$toolbarFilterSchema = is_array($toolbarFilterSchema ?? null) ? $toolbarFilterSchema : [];
$searchToolbarFilterSchema = is_array($searchToolbarFilterSchema ?? null) ? $searchToolbarFilterSchema : [];
$drawerToolbarFilterSchema = is_array($drawerToolbarFilterSchema ?? null) ? $drawerToolbarFilterSchema : [];
$toolbarFilterState = is_array($toolbarFilterState ?? null) ? $toolbarFilterState : [];
$toolbarOptionSets = is_array($toolbarOptionSets ?? null) ? $toolbarOptionSets : [];
$clientFilterSchema = is_array($clientFilterSchema ?? null) ? $clientFilterSchema : [];
$filterChipMeta = is_array($filterChipMeta ?? null) ? $filterChipMeta : [];
$searchConfig = is_array($searchConfig ?? null) ? $searchConfig : null;
$activeTenant = (string) ($toolbarFilterState['tenant'] ?? '');
$pageAuth = is_array($viewAuth['page'] ?? null) ? $viewAuth['page'] : [];
$canDeleteUsers = (bool) ($pageAuth['can_delete_users'] ?? false);
$canUpdateUsers = (bool) ($pageAuth['can_update_users'] ?? false);
$canAccessPdf = (bool) ($pageAuth['can_access_pdf'] ?? false);
$canUpdateSelf = (bool) ($pageAuth['can_update_self'] ?? false);
$canCreateUser = (bool) ($pageAuth['can_create_user'] ?? false);
2026-02-04 23:31:53 +01:00
$currentUserUuid = (string) ($_SESSION['user']['uuid'] ?? '');
$showTenantTabs = isset($tenants) && is_array($tenants) && count($tenants) > 1;
?>
2026-02-11 19:28:12 +01:00
<?php
2026-03-04 15:56:58 +01:00
$listTitle = t('Users');
ob_start();
?>
<button type="button" class="secondary outline" data-users-bulk="activate" hidden>
<i class="bi bi-check-circle"></i> <?php e(t('Activate')); ?>
</button>
<button type="button" class="secondary outline" data-users-bulk="deactivate" hidden>
<i class="bi bi-ban"></i> <?php e(t('Deactivate')); ?>
</button>
<?php if ($canUpdateUsers): ?>
<button type="button" class="secondary outline" data-users-bulk="send-access" hidden>
<i class="bi bi-envelope"></i> <?php e(t('Send access')); ?>
</button>
<?php endif; ?>
<?php if ($canAccessPdf): ?>
<button type="button" class="secondary outline" data-users-bulk="access-pdf" hidden>
<i class="bi bi-file-earmark-pdf"></i> <?php e(t('Download access PDFs')); ?>
</button>
<?php endif; ?>
<?php if ($canDeleteUsers): ?>
<button type="button" class="danger outline" data-users-bulk="delete" hidden>
<i class="bi bi-trash3-fill"></i> <?php e(t('Delete')); ?>
</button>
<?php endif; ?>
<?php require templatePath('partials/app-list-export-dropdown.phtml'); ?>
2026-02-04 23:31:53 +01:00
2026-03-04 15:56:58 +01:00
<?php if ($canCreateUser): ?>
2026-03-12 16:47:53 +01:00
<a role="button" class="app-action-success" href="<?php e(requestPathWithReturnTarget('admin/users/create', Request::pathWithQuery())); ?>">
2026-03-04 15:56:58 +01:00
<i class="bi bi-plus"></i> <?php e(t('Create user')); ?>
</a>
2026-02-04 23:31:53 +01:00
<?php endif; ?>
2026-03-04 15:56:58 +01:00
<?php
$listTitleActionsHtml = ob_get_clean();
require templatePath('partials/app-list-titlebar.phtml');
?>
<?php if ($showTenantTabs): ?>
<?php
$listTabsId = 'users-tabs';
$listTabsItems = [
[
'href' => 'admin/users',
'label' => t('All'),
'active' => $activeTenant === '',
],
];
foreach ($tenants ?? [] as $tenant) {
$tenantUuid = (string) ($tenant['uuid'] ?? '');
if ($tenantUuid === '') {
continue;
}
2026-02-11 19:28:12 +01:00
2026-03-04 15:56:58 +01:00
$listTabsItems[] = [
'href' => 'admin/users?tenant=' . rawurlencode($tenantUuid),
'label' => (string) ($tenant['description'] ?? ''),
'active' => $activeTenant === $tenantUuid,
];
}
require templatePath('partials/app-list-tabs.phtml');
?>
<?php endif; ?>
<?php
$filterUiNamespace = 'users';
require templatePath('partials/app-list-filters.phtml');
?>
2026-02-04 23:31:53 +01:00
<div class="app-list-table">
<div id="users-grid"></div>
</div>
<?php if ($canAccessPdf): ?>
<form id="users-access-pdf-bulk-form" method="post" action="admin/users/access-pdf-bulk" hidden>
<?php Session::getCsrfInput(); ?>
<input type="hidden" name="uuids" value="">
</form>
<?php endif; ?>
2026-02-04 23:31:53 +01:00
2026-03-05 08:26:51 +01:00
<?php
$gridLang = json_decode(appBufferValue('grid_lang'), true);
if (!is_array($gridLang)) {
$gridLang = [];
}
$gridCsrf = json_decode(appBufferValue('grid_csrf'), true);
if (!is_array($gridCsrf)) {
$gridCsrf = [];
}
$pageConfig = [
'gridSearch' => $searchConfig,
'filterSchema' => $clientFilterSchema,
'filterChipMeta' => $filterChipMeta,
feat(core): endpointUrl() helper — query-safe URLs for module routes Introduce a helper that returns the registered route TARGET for a given source path, so URLs built for endpoints that carry query parameters do not rely on MintyPHP's applyRoutes() rewrite layer — that layer compares the full request URI (including `?query`) against source paths and silently misses modules where path ≠ target. - core/Support/helpers/app.php: endpointUrl($path) consults ModuleRegistry::getRoutes(), returns lurl(target) when the path is a registered module source path, otherwise falls through to lurl($path). Safe fallback when the container or registry is unavailable. - modules/audit/pages/audit/system-audit/index(default).phtml: replace the ad-hoc target-path workaround with endpointUrl('admin/system-audit/ export'). Callers can now write the natural source path without knowing about the rewrite trap. - Apply the same helper to modules/helpdesk/.../domains/index and pages/admin/users/index for consistency — a no-op where path already equals target, but establishes the convention: every export/data endpoint URL in page configs goes through endpointUrl(). - tests/Support/Helpers/EndpointUrlTest: 5 cases covering source→target resolution, idempotence when path == target, fall-through for unregistered paths, leading-slash normalization, and graceful degradation when the registry is missing. Uses AppContainerIsolationTrait per the contract test in tests/Architecture/AppContainerIsolationContractTest. Gates: PHPUnit 1894 OK, PHPStan 0 errors, module:sync ok. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 22:39:36 +02:00
'exportUrl' => endpointUrl('admin/users/export'),
2026-03-05 08:26:51 +01:00
'currentUserUuid' => (string) $currentUserUuid,
'canUpdateUsers' => (bool) $canUpdateUsers,
'canUpdateSelf' => (bool) $canUpdateSelf,
'csrf' => $gridCsrf,
'gridLang' => $gridLang,
'labels' => [
'user' => t('User'),
2026-03-05 08:26:51 +01:00
'state' => t('State'),
'tenants' => t('Tenants'),
'lastLogin' => t('Last login'),
'selectAll' => t('Select all'),
'active' => t('Active'),
'inactive' => t('Inactive'),
'never' => t('Never'),
'bulkActivateConfirm' => t('Activate users?'),
'bulkDeactivateConfirm' => t('Deactivate users?'),
'bulkDeleteConfirm' => t('Delete users?'),
'bulkSendAccessConfirm' => t('Send access emails to selected users?'),
'bulkAccessPdfConfirm' => t('Generate access PDFs for selected users?'),
'primaryTenant' => t('Primary tenant'),
'bulkMessages' => [
'activate' => [
'success' => t('%d users activated'),
'error' => t('Failed to activate users'),
],
'deactivate' => [
'success' => t('%d users deactivated'),
'error' => t('Failed to deactivate users'),
],
'delete' => [
'success' => t('%d users deleted'),
'error' => t('Failed to delete users'),
],
'send-access' => [
'success' => t('Access emails sent to %d users'),
'partial' => t('Access emails sent to %d users, %f failed'),
'error' => t('Failed to send access emails'),
],
],
],
];
?>
<script src="<?php e(assetVersion('vendor/gridjs/gridjs.umd.js')); ?>"></script>
<script src="<?php e(assetVersion('vendor/gridjs/plugins/selection/selection.umd.js')); ?>"></script>
<script type="application/json" id="page-config-admin-users-index"><?php gridJsonForJs($pageConfig); ?></script>
<script type="module" src="<?php e(assetVersion('js/pages/admin-users-index.js')); ?>"></script>