From ac6e7bdfbf3479c655d7b883e50b6b01aa08784d Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 17 May 2015 22:09:44 -0400 Subject: Add iCalendar public access for projects --- app/Controller/Ical.php | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 app/Controller/Ical.php (limited to 'app/Controller') diff --git a/app/Controller/Ical.php b/app/Controller/Ical.php new file mode 100644 index 00000000..55cc64a6 --- /dev/null +++ b/app/Controller/Ical.php @@ -0,0 +1,52 @@ +request->getStringParam('token'); + $project = $this->project->getByToken($token); + + // Token verification + if (empty($project)) { + $this->forbidden(true); + } + + $start = $this->request->getStringParam('start', strtotime('-1 month')); + $end = $this->request->getStringParam('end', strtotime('+2 months')); + + // Common filter + $filter = $this->taskFilter + ->create() + ->filterByProject($project['id']); + + // Tasks + if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') { + $calendar = $filter->copy()->filterByCreationDateRange($start, $end)->addDateTimeIcalEvents('date_creation', 'date_completed'); + } + else { + $calendar = $filter->copy()->filterByStartDateRange($start, $end)->addDateTimeIcalEvents('date_started', 'date_completed'); + } + + // Tasks with due date + $calendar = $filter->copy()->filterByDueDateRange($start, $end)->addAllDayIcalEvents('date_due', $calendar); + + $this->response->contentType('text/calendar; charset=utf-8'); + echo $calendar->render(); + } +} -- cgit v1.2.3