{"version":3,"file":"repository.min.js","sources":["https:\/\/lms.mgt.sjp.ac.lk\/mod\/forum\/amd\/src\/repository.js"],"sourcesContent":["\/\/ This file is part of Moodle - http:\/\/moodle.org\/\n\/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\n\/**\n * Forum repository class to encapsulate all of the AJAX requests that subscribe or unsubscribe\n * can be sent for forum.\n *\n * @module mod_forum\/repository\n * @copyright 2019 Andrew Nicols \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\ndefine(['core\/ajax'], function(Ajax) {\n \/**\n * Set the subscription state for a discussion in a forum.\n *\n * @param {number} forumId ID of the forum the discussion belongs to\n * @param {number} discussionId ID of the discussion with the subscription state\n * @param {boolean} targetState Set the subscribed state. True == subscribed; false == unsubscribed.\n * @return {object} jQuery promise\n *\/\n var setDiscussionSubscriptionState = function(forumId, discussionId, targetState) {\n var request = {\n methodname: 'mod_forum_set_subscription_state',\n args: {\n forumid: forumId,\n discussionid: discussionId,\n targetstate: targetState\n }\n };\n return Ajax.call([request])[0];\n };\n\n var addDiscussionPost = function(postid, subject, message, messageformat, isprivatereply, topreferredformat) {\n var request = {\n methodname: 'mod_forum_add_discussion_post',\n args: {\n postid: postid,\n message: message,\n messageformat: messageformat,\n subject: subject,\n options: [{\n name: \"private\",\n value: isprivatereply,\n }, {\n name: \"topreferredformat\",\n value: topreferredformat,\n }]\n }\n };\n return Ajax.call([request])[0];\n };\n\n \/**\n * Set the favourite state for a discussion in a forum.\n *\n * @param {number} forumId ID of the forum the discussion belongs to\n * @param {number} discussionId ID of the discussion with the subscription state\n * @param {null|date} targetState Set the favourite state. True == favourited; false == unfavourited.\n * @return {object} jQuery promise\n *\/\n var setFavouriteDiscussionState = function(forumId, discussionId, targetState) {\n var request = {\n methodname: 'mod_forum_toggle_favourite_state',\n args: {\n discussionid: discussionId,\n targetstate: targetState\n }\n };\n return Ajax.call([request])[0];\n };\n\n var setDiscussionLockState = function(forumId, discussionId, targetState) {\n var request = {\n methodname: 'mod_forum_set_lock_state',\n args: {\n forumid: forumId,\n discussionid: discussionId,\n targetstate: targetState}\n };\n return Ajax.call([request])[0];\n };\n\n \/**\n * Set the pinned state for the discussion provided.\n *\n * @param {number} forumid\n * @param {number} discussionid\n * @param {boolean} targetstate\n * @return {*|Promise}\n *\/\n var setPinDiscussionState = function(forumid, discussionid, targetstate) {\n var request = {\n methodname: 'mod_forum_set_pin_state',\n args: {\n discussionid: discussionid,\n targetstate: targetstate\n }\n };\n return Ajax.call([request])[0];\n };\n\n \/**\n * Get the discussions for the user and cmid provided.\n *\n * @param {number} userid\n * @param {number} cmid\n * @param {string} sortby\n * @param {string} sortdirection\n * @return {*|Promise}\n *\/\n var getDiscussionByUserID = function(userid, cmid, sortby = 'modified', sortdirection = 'DESC') {\n var request = {\n methodname: 'mod_forum_get_discussion_posts_by_userid',\n args: {\n userid: userid,\n cmid: cmid,\n sortby: sortby,\n sortdirection: sortdirection,\n },\n };\n return Ajax.call([request])[0];\n };\n\n \/**\n * Get the posts for the discussion ID provided.\n *\n * @param {number} discussionId\n * @param {String} sortby\n * @param {String} sortdirection\n * @return {*|Promise}\n *\/\n var getDiscussionPosts = function(discussionId, sortby = 'created', sortdirection = 'ASC') {\n var request = {\n methodname: 'mod_forum_get_discussion_posts',\n args: {\n discussionid: discussionId,\n sortby: sortby,\n sortdirection: sortdirection,\n },\n };\n return Ajax.call([request])[0];\n };\n\n return {\n setDiscussionSubscriptionState: setDiscussionSubscriptionState,\n addDiscussionPost: addDiscussionPost,\n setDiscussionLockState: setDiscussionLockState,\n setFavouriteDiscussionState: setFavouriteDiscussionState,\n setPinDiscussionState: setPinDiscussionState,\n getDiscussionByUserID: getDiscussionByUserID,\n getDiscussionPosts: getDiscussionPosts,\n };\n});\n"],"names":["define","Ajax","setDiscussionSubscriptionState","forumId","discussionId","targetState","request","methodname","args","forumid","discussionid","targetstate","call","addDiscussionPost","postid","subject","message","messageformat","isprivatereply","topreferredformat","options","name","value","setDiscussionLockState","setFavouriteDiscussionState","setPinDiscussionState","getDiscussionByUserID","userid","cmid","sortby","sortdirection","getDiscussionPosts"],"mappings":";;;;;;;;AAuBAA,8BAAO,CAAC,cAAc,SAASC,YAoIpB,CACHC,+BA5HiC,SAASC,QAASC,aAAcC,iBAC7DC,QAAU,CACVC,WAAY,mCACZC,KAAM,CACFC,QAASN,QACTO,aAAcN,aACdO,YAAaN,qBAGdJ,KAAKW,KAAK,CAACN,UAAU,IAoH5BO,kBAjHoB,SAASC,OAAQC,QAASC,QAASC,cAAeC,eAAgBC,uBAClFb,QAAU,CACVC,WAAY,gCACZC,KAAM,CACFM,OAAQA,OACRE,QAASA,QACTC,cAAeA,cACfF,QAASA,QACTK,QAAS,CAAC,CACNC,KAAM,UACNC,MAAOJ,gBACR,CACCG,KAAM,oBACNC,MAAOH,6BAIZlB,KAAKW,KAAK,CAACN,UAAU,IAiG5BiB,uBA3EyB,SAASpB,QAASC,aAAcC,iBACrDC,QAAU,CACVC,WAAY,2BACZC,KAAM,CACFC,QAASN,QACTO,aAAcN,aACdO,YAAaN,qBAEdJ,KAAKW,KAAK,CAACN,UAAU,IAoE5BkB,4BAvF8B,SAASrB,QAASC,aAAcC,iBAC1DC,QAAU,CACVC,WAAY,mCACZC,KAAM,CACFE,aAAcN,aACdO,YAAaN,qBAGdJ,KAAKW,KAAK,CAACN,UAAU,IAgF5BmB,sBA1DwB,SAAShB,QAASC,aAAcC,iBACpDL,QAAU,CACVC,WAAY,0BACZC,KAAM,CACFE,a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