major update

This commit is contained in:
2026-03-04 15:56:58 +01:00
parent 16759a2732
commit 8f4dd5840d
478 changed files with 24313 additions and 8201 deletions

View File

@@ -42,6 +42,8 @@ class SettingService
public const SMTP_FROM_NAME_KEY = 'smtp_from_name';
public const USER_INACTIVITY_DEACTIVATE_DAYS_KEY = 'user_inactivity_deactivate_days';
public const USER_INACTIVITY_DELETE_DAYS_KEY = 'user_inactivity_delete_days';
public const SYSTEM_AUDIT_ENABLED_KEY = 'system_audit_enabled';
public const SYSTEM_AUDIT_RETENTION_DAYS_KEY = 'system_audit_retention_days';
private const API_TOKEN_DEFAULT_TTL_DAYS_FALLBACK = 90;
private const API_TOKEN_MAX_TTL_DAYS_FALLBACK = 365;
private const API_TOKEN_TTL_DAYS_MIN = 1;
@@ -50,6 +52,10 @@ class SettingService
private const USER_INACTIVITY_DELETE_DAYS_FALLBACK = 365;
private const USER_INACTIVITY_DAYS_MIN = 0;
private const USER_INACTIVITY_DAYS_MAX = 3650;
private const SYSTEM_AUDIT_ENABLED_FALLBACK = true;
private const SYSTEM_AUDIT_RETENTION_DAYS_FALLBACK = 365;
private const SYSTEM_AUDIT_RETENTION_DAYS_MIN = 30;
private const SYSTEM_AUDIT_RETENTION_DAYS_MAX = 1095;
public function get(string $key): ?array
{
@@ -338,6 +344,45 @@ class SettingService
return $this->settingRepository->set(self::USER_INACTIVITY_DELETE_DAYS_KEY, (string) $value, $desc);
}
public function isSystemAuditEnabled(): bool
{
$value = strtolower(trim((string) ($this->settingRepository->getValue(self::SYSTEM_AUDIT_ENABLED_KEY) ?? '')));
if ($value === '') {
return self::SYSTEM_AUDIT_ENABLED_FALLBACK;
}
return in_array($value, ['1', 'true', 'yes', 'on'], true);
}
public function setSystemAuditEnabled(bool $enabled, ?string $description = null): bool
{
$desc = $description ?? 'setting.system_audit_enabled';
return $this->settingRepository->set(self::SYSTEM_AUDIT_ENABLED_KEY, $enabled ? '1' : '0', $desc);
}
public function getSystemAuditRetentionDays(): int
{
$value = $this->getInt(self::SYSTEM_AUDIT_RETENTION_DAYS_KEY);
if ($value === null) {
return self::SYSTEM_AUDIT_RETENTION_DAYS_FALLBACK;
}
if ($value < self::SYSTEM_AUDIT_RETENTION_DAYS_MIN || $value > self::SYSTEM_AUDIT_RETENTION_DAYS_MAX) {
return self::SYSTEM_AUDIT_RETENTION_DAYS_FALLBACK;
}
return $value;
}
public function setSystemAuditRetentionDays(?int $days, ?string $description = null): bool
{
$value = $days ?? self::SYSTEM_AUDIT_RETENTION_DAYS_FALLBACK;
if ($value < self::SYSTEM_AUDIT_RETENTION_DAYS_MIN || $value > self::SYSTEM_AUDIT_RETENTION_DAYS_MAX) {
return false;
}
$desc = $description ?? 'setting.system_audit_retention_days';
return $this->settingRepository->set(self::SYSTEM_AUDIT_RETENTION_DAYS_KEY, (string) $value, $desc);
}
public function getApiCorsAllowedOrigins(): array
{
$stored = $this->settingRepository->getValue(self::API_CORS_ALLOWED_ORIGINS_KEY);