function show_atom($summary, $annotations) { global $CFG; $annotationobjs = array(); foreach ($annotations as $annotationrec) { $annotationobjs[] = annotation_globals::record_to_annotation($annotationrec); } MarginaliaHelper::generateAnnotationFeed($annotationobjs, annotation_globals::get_feed_tag_uri(), MarginaliaHelper::getLastModified($annotationObjs, annotation_globals::get_install_date()), annotation_globals::get_service_path(), annotation_globals::get_host(), $summary->get_feed_url('atom'), $CFG->wwwroot); }
header('HTTP/1.1 400 Bad Request'); echo '<h1>400 Bad Request</h1>' . htmlspecialchars($query->error); } elseif (!MarginaliaHelper::isUrlSafe($summaryUrl)) { header('HTTP/1.1 400 Bad Request'); echo '<h1>400 Bad Request</h1>Bad url parameter'; } else { // Display individual annotations // Dunno if the range sorting is working $annotations = get_records_sql($query->sql('section_type, section_name, quote_title, start_block, start_word, start_char, end_block, end_word, end_char')); $format = array_key_exists('format', $_GET) ? $_GET['format'] : 'html'; if ('atom' == $format) { $annotationObjs = array(); foreach ($annotations as $annotationRec) { $annotationObjs[] = AnnotationGlobals::recordToAnnotation($annotationRec); } MarginaliaHelper::generateAnnotationFeed($annotationObjs, AnnotationGlobals::getFeedTagUri(), MarginaliaHelper::getLastModified($annotationObjs, AnnotationGlobals::getInstallDate()), AnnotationGlobals::getServicePath(), AnnotationGlobals::getHost(), $query->getFeedUrl('atom'), $CFG->wwwroot); } else { // Get the course. This can't be passed as a GET parameter because this URL could be via the // Atom feed, and the Atom feed is generated exclusively by annotation code which doesn't know // that much about Moodle. So the handler has to query it based on a discussion ID or the like. $course = null; $courseId = $query->handler->courseId; if (null != $courseId) { if (!($course = get_record("course", "id", $courseId))) { error("Course ID is incorrect - discussion is faulty "); } // Ok, now this is probably very wrong. If the user looks for annotations within a course, // it requires a login. Without the course (i.e. in a more general search), it doesn't! // I would eleminate this, but I don't really know how Moodle security works. #geof# if ($course->category) { require_login($course->id);
/** * Emit an Atom document for a list of annotations * The annotations should already be sorted */ function getAtom($annotations, $feedUrl, $baseUrl) { $feedLastModified = MarginaliaHelper::getLastModified($annotations, $this->installDate); $feedTagUri = "tag:" . $this->host . ',' . date('Y-m-d', $this->installDate) . ":annotation"; header('Content-Type: application/xml'); echo '<?xml version="1.0" encoding="utf-8"?>' . "\n"; echo MarginaliaHelper::generateAnnotationFeed($annotations, $feedTagUri, $feedLastModified, $this->servicePath, $this->host, $feedUrl, $baseUrl); }