From dc22821312b8d5417e59af1ce0e83ebfe66e743a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 12 Jul 2017 18:37:08 +0200 Subject: [locationinfo] Improve dummy backend data generator --- .../inc/coursebackend/coursebackend_davinci.inc.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'modules-available/locationinfo') diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php index 4c2dde6c..53617a61 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php @@ -61,10 +61,8 @@ class CourseBackend_Davinci extends CourseBackend * @param $roomId string name of the room * @return array|bool if successful the arrayrepresentation of the timetable */ - private function fetchRoomRaw($roomId) + private function fetchRoomRaw($roomId, $startDate, $endDate) { - $startDate = new DateTime('today 0:00'); - $endDate = new DateTime('+7 days 0:00'); $url = $this->location . "content=xml&type=room&name=" . urlencode($roomId) . "&startdate=" . $startDate->format('d.m.Y') . "&enddate=" . $endDate->format('d.m.Y'); $ch = curl_init(); @@ -92,9 +90,13 @@ class CourseBackend_Davinci extends CourseBackend public function fetchSchedulesInternal($requestedRoomIds) { + $startDate = new DateTime('today 0:00'); + $endDate = new DateTime('+7 days 0:00'); + $lower = (int)$startDate->format('Ymd'); + $upper = (int)$endDate->format('Ymd'); $schedules = []; foreach ($requestedRoomIds as $roomId) { - $return = $this->fetchRoomRaw($roomId); + $return = $this->fetchRoomRaw($roomId, $startDate, $endDate); if ($return === false) { continue; } @@ -113,6 +115,9 @@ class CourseBackend_Davinci extends CourseBackend $this->error = 'Lesson is missing Date, Start or Finish'; continue; } + $c = (int)$lesson['Date']; + if ($c < $lower || $c > $upper) + continue; $date = $lesson['Date']; $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2); $start = $lesson['Start']; -- cgit v1.2.3-55-g7522