2026-02-04 23:31:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use MintyPHP\Buffer;
|
2026-03-06 11:28:22 +01:00
|
|
|
use MintyPHP\Http\SessionStoreInterface;
|
2026-02-04 23:31:53 +01:00
|
|
|
use MintyPHP\Router;
|
2026-02-24 08:49:40 +01:00
|
|
|
use MintyPHP\Service\Access\SettingsAuthorizationPolicy;
|
2026-03-04 15:56:58 +01:00
|
|
|
use MintyPHP\Service\Settings\AdminSettingsService;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Support\Flash;
|
|
|
|
|
use MintyPHP\Support\Guard;
|
2026-02-04 23:31:53 +01:00
|
|
|
|
2026-03-06 11:28:22 +01:00
|
|
|
$session = app(SessionStoreInterface::class)->all();
|
2026-02-04 23:31:53 +01:00
|
|
|
Guard::requireLogin();
|
2026-03-04 15:56:58 +01:00
|
|
|
$request = requestInput();
|
2026-02-24 08:49:40 +01:00
|
|
|
|
2026-03-06 11:28:22 +01:00
|
|
|
$currentUserId = (int) ($session['user']['id'] ?? 0);
|
2026-03-04 15:56:58 +01:00
|
|
|
$authorizationService = app(\MintyPHP\Service\Access\AuthorizationService::class);
|
2026-02-24 08:49:40 +01:00
|
|
|
$viewDecision = $authorizationService->authorize(SettingsAuthorizationPolicy::ABILITY_ADMIN_SETTINGS_VIEW, [
|
|
|
|
|
'actor_user_id' => $currentUserId,
|
|
|
|
|
]);
|
|
|
|
|
if (!$viewDecision->isAllowed()) {
|
|
|
|
|
Guard::deny();
|
|
|
|
|
}
|
|
|
|
|
$viewCapabilities = $viewDecision->attribute('capabilities', []);
|
|
|
|
|
$canUpdateSettings = is_array($viewCapabilities) ? (bool) ($viewCapabilities['can_update_settings'] ?? false) : false;
|
2026-02-04 23:31:53 +01:00
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
$adminSettingsService = app(AdminSettingsService::class);
|
|
|
|
|
$pageData = $adminSettingsService->buildPageData();
|
|
|
|
|
$tenants = is_array($pageData['tenants'] ?? null) ? $pageData['tenants'] : [];
|
|
|
|
|
$roles = is_array($pageData['roles'] ?? null) ? $pageData['roles'] : [];
|
|
|
|
|
$departments = is_array($pageData['departments'] ?? null) ? $pageData['departments'] : [];
|
|
|
|
|
$values = is_array($pageData['values'] ?? null) ? $pageData['values'] : [];
|
|
|
|
|
$settings = is_array($pageData['settings'] ?? null) ? $pageData['settings'] : [];
|
|
|
|
|
$activeLoginTokens = (int) ($pageData['active_login_tokens'] ?? 0);
|
|
|
|
|
$activeApiTokens = (int) ($pageData['active_api_tokens'] ?? 0);
|
2026-02-23 12:58:19 +01:00
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
if ($request->isMethod('POST')) {
|
|
|
|
|
$post = $request->bodyAll();
|
|
|
|
|
if (!array_key_exists('settings_submit', $post)) {
|
2026-02-04 23:31:53 +01:00
|
|
|
Router::redirect('admin/settings');
|
|
|
|
|
}
|
2026-03-04 15:56:58 +01:00
|
|
|
|
2026-02-24 08:49:40 +01:00
|
|
|
$updateDecision = $authorizationService->authorize(SettingsAuthorizationPolicy::ABILITY_ADMIN_SETTINGS_UPDATE, [
|
|
|
|
|
'actor_user_id' => $currentUserId,
|
|
|
|
|
]);
|
|
|
|
|
if (!$updateDecision->isAllowed()) {
|
|
|
|
|
Guard::deny();
|
|
|
|
|
}
|
2026-02-04 23:31:53 +01:00
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
$updateResult = $adminSettingsService->updateFromAdmin($post);
|
|
|
|
|
$errorBag = formErrors();
|
|
|
|
|
foreach ((array) ($updateResult['errors'] ?? []) as $error) {
|
|
|
|
|
if (is_array($error)) {
|
|
|
|
|
$message = trim((string) ($error['message'] ?? ''));
|
|
|
|
|
$field = trim((string) ($error['field'] ?? 'input'));
|
|
|
|
|
if ($message !== '') {
|
|
|
|
|
$errorBag->add($field !== '' ? $field : 'input', $message);
|
|
|
|
|
}
|
|
|
|
|
continue;
|
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-03-04 15:56:58 +01:00
|
|
|
|
|
|
|
|
$message = trim((string) $error);
|
|
|
|
|
if ($message !== '') {
|
|
|
|
|
$errorBag->addGlobal($message);
|
2026-02-04 23:31:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
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-03-04 15:56:58 +01:00
|
|
|
if ($errorBag->hasAny()) {
|
|
|
|
|
flashFormErrors($errorBag, 'admin/settings', 'settings_update_error');
|
|
|
|
|
Router::redirect('admin/settings');
|
|
|
|
|
}
|
2026-02-04 23:31:53 +01:00
|
|
|
|
|
|
|
|
Flash::success('Settings updated', 'admin/settings', 'settings_updated');
|
|
|
|
|
Router::redirect('admin/settings');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Buffer::set('title', t('Settings'));
|