Browse files

Implemented events into CoursePag

  • Loading branch information...
1 parent 7bc9e99 commit 1ee8befd4d4678983fc0243526ed66dad0bc09ef @acolangelo acolangelo committed Jun 2, 2011
View
3 framework5/wddsocial/lang/page/global/en/CoursePageLang.php
@@ -13,6 +13,9 @@ public static function content($id, $var) {
case 'page-title':
return 'Course';
+ case 'events-header':
+ return 'Events';
+
default:
throw new Exception("Language pack content '$id' not found");
}
View
28 framework5/wddsocial/page/global/CoursePage.php
@@ -77,6 +77,34 @@ public function execute() {
$content .= render(':section',
array('section' => 'end_content_section', 'id' => 'latest'));
}
+
+ $content .= render(':section',
+ array('section' => 'begin_content_section',
+ 'id' => 'events',
+ 'classes' => array('small', 'no-margin', 'side-sticky'),
+ 'header' => $this->lang->text('events-header'))
+ );
+
+ import('wddsocial.model.WDDSocial\EventVO');
+ # query
+ $limit = 3;
+ if (UserSession::is_authorized()) $query = $this->db->prepare($this->sql->getCourseEvents . " LIMIT 0, $limit");
+ else $query = $this->db->prepare($this->sql->getCoursePublicEvents . " LIMIT 0, $limit");
+ $query->setFetchMode(\PDO::FETCH_CLASS,'WDDSocial\EventVO');
+ $query->execute(array('id' => $course->id));
+
+ if ($query->rowCount() > 0) {
+ while ($event = $query->fetch()) {
+ $content .= render('wddsocial.view.content.WDDSocial\SmallDisplayView', array('type' => $event->type,'content' => $event));
+ }
+ }
+ else {
+ $content .= render('wddsocial.view.content.WDDSocial\SmallDisplayEmptyView',array('type' => 'events'));
+ }
+
+ # create section footer
+ $content .= render(':section',
+ array('section' => 'end_content_section', 'id' => 'events'));
}
else {
redirect('/404');
View
21 framework5/wddsocial/sql/SelectorSQL.php
@@ -1259,6 +1259,27 @@ class SelectorSQL{
WHERE p.title = 'Public' AND TIMESTAMPDIFF(MINUTE,NOW(),endDateTime) > -1
GROUP BY e.id) AS events
WHERE events.flagCount < 3",
+
+ 'getCourseEvents' => "
+ SELECT *
+ FROM(SELECT e.id, e.userID, icsUID, e.title, description, vanityURL, 'event' AS `type`, location, e.datetime, startDateTime, DATE_FORMAT(startDateTime,'%b') AS `month`, DATE_FORMAT(startDateTime,'%e') AS `day`, DATE_FORMAT(startDateTime,'%l:%i %p') AS `startTime`, DATE_FORMAT(endDateTime,'%l:%i %p') AS `endTime`, COUNT(DISTINCT ef.userID) AS flagCount
+ FROM events AS e
+ LEFT JOIN eventCourses AS ec ON (e.id = ec.eventID)
+ LEFT JOIN eventFlags AS ef ON (e.id = ef.eventID)
+ WHERE ec.courseID = :id AND TIMESTAMPDIFF(MINUTE,NOW(),endDateTime) > -1
+ GROUP BY e.id) AS events
+ WHERE events.flagCount < 3",
+
+ 'getCoursePublicEvents' => "
+ SELECT *
+ FROM(SELECT e.id, e.userID, icsUID, e.title, description, vanityURL, 'event' AS `type`, location, e.datetime, startDateTime, DATE_FORMAT(startDateTime,'%b') AS `month`, DATE_FORMAT(startDateTime,'%e') AS `day`, DATE_FORMAT(startDateTime,'%l:%i %p') AS `startTime`, DATE_FORMAT(endDateTime,'%l:%i %p') AS `endTime`, COUNT(DISTINCT ef.userID) AS flagCount
+ FROM events AS e
+ LEFT JOIN eventCourses AS ec ON (e.id = ec.eventID)
+ LEFT JOIN eventFlags AS ef ON (e.id = ef.eventID)
+ LEFT JOIN privacyLevels AS p ON (e.privacyLevelID = p.id)
+ WHERE ec.courseID = :id AND p.title = 'Public' AND TIMESTAMPDIFF(MINUTE,NOW(),endDateTime) > -1
+ GROUP BY e.id) AS events
+ WHERE events.flagCount < 3",

0 comments on commit 1ee8bef

Please sign in to comment.