summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/frontend/facades/EventFacade.php7
-rw-r--r--app/frontend/facades/UserFacade.php21
2 files changed, 27 insertions, 1 deletions
diff --git a/app/frontend/facades/EventFacade.php b/app/frontend/facades/EventFacade.php
index 14f809d..79ca363 100644
--- a/app/frontend/facades/EventFacade.php
+++ b/app/frontend/facades/EventFacade.php
@@ -5,6 +5,7 @@ Prado::using('Application.dto.EventDTO');
Prado::using('Application.dto.TimezoneDTO');
Prado::using('Application.dto.GridEventDTO');
Prado::using('Application.dto.CalendarGridDTO');
+Prado::using('Application.dto.GroupedCalendarGridDTO');
Prado::using('Application.model.Calendar');
Prado::using('Application.facades.CalendarFacade');
Prado::using('Application.user.DbUser');
@@ -86,7 +87,11 @@ class EventFacade extends Facade {
$timeframe = CalendarFacade::getInstance()->getCalendarBoundaries(
$year, $month, $timezone
);
- return new CalendarGridDTO(
+ $dtoClass = 'CalendarGridDTO';
+ if (UserFacade::getInstance()->getGroupedViewPreference($user)) {
+ $dtoClass = 'Grouped' . $dtoClass;
+ }
+ return new $dtoClass(
$this->getTimeframeListForUser(
$user,
$timeframe[0], $timeframe[1],
diff --git a/app/frontend/facades/UserFacade.php b/app/frontend/facades/UserFacade.php
index 864fb58..5c8b6c0 100644
--- a/app/frontend/facades/UserFacade.php
+++ b/app/frontend/facades/UserFacade.php
@@ -97,6 +97,27 @@ class UserFacade extends Facade {
return NULL;
}
+ public function setGroupedViewPreference(DbUser $user, bool $value) {
+ if ($user->IsGuest) {
+ throw new TInvlaidDataException(
+ Prado::localize(
+ 'Grouped view preference change impossible for guest user'
+ )
+ );
+ }
+ $user->DbRecord->GroupedView = $value;
+ $user->DbRecord->save();
+ }
+
+ public function getGroupedViewPreference(DbUser $user) {
+ if (!$user->IsGuest) {
+ return TPropertyValue::ensureBoolean(
+ $user->DbRecord->GroupedView
+ );
+ }
+ return FALSE;
+ }
+
}
?>