public $fullwords;
public $notwords;
public $phrase;
- public $scripturl;
public $showfullwords;
public $subject;
public $user;
public function __construct($course) {
global $DB;
$this->course = $course;
- $this->scripturl = new moodle_url('/mod/forum/forum.js');
$this->showfullwords = $DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres';
$this->actionurl = new moodle_url('/mod/forum/search.php');
public function export_for_template(renderer_base $output) {
$data = new stdClass();
- $data->scripturl = $this->scripturl->out(false);
$data->courseid = $this->course->id;
$data->words = $this->words;
$data->phrase = $this->phrase;
* Any strings not passed in are taken from the $defaultmessages array
* at the top of the function.
* @param bool $cantaccessagroup
- * @param bool $fakelink
+ * @param bool $unused1
* @param bool $backtoindex
- * @param array $subscribed_forums
+ * @param array $unused2
* @return string
*/
-function forum_get_subscribe_link($forum, $context, $messages = array(), $cantaccessagroup = false, $fakelink=true, $backtoindex=false, $subscribed_forums=null) {
+function forum_get_subscribe_link($forum, $context, $messages = array(), $cantaccessagroup = false, $unused1 = true,
+ $backtoindex = false, $unused2 = null) {
global $CFG, $USER, $PAGE, $OUTPUT;
$defaultmessages = array(
'subscribed' => get_string('unsubscribe', 'forum'),
} else {
$backtoindexlink = '';
}
- $link = '';
- if ($fakelink) {
- $PAGE->requires->js('/mod/forum/forum.js');
- $PAGE->requires->js_function_call('forum_produce_subscribe_link', array($forum->id, $backtoindexlink, $linktext, $linktitle));
- $link = "<noscript>";
- }
$options['id'] = $forum->id;
$options['sesskey'] = sesskey();
$url = new moodle_url('/mod/forum/subscribe.php', $options);
- $link .= $OUTPUT->single_button($url, $linktext, 'get', array('title'=>$linktitle));
- if ($fakelink) {
- $link .= '</noscript>';
- }
-
- return $link;
+ return $OUTPUT->single_button($url, $linktext, 'get', array('title' => $linktitle));
}
}
{{#str}}searchforumintro, forum{{/str}}
</div>
<div class="box generalbox boxaligncenter">
- <script type="text/javascript" src="{{scripturl}}"></script>
<form id="searchform" action="{{actionurl}}" method="get">
<table class="searchbox" id="form" cellpadding="10">
<tr>
{{#str}}searchdatefrom, forum{{/str}}
</td>
<td class="c1">
- <input type="checkbox" name="timefromrestrict" value="1" onclick="return lockoptions('searchform', 'timefromrestrict', timefromitems)" {{#datefromchecked}}checked{{/datefromchecked}}>
+ <input type="checkbox" name="timefromrestrict" value="1" {{#datefromchecked}}checked{{/datefromchecked}}>
{{{datefromfields}}}
<input type="hidden" name="hfromday" value="0">
<input type="hidden" name="hfrommonth" value="0">
{{#str}}searchdateto, forum{{/str}}
</td>
<td class="c1">
- <input type="checkbox" name="timetorestrict" value="1" onclick="return lockoptions('searchform', 'timetorestrict', timetoitems)" {{#datetochecked}}checked{{/datetochecked}}>
+ <input type="checkbox" name="timetorestrict" value="1" {{#datetochecked}}checked{{/datetochecked}}>
{{{datetofields}}}
<input type="hidden" name="htoday" value="0">
<input type="hidden" name="htomonth" value="0">
</tr>
</table>
</form>
- {{#js}}
- lockoptions_timetoitems();
- lockoptions_timefromitems();
- {{/js}}
</div>
+{{#js}}
+ require(['jquery'], function($) {
+ var toggleDateFields = function(prefix, disabled) {
+ $('#searchform select[name^=' + prefix + ']').prop('disabled', disabled);
+ $('#searchform input[name^=h' + prefix + ']').val(disabled ? 1 : 0);
+ };
+
+ toggleDateFields('from', true);
+ $("#searchform input[name='timefromrestrict']").click(function() {
+ toggleDateFields('from', !this.checked);
+ });
+
+ toggleDateFields('to', true);
+ $("#searchform input[name='timetorestrict']").click(function() {
+ toggleDateFields('to', !this.checked);
+ });
+ });
+{{/js}}
{{#str}}searchforumintro, forum{{/str}}
</div>
<div class="box generalbox boxaligncenter">
- <script type="text/javascript" src="{{scripturl}}"></script>
<form id="searchform" action="{{actionurl}}" method="get">
<table class="searchbox table table-striped" id="form" cellpadding="10">
<tr>
{{#str}}searchdatefrom, forum{{/str}}
</td>
<td class="c1 text-nowrap form-inline">
- <input type="checkbox" name="timefromrestrict" value="1" onclick="return lockoptions('searchform', 'timefromrestrict', timefromitems)" {{#datefromchecked}}checked{{/datefromchecked}}>
+ <input type="checkbox" name="timefromrestrict" value="1" {{#datefromchecked}}checked{{/datefromchecked}}>
{{{datefromfields}}}
<input type="hidden" name="hfromday" value="0">
<input type="hidden" name="hfrommonth" value="0">
{{#str}}searchdateto, forum{{/str}}
</td>
<td class="c1 text-nowrap form-inline">
- <input type="checkbox" name="timetorestrict" value="1" onclick="return lockoptions('searchform', 'timetorestrict', timetoitems)" {{#datetochecked}}checked{{/datetochecked}}>
+ <input type="checkbox" name="timetorestrict" value="1" {{#datetochecked}}checked{{/datetochecked}}>
{{{datetofields}}}
<input type="hidden" name="htoday" value="0">
<input type="hidden" name="htomonth" value="0">
</tr>
</table>
</form>
- {{#js}}
- lockoptions_timetoitems();
- lockoptions_timefromitems();
- {{/js}}
</div>
+{{#js}}
+require(['jquery'], function($) {
+ var toggleDateFields = function(prefix, disabled) {
+ $('#searchform select[name^=' + prefix + ']').prop('disabled', disabled);
+ $('#searchform input[name^=h' + prefix + ']').val(disabled ? 1 : 0);
+ };
+
+ toggleDateFields('from', true);
+ $("#searchform input[name='timefromrestrict']").click(function() {
+ toggleDateFields('from', !this.checked);
+ });
+
+ toggleDateFields('to', true);
+ $("#searchform input[name='timetorestrict']").click(function() {
+ toggleDateFields('to', !this.checked);
+ });
+});
+{{/js}}
\ No newline at end of file