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);
function MoodleAnnotationService($username) { global $CFG; AnnotationService::AnnotationService(AnnotationGlobals::getHost(), AnnotationGlobals::getServicePath(), AnnotationGlobals::getInstallDate(), $username, $CFG->wwwroot); $this->tablePrefix = $CFG->prefix; }