示例#1
0
 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;
     }
 }
示例#2
0
 $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);
         }
         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))) {