Files
global-autoresponder/exec/handlers/toggle.php
T
2026-06-02 19:55:07 +02:00

15 lines
500 B
PHP

<?php
declare(strict_types=1);
return static function (AppContext $ctx): void {
$ctx->requirePost();
$id = $ctx->post('id');
$ctx->requireCsrf('toggle:' . $id);
$rule = $ctx->rules->find($ctx->daUser->username(), $id);
if ($rule === null) {
throw new RuntimeException($ctx->t('Rule not found'));
}
$ctx->rules->update($ctx->daUser->username(), $id, ['enabled' => empty($rule['enabled'])]);
Http::redirect($ctx->url('index.html', ['status' => 'toggled']));
};