Add poll expiry, reminder mail and polls admin CLI
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:
1 parent
4caff47a09
commit
a19cd8339e
20 files changed
+976
-1
No files matched your search
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Cake\Console\Arguments;
|
||||
use Cake\Console\ConsoleIo;
|
||||
use Cake\Console\ConsoleOptionParser;
|
||||
|
||||
/**
|
||||
* Details of one poll. The secret admin link is only printed with --link.
|
||||
*
|
||||
* Usage: bin/cake polls show <id|code> [--link]
|
||||
*/
|
||||
class PollsShowCommand extends PollsCommand
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function defaultName(): string
|
||||
{
|
||||
return 'polls show';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Cake\Console\ConsoleOptionParser $parser Parser
|
||||
* @return \Cake\Console\ConsoleOptionParser
|
||||
*/
|
||||
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
|
||||
{
|
||||
return $parser
|
||||
->setDescription(__('Zeigt Details einer Umfrage, auf Wunsch mit dem geheimen Admin-Link.'))
|
||||
->addArgument('poll', [
|
||||
'help' => __('ID oder Beitrittscode der Umfrage.'),
|
||||
'required' => true,
|
||||
])
|
||||
->addOption('link', [
|
||||
'help' => __('Auch den Admin-Link ausgeben (enthält das geheime Token!).'),
|
||||
'boolean' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Cake\Console\Arguments $args Arguments
|
||||
* @param \Cake\Console\ConsoleIo $io Console
|
||||
* @return int
|
||||
*/
|
||||
public function execute(Arguments $args, ConsoleIo $io): int
|
||||
{
|
||||
$poll = $this->findPoll((string)$args->getArgument('poll'));
|
||||
if ($poll === null) {
|
||||
$io->err(__('Umfrage nicht gefunden.'));
|
||||
|
||||
return static::CODE_ERROR;
|
||||
}
|
||||
|
||||
$slides = $this->fetchTable('Slides')->find()->where(['poll_id' => $poll->id])->count();
|
||||
$io->out([
|
||||
__('ID: {0}', $poll->id),
|
||||
__('Titel: {0}', $poll->title),
|
||||
__('E-Mail: {0}', $poll->email),
|
||||
__('Beitrittscode: {0}', $poll->join_code),
|
||||
__('Teilnahme-Link: {0}', $this->joinLink($poll)),
|
||||
__('Folien: {0}', $slides),
|
||||
__('Angelegt: {0}', $this->formatDate($poll->created)),
|
||||
__('Letzter Besuch: {0}', $this->formatDate($poll->last_admin_access)),
|
||||
__('Läuft ab: {0}', $this->formatExpiry($poll)),
|
||||
__('Erinnerung: {0}', $poll->expiry_reminded_at === null ? __('nicht verschickt') : $this->formatDate($poll->expiry_reminded_at)),
|
||||
]);
|
||||
|
||||
if ($args->getOption('link')) {
|
||||
$link = $this->adminLink($poll);
|
||||
if ($link === null) {
|
||||
$io->err(__('Der Admin-Link lässt sich nicht entschlüsseln (SECURITY_SALT geändert?).'));
|
||||
|
||||
return static::CODE_ERROR;
|
||||
}
|
||||
$io->out(__('Admin-Link: {0}', $link));
|
||||
} else {
|
||||
$io->out(__('Admin-Link: (mit --link anzeigen)'));
|
||||
}
|
||||
|
||||
return static::CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user