Revert "Browse and delete polls from a numbered list in the polls menu"
This reverts commit 7b83cf2f2c.
This commit is contained in:
6 files changed
+39
-202
No files matched your search
@@ -51,8 +51,22 @@ class PollsListCommand extends PollsCommand
|
||||
*/
|
||||
public function execute(Arguments $args, ConsoleIo $io): int
|
||||
{
|
||||
$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 ($args->getOption('expired')) {
|
||||
$query->find('expired');
|
||||
}
|
||||
$email = $args->getOption('email');
|
||||
$polls = $this->findPolls((bool)$args->getOption('expired'), is_string($email) ? $email : '');
|
||||
if (is_string($email) && $email !== '') {
|
||||
$query->where(['Polls.email LIKE' => '%' . addcslashes(strtolower($email), '%_\\') . '%']);
|
||||
}
|
||||
|
||||
/** @var list<\App\Model\Entity\Poll> $polls */
|
||||
$polls = $query->all()->toList();
|
||||
$sort = (string)$args->getOption('sort');
|
||||
if ($sort !== 'created') {
|
||||
usort($polls, fn($a, $b): int => match ($sort) {
|
||||
@@ -67,7 +81,20 @@ class PollsListCommand extends PollsCommand
|
||||
return static::CODE_SUCCESS;
|
||||
}
|
||||
|
||||
$this->printPolls($polls, $io);
|
||||
$rows = [[__('ID'), __('Code'), __('Titel'), __('E-Mail'), __('Angelegt'), __('Letzter Admin-Besuch'), __('Läuft ab'), __('Erinnert')]];
|
||||
foreach ($polls as $poll) {
|
||||
$rows[] = [
|
||||
(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),
|
||||
];
|
||||
}
|
||||
$io->helper('Table')->output($rows);
|
||||
|
||||
$expired = count(array_filter($polls, fn($poll): bool => $poll->isExpired()));
|
||||
$io->out(__('{0} Umfrage(n), davon {1} abgelaufen.', count($polls), $expired));
|
||||
|
||||
Reference in new issue
Block a user