Merge branch 'MDL-57844-master' of git://github.com/dpalou/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 6 Feb 2017 18:53:55 +0000 (19:53 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 6 Feb 2017 18:53:55 +0000 (19:53 +0100)
12 files changed:
lib/amd/build/form-autocomplete.min.js
lib/amd/src/form-autocomplete.js
mod/forum/classes/output/big_search_form.php
mod/forum/search.php
mod/forum/templates/big_search_form.mustache
question/type/gapselect/questionbase.php
question/type/match/question.php
question/type/multichoice/question.php
question/type/questionbase.php
question/type/upgrade.txt
rss/file.php
theme/boost/templates/mod_forum/big_search_form.mustache

index a29e064..17220a3 100644 (file)
Binary files a/lib/amd/build/form-autocomplete.min.js and b/lib/amd/build/form-autocomplete.min.js differ
index ca7f034..361d0e1 100644 (file)
@@ -33,7 +33,7 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
         ENTER: 13,
         SPACE: 32,
         ESCAPE: 27,
-        COMMA: 188,
+        COMMA: 44,
         UP: 38
     };
 
@@ -543,14 +543,6 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
                     // We handled this event, so prevent it.
                     e.preventDefault();
                     return false;
-                case KEYS.COMMA:
-                    if (options.tags) {
-                        // If we are allowing tags, comma should create a tag (or enter).
-                        createItem(options, state, originalSelect);
-                    }
-                    // We handled this event, so prevent it.
-                    e.preventDefault();
-                    return false;
                 case KEYS.UP:
                     // Choose the previous active item.
                     activatePreviousItem(state);
@@ -581,6 +573,19 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
             }
             return true;
         });
+        // Support multi lingual COMMA keycode (44).
+        inputElement.on('keypress', function(e) {
+            if (e.keyCode === KEYS.COMMA) {
+                if (options.tags) {
+                    // If we are allowing tags, comma should create a tag (or enter).
+                    createItem(options, state, originalSelect);
+                }
+                // We handled this event, so prevent it.
+                e.preventDefault();
+                return false;
+            }
+            return true;
+        });
         // Handler used to force set the value from behat.
         inputElement.on('behat:set-value', function() {
             var suggestionsElement = $(document.getElementById(state.suggestionsId));
index 6a77898..8145103 100644 (file)
@@ -148,6 +148,15 @@ class big_search_form implements renderable, templatable {
         $this->words = $value;
     }
 
+    /**
+     * Forum ID setter search criteria.
+     *
+     * @param int $forumid The forum ID.
+     */
+    public function set_forumid($forumid) {
+        $this->forumid = $forumid;
+    }
+
     public function export_for_template(renderer_base $output) {
         $data = new stdClass();
 
@@ -185,6 +194,15 @@ class big_search_form implements renderable, templatable {
                             . html_writer::select_time('hours', 'tohour', $dateto)
                             . html_writer::select_time('minutes', 'tominute', $dateto);
 
+        if ($this->forumid && !empty($this->forumoptions)) {
+            foreach ($this->forumoptions as $index => $option) {
+                if ($option['value'] == $this->forumid) {
+                    $this->forumoptions[$index]['selected'] = true;
+                } else {
+                    $this->forumoptions[$index]['selected'] = false;
+                }
+            }
+        }
         $data->forumoptions = $this->forumoptions;
 
         return $data;
index 931d045..ec399f9 100644 (file)
@@ -318,7 +318,7 @@ echo $OUTPUT->footer();
   * @return void The function prints the form.
   */
 function forum_print_big_search_form($course) {
-    global $PAGE, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $OUTPUT;
+    global $PAGE, $words, $subject, $phrase, $user, $fullwords, $notwords, $datefrom, $dateto, $forumid;
 
     $renderable = new \mod_forum\output\big_search_form($course, $user);
     $renderable->set_words($words);
@@ -329,6 +329,7 @@ function forum_print_big_search_form($course) {
     $renderable->set_dateto($dateto);
     $renderable->set_subject($subject);
     $renderable->set_user($user);
+    $renderable->set_forumid($forumid);
 
     $output = $PAGE->get_renderer('mod_forum');
     echo $output->render($renderable);
index 6fc760c..f9371f2 100644 (file)
                 <td class="c1">
                     <select name="forumid" id="menuforumid">
                         {{#forumoptions}}
-                            <option value="{{value}}">{{name}}</option>
+                            <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
                         {{/forumoptions}}
                     </select>
                 </td>
index 180a448..76a3882 100644 (file)
@@ -321,7 +321,7 @@ abstract class qtype_gapselect_question_base extends question_graded_automatical
     public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload) {
         if ($component == 'question' && in_array($filearea,
                 array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) {
-            return $this->check_combined_feedback_file_access($qa, $options, $filearea);
+            return $this->check_combined_feedback_file_access($qa, $options, $filearea, $args);
 
         } else if ($component == 'question' && $filearea == 'hint') {
             return $this->check_hint_file_access($qa, $options, $args);
index b373fba..4113010 100644 (file)
@@ -342,7 +342,7 @@ class qtype_match_question extends question_graded_automatically_with_countback
 
         } else if ($component == 'question' && in_array($filearea,
                 array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) {
-            return $this->check_combined_feedback_file_access($qa, $options, $filearea);
+            return $this->check_combined_feedback_file_access($qa, $options, $filearea, $args);
 
         } else if ($component == 'question' && $filearea == 'hint') {
             return $this->check_hint_file_access($qa, $options, $args);
index 2c5e17c..09b9493 100644 (file)
@@ -113,7 +113,7 @@ abstract class qtype_multichoice_base extends question_graded_automatically {
     public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload) {
         if ($component == 'question' && in_array($filearea,
                 array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) {
-            return $this->check_combined_feedback_file_access($qa, $options, $filearea);
+            return $this->check_combined_feedback_file_access($qa, $options, $filearea, $args);
 
         } else if ($component == 'question' && $filearea == 'answer') {
             $answerid = reset($args); // Itemid is answer id.
index 879381e..b6a4b89 100644 (file)
@@ -668,11 +668,18 @@ abstract class question_graded_automatically extends question_with_responses
      * @param question_attempt $qa the question attempt being displayed.
      * @param question_display_options $options the options that control display of the question.
      * @param string $filearea the name of the file area.
+     * @param array $args the remaining bits of the file path.
      * @return bool whether access to the file should be allowed.
      */
-    protected function check_combined_feedback_file_access($qa, $options, $filearea) {
+    protected function check_combined_feedback_file_access($qa, $options, $filearea, $args = null) {
         $state = $qa->get_state();
 
+        if ($args === null) {
+            debugging('You must pass $args as the fourth argument to check_combined_feedback_file_access.',
+                    DEBUG_DEVELOPER);
+            $args = array($this->id); // Fake it for now, so the rest of this method works.
+        }
+
         if (!$state->is_finished()) {
             $response = $qa->get_last_qt_data();
             if (!$this->is_gradable_response($response)) {
index 470629c..6a74061 100644 (file)
@@ -1,5 +1,11 @@
 This files describes API changes for question type plugins.
 
+=== 3.1.5, 3.2.2, 3.3 ===
+
+* If you are using check_combined_feedback_file_access in your check_file_access method,
+  then you must now pass $args as the 4th argument, so the correct permission checks
+  can be performed. If you don't, you will get a developer debug notice.
+
 === 3.1 ===
 
 * The following functions, previously used (exclusively) by upgrade steps are not available
index b0bd7a2..9a31a11 100644 (file)
@@ -115,7 +115,11 @@ if ($token === "$inttoken") {
 }
 
 // Check the context actually exists.
-list($context, $course, $cm) = get_context_info_array($contextid);
+try {
+    list($context, $course, $cm) = get_context_info_array($contextid);
+} catch (dml_missing_record_exception $e) {
+    rss_error();
+}
 
 $PAGE->set_context($context);
 
index c376145..241d842 100644 (file)
                 <td class="c1">
                     <select name="forumid" id="menuforumid" class="form-control">
                         {{#forumoptions}}
-                            <option value="{{value}}">{{name}}</option>
+                            <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
                         {{/forumoptions}}
                     </select>
                 </td>