diff options
| author | Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de> | 2021-12-17 16:20:12 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2021-12-17 16:20:12 +0000 |
| commit | b0a1a7adf5203efa32661b96ecb023fef74c5d2d (patch) | |
| tree | c4641b27164f1e8d4feb2274164bed26578721af /cli/Commands/Fix/EndTimeWeeklyRecurredEvents.php | |
| parent | cb0a67594116a17c78182637908c4723f37e7263 (diff) | |
CLI-Skript `studip` einführen und alte Skripte entsprechend umstellen
Diffstat (limited to 'cli/Commands/Fix/EndTimeWeeklyRecurredEvents.php')
| -rw-r--r-- | cli/Commands/Fix/EndTimeWeeklyRecurredEvents.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cli/Commands/Fix/EndTimeWeeklyRecurredEvents.php b/cli/Commands/Fix/EndTimeWeeklyRecurredEvents.php new file mode 100644 index 0000000..40e7a2b --- /dev/null +++ b/cli/Commands/Fix/EndTimeWeeklyRecurredEvents.php @@ -0,0 +1,40 @@ +<?php + +namespace Studip\Cli\Commands\Fix; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; + +class EndTimeWeeklyRecurredEvents extends Command +{ + protected static $defaultName = 'fix:end-time-weekly-recurred-events'; + + protected function configure(): void + { + $this->setDescription('Fix end time weekly recurred events'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $events = \EventData::findBySQL("rtype = 'WEEKLY' AND IFNULL(count, 0) > 0"); + $cal_event = new \CalendarEvent(); + + $i = 0; + + foreach ($events as $event) { + $id = $event->getId(); + $cal_event->event = $event; + $rrule = $cal_event->getRecurrence(); + $cal_event->setRecurrence($rrule); + $event->expire = $cal_event->event->expire; + $event->setId($id); + $event->store(); + $i++; + } + $io->info('Wrong end time of recurrence fixed for ' . $i . ' events.'); + return Command::SUCCESS; + } +} |
