MDL-65033 mod_forum: Toggle pin state via ajax

This commit is contained in:
andrewnicols 2019-03-21 06:30:26 +08:00 committed by Peter
parent 34e2f9c0c2
commit 25a97f99a9
2 changed files with 24 additions and 2 deletions

View File

@ -81,7 +81,19 @@ define(['core/ajax'], function(Ajax) {
args: {
forumid: forumId,
discussionid: discussionId,
targetstate: targetState
targetstate: targetState}
};
return Ajax.call([request])[0];
};
var togglePin = function(forumid, discussionid, targetstate, includetext) {
var request = {
methodname: 'mod_forum_set_pin_state',
args: {
forumid: forumid,
discussionid: discussionid,
targetstate: targetstate,
includetext: includetext,
}
};
return Ajax.call([request])[0];
@ -91,6 +103,7 @@ define(['core/ajax'], function(Ajax) {
setDiscussionSubscriptionState: setDiscussionSubscriptionState,
addDiscussionPost: addDiscussionPost,
setDiscussionLockState: setDiscussionLockState,
toggleFavouriteDiscussionState: toggleFavouriteDiscussionState
toggleFavouriteDiscussionState: toggleFavouriteDiscussionState,
togglePin: togglePin
};
});

View File

@ -155,4 +155,13 @@ $functions = array(
'ajax' => true,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
),
'mod_forum_set_pin_state' => array(
'classname' => 'mod_forum_external',
'methodname' => 'set_pin_state',
'classpath' => 'mod/forum/externallib.php',
'description' => 'Set the pin state',
'type' => 'write',
'ajax' => true,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
),
);