Revert "Browse and delete polls from a numbered list in the polls menu"
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

This reverts commit 7b83cf2f2c.
This commit is contained in:
gnilebein committed 2026-11-16 13:52:02 +01:00
1 parent bd401ed94a
commit e3f74e375f
6 files changed
+39 -202

No files matched your search

-55
View File
@@ -26,61 +26,6 @@ abstract class PollsCommand extends Command
return $polls;
}
/**
* @param bool $expiredOnly Only expired polls
* @param string $email Only polls whose e-mail address contains this text (case-insensitive)
* @return list<\App\Model\Entity\Poll> Oldest first
*/
protected function findPolls(bool $expiredOnly = false, string $email = ''): array
{
$query = $this->polls()->find()
->select([
'Polls.id', 'Polls.title', 'Polls.email', 'Polls.join_code', 'Polls.current_slide_id',
'Polls.paused_slide_id', 'Polls.last_admin_access', 'Polls.expiry_reminded_at', 'Polls.created',
])
->orderBy(['Polls.id' => 'ASC']);
if ($expiredOnly) {
$query->find('expired');
}
if ($email !== '') {
$query->where(['Polls.email LIKE' => '%' . addcslashes(strtolower($email), '%_\\') . '%']);
}
/** @var list<\App\Model\Entity\Poll> $polls */
$polls = $query->all()->toList();
return $polls;
}
/**
* Prints polls as a table, optionally with a running number to pick from.
*
* @param list<\App\Model\Entity\Poll> $polls Polls
* @param \Cake\Console\ConsoleIo $io Console
* @param int $firstNumber Number of the first row (with $numbered)
* @param bool $numbered Add the number column
* @return void
*/
protected function printPolls(array $polls, ConsoleIo $io, int $firstNumber = 1, bool $numbered = false): void
{
$header = [__('ID'), __('Code'), __('Titel'), __('E-Mail'), __('Angelegt'), __('Letzter Admin-Besuch'), __('Läuft ab'), __('Erinnert')];
$rows = [$numbered ? array_merge(['#'], $header) : $header];
foreach ($polls as $i => $poll) {
$row = [
(string)$poll->id,
$poll->join_code,
mb_strimwidth($poll->title, 0, 40, '…'),
$poll->email,
$this->formatDate($poll->created),
$this->formatDate($poll->last_admin_access),
$this->formatExpiry($poll),
$this->formatDate($poll->expiry_reminded_at),
];
$rows[] = $numbered ? array_merge([(string)($firstNumber + $i)], $row) : $row;
}
$io->helper('Table')->output($rows);
}
/**
* Finds a poll by numeric id or join code ("K7P2QX", "k7p-2qx").
*