/** * returns events for a given course * * @get /course/:course_id/events */ public function getEventsForCourse($course_id) { if (!$GLOBALS['perm']->have_studip_perm('user', $course_id, $GLOBALS['user']->id)) { $this->error(401); } $seminar = new Seminar($course_id); $dates = getAllSortedSingleDates($seminar); $total = sizeof($dates); $events = array(); foreach (array_slice($dates, $this->offset, $this->limit) as $date) { // get issue titles $issue_titles = array(); if (is_array($issues = $date->getIssueIDs())) { foreach ($issues as $is) { $issue = new Issue(array('issue_id' => $is)); $issue_titles[] = $issue->getTitle(); } } $room = self::getRoomForSingleDate($date); $events[] = array('event_id' => $date->getSingleDateID(), 'start' => $date->getStartTime(), 'end' => $date->getEndTime(), 'title' => $date->toString(), 'description' => implode(', ', $issue_titles), 'categories' => $data->getTypeName() ?: '', 'room' => $room ?: '', 'deleted' => $data->isExTermin(), 'canceled' => $date->isHoliday() ?: false); } $this->etag(md5(serialize($events))); return $this->paginated($events, $total, compact('course_id')); }
public function export_action() { $course = new Course($_SESSION['SessionSeminar']); $sem = new Seminar($_SESSION['SessionSeminar']); $themen =& $sem->getIssues(); $termine = getAllSortedSingleDates($sem); $dates = array(); if (is_array($termine) && sizeof($termine) > 0) { foreach ($termine as $singledate_id => $singledate) { if (!$singledate->isExTermin()) { $tmp_ids = $singledate->getIssueIDs(); $title = $description = ''; if (is_array($tmp_ids)) { $title = trim(join("\n", array_map(function ($tid) use($themen) { return $themen[$tid]->getTitle(); }, $tmp_ids))); $description = trim(join("\n\n", array_map(function ($tid) use($themen) { return $themen[$tid]->getDescription(); }, $tmp_ids))); } $dates[] = array('date' => $singledate->toString(), 'title' => $title, 'description' => $description, 'start' => $singledate->getStartTime(), 'related_persons' => $singledate->getRelatedPersons()); } elseif ($singledate->getComment()) { $dates[] = array('date' => $singledate->toString(), 'title' => _('fällt aus') . ' (' . _('Kommentar:') . ' ' . $singledate->getComment() . ')', 'description' => '', 'start' => $singledate->getStartTime(), 'related_persons' => array()); } } } $factory = $this->get_template_factory(); $template = $factory->open($this->get_default_template("export")); $template->set_attribute('dates', $dates); $content = $template->render(); $content = mb_encode_numericentity($content, array(0x80, 0xffff, 0, 0xffff), 'cp1252'); $filename = prepareFilename($course['name'] . '-' . _("Ablaufplan")) . '.doc'; $this->set_content_type(get_mime_type($filename)); $this->response->add_header('Content-Disposition', 'attachment;filename="' . $filename . '"'); $this->response->add_header('Expires', 0); $this->response->add_header('Cache-Control', 'private'); $this->response->add_header('Pragma', 'cache'); $this->render_text($content); }