summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-03-16 00:00:23 +0100
committeremkael <emkael@tlen.pl>2016-03-16 00:00:23 +0100
commit3b489d6312a4f2734e4ab3129e64d3ab007f3716 (patch)
tree4e202e324a34e48619a8f0be7aa149e0895e3d73
parent4847856dd8adcbc0004f6653c627cb7cf7773a95 (diff)
* upcoming events on profile page
-rw-r--r--app/php/components/UpcomingEvents.php52
-rw-r--r--app/php/components/UpcomingEvents.tpl10
-rw-r--r--app/php/pages/Profile.page4
3 files changed, 66 insertions, 0 deletions
diff --git a/app/php/components/UpcomingEvents.php b/app/php/components/UpcomingEvents.php
new file mode 100644
index 0000000..e18f2f4
--- /dev/null
+++ b/app/php/components/UpcomingEvents.php
@@ -0,0 +1,52 @@
+<?php
+
+Prado::using('Application.facades.EventFacade');
+Prado::using('Application.dto.EventDTO');
+
+class UpcomingEvents extends TTemplateControl {
+
+ public function getUserToDisplay() {
+ return $this->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) {
+ $events = EventFacade::getInstance()->getEventList(
+ date('Y-m-d'),
+ date('Y-m-d', strtotime('+7 days')),
+ $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
+ );
+ }
+
+}
+
+?>
diff --git a/app/php/components/UpcomingEvents.tpl b/app/php/components/UpcomingEvents.tpl
new file mode 100644
index 0000000..d660f54
--- /dev/null
+++ b/app/php/components/UpcomingEvents.tpl
@@ -0,0 +1,10 @@
+Upcoming events:
+<br />
+<com:TRepeater ID="Events">
+ <prop:ItemTemplate>
+ <%# $this->Data->DateString %>
+ <%# $this->Data->Name %>
+ (<%# $this->Data->Calendar->Name %>)
+ <br />
+ </prop:ItemTemplate>
+</com:TRepeater>
diff --git a/app/php/pages/Profile.page b/app/php/pages/Profile.page
index c5e06ca..0cd3dd3 100644
--- a/app/php/pages/Profile.page
+++ b/app/php/pages/Profile.page
@@ -6,4 +6,8 @@
<com:UserSelection>
<prop:UserToDisplay><%= $this->User %></prop:UserToDisplay>
</com:UserSelection>
+ <br />
+ <com:UpcomingEvents>
+ <prop:UserToDisplay><%= $this->User %></prop:UserToDisplay>
+ </com:UpcomingEvents>
</com:TContent>