Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plugins bot
moodle-plugins-snapshots
Commits
34dc9284
Commit
34dc9284
authored
Jan 24, 2017
by
Andrew Nicols
Browse files
Merge branch 'MDL-57550-master' of
git://github.com/danpoltawski/moodle
parents
d68d5ce3
1847d4c5
Changes
6
Hide whitespace changes
Inline
Side-by-side
mod/forum/classes/output/big_search_form.php
View file @
34dc9284
...
...
@@ -48,7 +48,6 @@ class big_search_form implements renderable, templatable {
public
$fullwords
;
public
$notwords
;
public
$phrase
;
public
$scripturl
;
public
$showfullwords
;
public
$subject
;
public
$user
;
...
...
@@ -65,7 +64,6 @@ class big_search_form implements renderable, templatable {
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'
);
...
...
@@ -153,7 +151,6 @@ class big_search_form implements renderable, templatable {
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
;
...
...
mod/forum/forum.js
deleted
100644 → 0
View file @
d68d5ce3
var
timefromitems
=
[
'
fromday
'
,
'
frommonth
'
,
'
fromyear
'
,
'
fromhour
'
,
'
fromminute
'
];
var
timetoitems
=
[
'
today
'
,
'
tomonth
'
,
'
toyear
'
,
'
tohour
'
,
'
tominute
'
];
function
forum_produce_subscribe_link
(
forumid
,
backtoindex
,
ltext
,
ltitle
)
{
var
elementid
=
"
subscriptionlink
"
;
var
subs_link
=
document
.
getElementById
(
elementid
);
if
(
subs_link
){
subs_link
.
innerHTML
=
"
<a title='
"
+
ltitle
+
"
' href='
"
+
M
.
cfg
.
wwwroot
+
"
/mod/forum/subscribe.php?id=
"
+
forumid
+
backtoindex
+
"
&sesskey=
"
+
M
.
cfg
.
sesskey
+
"
'>
"
+
ltext
+
"
<
\
/a>
"
;
}
}
function
forum_produce_tracking_link
(
forumid
,
ltext
,
ltitle
)
{
var
elementid
=
"
trackinglink
"
;
var
subs_link
=
document
.
getElementById
(
elementid
);
if
(
subs_link
){
subs_link
.
innerHTML
=
"
<a title='
"
+
ltitle
+
"
' href='
"
+
M
.
cfg
.
wwwroot
+
"
/mod/forum/settracking.php?id=
"
+
forumid
+
"
&sesskey=
"
+
M
.
cfg
.
sesskey
+
"
'>
"
+
ltext
+
"
<
\
/a>
"
;
}
}
function
lockoptions_timetoitems
()
{
lockoptions
(
'
searchform
'
,
'
timefromrestrict
'
,
timefromitems
);
}
function
lockoptions_timefromitems
()
{
lockoptions
(
'
searchform
'
,
'
timetorestrict
'
,
timetoitems
);
}
function
lockoptions
(
formid
,
master
,
subitems
)
{
// Subitems is an array of names of sub items.
// Optionally, each item in subitems may have a
// companion hidden item in the form with the
// same name but prefixed by "h".
var
form
=
document
.
forms
[
formid
],
i
;
if
(
form
[
master
].
checked
)
{
for
(
i
=
0
;
i
<
subitems
.
length
;
i
++
)
{
unlockoption
(
form
,
subitems
[
i
]);
}
}
else
{
for
(
i
=
0
;
i
<
subitems
.
length
;
i
++
)
{
lockoption
(
form
,
subitems
[
i
]);
}
}
return
(
true
);
}
function
lockoption
(
form
,
item
)
{
form
[
item
].
setAttribute
(
'
disabled
'
,
'
disabled
'
);
if
(
form
.
elements
[
'
h
'
+
item
])
{
form
.
elements
[
'
h
'
+
item
].
value
=
1
;
}
}
function
unlockoption
(
form
,
item
)
{
form
[
item
].
removeAttribute
(
'
disabled
'
);
if
(
form
.
elements
[
'
h
'
+
item
])
{
form
.
elements
[
'
h
'
+
item
].
value
=
0
;
}
}
mod/forum/lib.php
View file @
34dc9284
...
...
@@ -4791,12 +4791,13 @@ function forum_post_subscription($fromform, $forum, $discussion) {
* 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'
),
...
...
@@ -4835,22 +4836,11 @@ function forum_get_subscribe_link($forum, $context, $messages = array(), $cantac
}
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
));
}
}
...
...
mod/forum/templates/big_search_form.mustache
View file @
34dc9284
...
...
@@ -21,7 +21,6 @@
Example
context
(
json
)
:
{
"scripturl"
:
"https://example.com/mod/forum/forum.js"
,
"actionurl"
:
"https://example.com/mod/forum/search.php"
,
"courseid"
:
"2"
,
"words"
:
"apples"
,
...
...
@@ -52,9 +51,8 @@
{{#
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"
>
<table
class=
"searchbox
table
"
id=
"form"
>
<tr>
<td
class=
"c0"
>
<label
for=
"words"
>
{{#
str
}}
searchwords, forum
{{/
str
}}
</label>
...
...
@@ -95,7 +93,7 @@
{{#
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"
>
...
...
@@ -109,7 +107,7 @@
{{#
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"
>
...
...
@@ -147,14 +145,30 @@
</td>
</tr>
<tr>
<td
colspan=
"2"
class=
"submit"
align=
"center"
>
<input
type=
"submit"
value=
{{#
quote
}}{{#
str
}}
searchforums
,
forum
{{/
str
}}{{/
quote
}}
>
<td
colspan=
"2"
class=
"submit"
>
<div
class=
"text-center"
>
<input
type=
"submit"
value=
{{#
quote
}}{{#
str
}}
searchforums
,
forum
{{/
str
}}{{/
quote
}}
>
</div>
</td>
</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
}}
mod/forum/upgrade.txt
View file @
34dc9284
...
...
@@ -4,6 +4,9 @@ information provided here is intended especially for developers.
=== 3.3 ===
* External function get_forums_by_courses now returns and additional field "istracked" that indicates if the user
is tracking the related forum.
* The legacy forum.js file has been removed, this includes the js functions:
forum_produce_subscribe_link, forum_produce_tracking_link, lockoptions_timetoitems,
lockoptions_timefromitems, lockoptions, lockoption, unlockoption
=== 3.2 ===
* The setting $CFG->forum_replytouser has been removed in favour of a centralized noreplyaddress setting.
...
...
theme/boost/templates/mod_forum/big_search_form.mustache
View file @
34dc9284
...
...
@@ -21,7 +21,6 @@
Example
context
(
json
)
:
{
"scripturl"
:
"https://example.com/mod/forum/forum.js"
,
"actionurl"
:
"https://example.com/mod/forum/search.php"
,
"courseid"
:
"2"
,
"words"
:
"apples"
,
...
...
@@ -52,9 +51,8 @@
{{#
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"
>
<table
class=
"searchbox table table-striped"
id=
"form"
>
<tr>
<td
class=
"c0 text-xs-right"
>
<label
for=
"words"
>
{{#
str
}}
searchwords, forum
{{/
str
}}
</label>
...
...
@@ -95,7 +93,7 @@
{{#
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"
>
...
...
@@ -109,7 +107,7 @@
{{#
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"
>
...
...
@@ -154,8 +152,22 @@
</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
}}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment