getControlState('user'); } public function setUserToDisplay($user) { $this->setControlState('user', $user); } public function onPreRender($param) { parent::onPreRender($param); $this->Events->setDataSource( $this->_getEventsForUser($this->UserToDisplay) ); $this->Events->dataBind(); } private function _getEventsForUser(DbUser $user) { $utc = new DateTimeZone('UTC'); $events = EventFacade::getInstance()->getEventList( (new DateTime('now', $utc))->format('Y-m-d H:i:s'), (new DateTime('+7 days', $utc))->format('Y-m-d H:i:s'), $user->getCalendarPreference() ); $calendars = Calendar::finder()->findAllByPks( array_unique( array_map( function($event) { return $event->CalendarID; }, $events ) ) ); return array_map( function($event) use($calendars) { $dto = new EventDTO(); $dto->loadRecord($event, $calendars); return $dto; }, $events ); } } ?>