[Web] Retention: last run for single rules, mode only when editing, check domain access first

This commit is contained in:
FreddleSpl0it committed 2026-11-09 12:09:57 +01:00
1 parent 1238e6fb58
commit 6796db6b8f
5 files changed
+44 -6

No files matched your search

@@ -71,7 +71,7 @@ class RetentionApiController
{
$id = $this->toId($id);
$rule = ($id === null) ? null : $this->rules->get($id);
return ($rule === null) ? [] : $this->rules->toArray($rule);
return ($rule === null) ? [] : $this->rules->toArray($rule, $this->rules->lastRuns([$id])[$id] ?? null);
}
/**
@@ -196,13 +196,14 @@ class RuleService
/** @throws UserError */
private function domainFor(mixed $value): string
{
$domain = strtolower((string)Input::text($value));
$domain = Input::text($value);
$domain = ($domain === null || $domain === '') ? '' : (string)idn_to_ascii(strtolower($domain), 0, INTL_IDNA_VARIANT_UTS46);
if ($domain !== '' && !$this->context->hasAdminRights() && !$this->context->canAccessDomain($domain)) {
throw new AccessDenied();
}
if ($domain === '' || !$this->repo->isDomain($domain)) {
throw new UserError('domain_not_found', [htmlspecialchars((string)Input::text($value))]);
}
if (!$this->context->hasAdminRights() && !$this->context->canAccessDomain($domain)) {
throw new AccessDenied();
}
return $domain;
}
@@ -43,6 +43,7 @@
</div>
</div>
</div>
{% if rule.id is defined %}
<div class="row mb-2">
<label class="control-label col-sm-2{{ label_class }}" for="{{ id }}_mode">{{ lang.retention.mode }}</label>
<div class="col-sm-10">
@@ -54,6 +55,7 @@
<small class="text-muted d-block">{{ lang.retention.mode_info }}</small>
</div>
</div>
{% endif %}
<legend class="fs-5 mt-4"><i class="bi bi-people"></i> {{ lang.retention.assign }}</legend><hr>
<p class="text-muted small">{{ lang.retention.assign_info }}</p>
<div class="row mb-2">