From 1a2cd8ca8c3a5d4561905fc3139654d06b9cefd7 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 May 2016 12:48:05 +0200 Subject: * adding calendar to user preference --- app/php/facades/CalendarFacade.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app') diff --git a/app/php/facades/CalendarFacade.php b/app/php/facades/CalendarFacade.php index 25dec5f..a1ff42d 100644 --- a/app/php/facades/CalendarFacade.php +++ b/app/php/facades/CalendarFacade.php @@ -39,6 +39,18 @@ class CalendarFacade extends Facade { return []; } + public function addToPreference(DbUser $user, $calendarID) { + if (!$user->IsGuest) { + $calendar = Calendar::finder()->findByPk($calendarID); + if ($calendar) { + $preference = new UserPreference(); + $preference->CalendarID = $calendar->UID; + $preference->UserID = $user->DbRecord->ID; + $preference->save(); + } + } + } + public function removeFromPreference(DbUser $user, $calendarID) { if (!$user->IsGuest) { $preferenceRecord = UserPreference::finder()->find( -- cgit v1.2.3