diff --git a/mod/forum/classes/output/big_search_form.php b/mod/forum/classes/output/big_search_form.php index 6a778985f62..814510369bb 100644 --- a/mod/forum/classes/output/big_search_form.php +++ b/mod/forum/classes/output/big_search_form.php @@ -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; diff --git a/mod/forum/search.php b/mod/forum/search.php index 931d04526d5..ec399f94d77 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -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); diff --git a/mod/forum/templates/big_search_form.mustache b/mod/forum/templates/big_search_form.mustache index 6fc760cff45..f9371f2c3e0 100644 --- a/mod/forum/templates/big_search_form.mustache +++ b/mod/forum/templates/big_search_form.mustache @@ -123,7 +123,7 @@ diff --git a/theme/boost/templates/mod_forum/big_search_form.mustache b/theme/boost/templates/mod_forum/big_search_form.mustache index c376145a928..241d842692f 100644 --- a/theme/boost/templates/mod_forum/big_search_form.mustache +++ b/theme/boost/templates/mod_forum/big_search_form.mustache @@ -123,7 +123,7 @@