Add poll expiry, reminder mail and polls admin CLI
CI / Deploy / PHP 8.4 (push) Successful in 1m57s
CI / Deploy / PHP 8.5 (push) Successful in 2m9s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

Polls are deleted POLL_RETENTION_DAYS (default 90) after creation by the
cron job `bin/cake polls cleanup`. POLL_REMINDER_DAYS (default 14) before
that the owner gets a one-time reminder mail (expiry_reminded_at).

New commands: polls list, show (admin link only with --link), delete,
remind, cleanup. The expiry date is shown in the creation mail and the
dashboard. Docs: README, AGENTS.md, .env.example.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 12:46:12 +01:00
1 parent 4caff47a09
commit a19cd8339e
20 files changed
+976 -1

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace App\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
/**
* Deletes polls for good (slides, answers and images included). Unknown polls are an error (exit code 1).
*
* Usage: bin/cake polls delete <id|code> [--yes]
*/
class PollsDeleteCommand extends PollsCommand
{
/**
* @return string
*/
public static function defaultName(): string
{
return 'polls delete';
}
/**
* @param \Cake\Console\ConsoleOptionParser $parser Parser
* @return \Cake\Console\ConsoleOptionParser
*/
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
return $parser
->setDescription(__('Löscht Umfragen endgültig, samt Folien, Antworten und Bildern.'))
->addArgument('poll', [
'help' => __('ID oder Beitrittscode der Umfrage.'),
'required' => true,
])
->addOption('yes', [
'short' => 'y',
'help' => __('Ohne Rückfrage löschen.'),
'boolean' => true,
]);
}
/**
* @param \Cake\Console\Arguments $args Arguments
* @param \Cake\Console\ConsoleIo $io Console
* @return int
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
$reference = (string)$args->getArgument('poll');
$poll = $this->findPoll($reference);
if ($poll === null) {
$io->err(__('Umfrage "{0}" nicht gefunden.', $reference));
return static::CODE_ERROR;
}
$io->out(__('#{0} {1} ({2}), angelegt {3}', $poll->id, $poll->title, $poll->email, $this->formatDate($poll->created)));
if (!$args->getOption('yes') && $io->askChoice(__('Diese Umfrage endgültig löschen?'), ['y', 'n'], 'n') !== 'y') {
$io->out(__('Abgebrochen.'));
return static::CODE_ERROR;
}
return $this->deletePolls([$poll], $io) === 1 ? static::CODE_SUCCESS : static::CODE_ERROR;
}
}