function doListAnnotations($url, $username, $block) { $query = new AnnotationSummaryQuery($url, $username, null, null); if ($query->error) { $this->httpError(400, 'Bad Request', 'Bad URL'); return null; } elseif (isguest() && ANNOTATION_REQUIRE_USER) { $this->httpError(403, 'Forbidden', 'Anonymous listing not allowed'); return null; } else { $querySql = $query->sql('section_type, section_name, quote_title'); $annotationSet = get_records_sql($querySql); $annotations = array(); if ($annotationSet) { $i = 0; foreach ($annotationSet as $r) { $annotations[$i++] = AnnotationGlobals::recordToAnnotation($r); } } $format = $this->getQueryParam('format', 'atom'); $logUrl = 'annotate.php?format=' . $format . ($username ? '&user='******'') . '&url=' . $url; add_to_log($query->handler->courseId, 'annotation', 'list', $logUrl); return $annotations; } }
*/ $urlString = $_SERVER['REQUEST_URI']; if ($_SERVER['REQUEST_METHOD'] != 'GET') { header('HTTP/1.1 405 Method Not Allowed'); header('Allow: GET'); } else { $errorPage = array_key_exists('error', $_GET) ? $_GET['error'] : null; $summaryUrl = $_GET['url']; $excludeFields = array_key_exists('exclude', $_GET) ? $_GET['exclude'] : ''; $excludeFields = split(' ', $excludeFields); $possibleExcludeFields = array('quote', 'note', 'source', 'user', 'controls'); $nCols = 5 - count(array_intersect($excludeFields, $possibleExcludeFields)); $searchQuery = array_key_exists('q', $_GET) ? $_GET['q'] : null; $searchUser = array_key_exists('u', $_GET) ? $_GET['u'] : null; $searchOf = array_key_exists('search-of', $_GET) ? $_GET['search-of'] : 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);