function doGetAnnotation($id) { global $CFG; // Check whether the range column exists (for backwards compatibility) $range = ''; if (!column_type($this->tablePrefix . 'annotation', 'range')) { $range = ', a.range AS range '; } // Caller should ensure that id is numeric $query = "SELECT a.id, a.userid, a.url,\n\t\t\t a.start_block, a.start_xpath, a.start_word, a.start_char,\n\t\t\t a.end_block, a.end_xpath, a.end_word, a.end_char,\n\t\t\t a.note, a.access, a.quote, a.quote_title, a.quote_author,\n\t\t\t a.link, a.link_title, a.action,\n\t\t\t a.created, a.modified {$range}\n\t\t\t FROM {$this->tablePrefix}annotation AS a\n\t\t\tWHERE a.id = {$id}"; $resultSet = get_record_sql($query); if ($resultSet && count($resultSet) != 0) { $annotation = AnnotationGlobals::recordToAnnotation($resultSet); return $annotation; } else { return null; } }
$query = new AnnotationSummaryQuery($summaryUrl, $searchUser, $searchOf, $searchQuery); if ($query->error) { 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#