From a69844e2640d559ecd78fbe39d1bcadc1cb53d15 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 May 2016 17:13:01 +0200 Subject: * mass setting of user-preferred calendars --- app/php/facades/CalendarFacade.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/php/facades/CalendarFacade.php b/app/php/facades/CalendarFacade.php index 5eed764..232acf3 100644 --- a/app/php/facades/CalendarFacade.php +++ b/app/php/facades/CalendarFacade.php @@ -96,6 +96,20 @@ class CalendarFacade extends Facade { $preference->save(); } + public function setPreferredCalendars(User $user, $calendars) { + //TODO: remove old preference, optionally + $transaction = $this->beginTransaction(); + try { + foreach ($calendars as $calendar) { + $this->setPreferredCalendar($user, $calendar); + } + $transaction->commit(); + } catch (Exception $e) { + $transaction->rollback(); + throw $e; + } + } + public function getEventsForTimeframe(CalendarDTO $calendar, DateTime $dateFrom, DateTime $dateTo, -- cgit v1.2.3