1
0

RegenerateBirthdayCalendars.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\DAV\Migration;
  25. use OCA\DAV\BackgroundJob\RegisterRegenerateBirthdayCalendars;
  26. use OCP\BackgroundJob\IJobList;
  27. use OCP\IConfig;
  28. use OCP\Migration\IOutput;
  29. use OCP\Migration\IRepairStep;
  30. class RegenerateBirthdayCalendars implements IRepairStep {
  31. /** @var IJobList */
  32. private $jobList;
  33. /** @var IConfig */
  34. private $config;
  35. /**
  36. * @param IJobList $jobList
  37. * @param IConfig $config
  38. */
  39. public function __construct(IJobList $jobList,
  40. IConfig $config) {
  41. $this->jobList = $jobList;
  42. $this->config = $config;
  43. }
  44. /**
  45. * @return string
  46. */
  47. public function getName() {
  48. return 'Regenerating birthday calendars to use new icons and fix old birthday events without year';
  49. }
  50. /**
  51. * @param IOutput $output
  52. */
  53. public function run(IOutput $output) {
  54. // only run once
  55. if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') {
  56. $output->info('Repair step already executed');
  57. return;
  58. }
  59. $output->info('Adding background jobs to regenerate birthday calendar');
  60. $this->jobList->add(RegisterRegenerateBirthdayCalendars::class);
  61. // if all were done, no need to redo the repair during next upgrade
  62. $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes');
  63. }
  64. }