1
0

FixBirthdayCalendarComponent.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud GmbH.
  4. *
  5. * @author Thomas Müller <thomas.mueller@tmit.eu>
  6. *
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OCA\DAV\Migration;
  23. use OCA\DAV\CalDAV\BirthdayService;
  24. use OCP\IDBConnection;
  25. use OCP\Migration\IOutput;
  26. use OCP\Migration\IRepairStep;
  27. class FixBirthdayCalendarComponent implements IRepairStep {
  28. /** @var IDBConnection */
  29. private $connection;
  30. /**
  31. * FixBirthdayCalendarComponent constructor.
  32. *
  33. * @param IDBConnection $connection
  34. */
  35. public function __construct(IDBConnection $connection) {
  36. $this->connection = $connection;
  37. }
  38. /**
  39. * @inheritdoc
  40. */
  41. public function getName() {
  42. return 'Fix component of birthday calendars';
  43. }
  44. /**
  45. * @inheritdoc
  46. */
  47. public function run(IOutput $output) {
  48. $query = $this->connection->getQueryBuilder();
  49. $updated = $query->update('calendars')
  50. ->set('components', $query->createNamedParameter('VEVENT'))
  51. ->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
  52. ->execute();
  53. $output->info("$updated birthday calendars updated.");
  54. }
  55. }