MDL-36806 question files: fix unnecessary require_login call.
authorTim Hunt <T.J.Hunt@open.ac.uk>
Fri, 23 Nov 2012 15:54:58 +0000 (15:54 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Fri, 23 Nov 2012 15:56:46 +0000 (15:56 +0000)
quiz_question_pluginfile later does the correct check. Doing this
other check first means you get an error about changing $PAGE->context.

lib/questionlib.php
question/previewlib.php

index 311629d..1cf1620 100644 (file)
@@ -1803,10 +1803,10 @@ function question_pluginfile($course, $context, $component, $filearea, $args, $f
         send_file_not_found();
     }
 
-    list($context, $course, $cm) = get_context_info_array($context->id);
-    require_login($course, false, $cm);
-
     if ($filearea === 'export') {
+        list($context, $course, $cm) = get_context_info_array($context->id);
+        require_login($course, false, $cm);
+
         require_once($CFG->dirroot . '/question/editlib.php');
         $contexts = new question_edit_contexts($context);
         // check export capability
index e228245..16adc1c 100644 (file)
@@ -231,6 +231,9 @@ function question_preview_question_pluginfile($course, $context, $component,
         $filearea, $qubaid, $slot, $args, $forcedownload, $fileoptions) {
     global $USER, $DB, $CFG;
 
+    list($context, $course, $cm) = get_context_info_array($context->id);
+    require_login($course, false, $cm);
+
     $quba = question_engine::load_questions_usage_by_activity($qubaid);
 
     if (!question_has_capability_on($quba->get_question($slot), 'use')) {