Skip to content

Commit

Permalink
Merge branch 'MDL-57660-32' of git://github.com/junpataleta/moodle in…
Browse files Browse the repository at this point in the history
…to MOODLE_32_STABLE
  • Loading branch information
danpoltawski committed Feb 6, 2017
2 parents 672ce4c + f33a8d4 commit e0c4e64
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
18 changes: 18 additions & 0 deletions mod/forum/classes/output/big_search_form.php
Expand Up @@ -150,6 +150,15 @@ public function set_words($value) {
$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();

Expand Down Expand Up @@ -188,6 +197,15 @@ public function export_for_template(renderer_base $output) {
. 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;
Expand Down
3 changes: 2 additions & 1 deletion mod/forum/search.php
Expand Up @@ -318,7 +318,7 @@
* @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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/templates/big_search_form.mustache
Expand Up @@ -125,7 +125,7 @@
<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>
Expand Down
2 changes: 1 addition & 1 deletion theme/boost/templates/mod_forum/big_search_form.mustache
Expand Up @@ -125,7 +125,7 @@
<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>
Expand Down

0 comments on commit e0c4e64

Please sign in to comment.