diff --git a/contentbank/amd/build/actions.min.js b/contentbank/amd/build/actions.min.js
index 2e95d9ad9e3..4d78f539037 100644
--- a/contentbank/amd/build/actions.min.js
+++ b/contentbank/amd/build/actions.min.js
@@ -1,2 +1,2 @@
-define ("core_contentbank/actions",["jquery","core/ajax","core/notification","core/str","core/templates","core/url","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g,h){var j={DELETE_CONTENT:"[data-action=\"deletecontent\"]"},k=function(){this.registerEvents()};k.prototype.registerEvents=function(){a(j.DELETE_CONTENT).click(function(b){b.preventDefault();var e=a(this).data("contentname"),f=a(this).data("contentid"),j=a(this).data("contextid"),k="";d.get_strings([{key:"deletecontent",component:"core_contentbank"},{key:"deletecontentconfirm",component:"core_contentbank",param:{name:e}},{key:"delete",component:"core"}]).then(function(a){var b=a[0],c=a[1];k=a[2];return g.create({title:b,body:c,type:g.types.SAVE_CANCEL,large:!0})}).done(function(a){a.setSaveButtonText(k);a.getRoot().on(h.save,function(){return i(f,j)});a.getRoot().on(h.hidden,function(){a.destroy()});a.show()}).catch(c.exception)})};function i(a,e){var g="success";b.call([{methodname:"core_contentbank_delete_content",args:{contentids:{contentid:a}}}])[0].then(function(a){if(a.result){return d.get_string("contentdeleted","core_contentbank")}g="error";return d.get_string("contentnotdeleted","core_contentbank")}).done(function(a){var b={contextid:e};if("success"==g){b.statusmsg=a}else{b.errormsg=a}window.location.href=f.relativeUrl("contentbank/index.php",b,!1)}).fail(c.exception)}return{init:function init(){return new k}}});
+define ("core_contentbank/actions",["jquery","core/ajax","core/notification","core/str","core/templates","core/url","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g,h){var k={DELETE_CONTENT:"[data-action=\"deletecontent\"]",RENAME_CONTENT:"[data-action=\"renamecontent\"]"},l=function(){this.registerEvents()};l.prototype.registerEvents=function(){a(k.DELETE_CONTENT).click(function(b){b.preventDefault();var e=a(this).data("contentname"),f=a(this).data("contentid"),j=a(this).data("contextid"),k="";d.get_strings([{key:"deletecontent",component:"core_contentbank"},{key:"deletecontentconfirm",component:"core_contentbank",param:{name:e}},{key:"delete",component:"core"}]).then(function(a){var b=a[0],c=a[1];k=a[2];return g.create({title:b,body:c,type:g.types.SAVE_CANCEL,large:!0})}).done(function(a){a.setSaveButtonText(k);a.getRoot().on(h.save,function(){return i(f,j)});a.getRoot().on(h.hidden,function(){a.destroy()});a.show()}).catch(c.exception)});a(k.RENAME_CONTENT).click(function(b){b.preventDefault();var f=a(this).data("contentname"),i=a(this).data("contentid"),k="";d.get_strings([{key:"renamecontent",component:"core_contentbank"},{key:"rename",component:"core_contentbank"}]).then(function(a){var b=a[0];k=a[1];return g.create({title:b,body:e.render("core_contentbank/renamecontent",{contentid:i,name:f}),type:g.types.SAVE_CANCEL})}).then(function(b){b.setSaveButtonText(k);b.getRoot().on(h.save,function(){var b=a("#newname").val();return j(i,b)});b.getRoot().on(h.hidden,function(){b.destroy()});b.show()}).catch(c.exception)})};function i(a,e){var g="success";b.call([{methodname:"core_contentbank_delete_content",args:{contentids:{contentid:a}}}])[0].then(function(a){if(a.result){return d.get_string("contentdeleted","core_contentbank")}g="error";return d.get_string("contentnotdeleted","core_contentbank")}).done(function(a){var b={contextid:e};if("success"==g){b.statusmsg=a}else{b.errormsg=a}window.location.href=f.relativeUrl("contentbank/index.php",b,!1)}).fail(c.exception)}function j(a,e){var g="success";b.call([{methodname:"core_contentbank_rename_content",args:{contentid:a,name:e}}])[0].then(function(a){if(a){return d.get_string("contentrenamed","core_contentbank")}g="error";return d.get_string("contentnotrenamed","core_contentbank")}).then(function(b){var d=null;if("success"==g){d={id:a,statusmsg:b};window.location.href=f.relativeUrl("contentbank/view.php",d,!1)}else{c.addNotification({message:b,type:"error"});c.fetchNotifications()}}).catch(c.exception)}return{init:function init(){return new l}}});
//# sourceMappingURL=actions.min.js.map
diff --git a/contentbank/amd/build/actions.min.js.map b/contentbank/amd/build/actions.min.js.map
index 05f46fb879d..6e5344eaf8c 100644
--- a/contentbank/amd/build/actions.min.js.map
+++ b/contentbank/amd/build/actions.min.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/actions.js"],"names":["define","$","Ajax","Notification","Str","Templates","Url","ModalFactory","ModalEvents","ACTIONS","DELETE_CONTENT","Actions","registerEvents","prototype","click","e","preventDefault","contentname","data","contentid","contextid","deleteButtonText","get_strings","key","component","param","name","then","langStrings","modalTitle","modalContent","create","title","body","type","types","SAVE_CANCEL","large","done","modal","setSaveButtonText","getRoot","on","save","deleteContent","hidden","destroy","show","catch","exception","requestType","call","methodname","args","contentids","result","get_string","message","params","statusmsg","errormsg","window","location","href","relativeUrl","fail"],"mappings":"AAuBAA,OAAM,4BAAC,CACH,QADG,CAEH,WAFG,CAGH,mBAHG,CAIH,UAJG,CAKH,gBALG,CAMH,UANG,CAOH,oBAPG,CAQH,mBARG,CAAD,CASN,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAAqCC,CAArC,CAAgDC,CAAhD,CAAqDC,CAArD,CAAmEC,CAAnE,CAAgF,IAOxEC,CAAAA,CAAO,CAAG,CACVC,cAAc,CAAE,iCADN,CAP8D,CAcxEC,CAAO,CAAG,UAAW,CACrB,KAAKC,cAAL,EACH,CAhB2E,CAqB5ED,CAAO,CAACE,SAAR,CAAkBD,cAAlB,CAAmC,UAAW,CAC1CX,CAAC,CAACQ,CAAO,CAACC,cAAT,CAAD,CAA0BI,KAA1B,CAAgC,SAASC,CAAT,CAAY,CACxCA,CAAC,CAACC,cAAF,GADwC,GAGpCC,CAAAA,CAAW,CAAGhB,CAAC,CAAC,IAAD,CAAD,CAAQiB,IAAR,CAAa,aAAb,CAHsB,CAIpCC,CAAS,CAAGlB,CAAC,CAAC,IAAD,CAAD,CAAQiB,IAAR,CAAa,WAAb,CAJwB,CAKpCE,CAAS,CAAGnB,CAAC,CAAC,IAAD,CAAD,CAAQiB,IAAR,CAAa,WAAb,CALwB,CAyBpCG,CAAgB,CAAG,EAzBiB,CA0BxCjB,CAAG,CAAC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CAACiD,IAAL,CAAU,CARI,CACVC,UAAU,CAAE,iCADF,CAEVC,IAAI,CAAE,CACFC,UAAU,CAAE,CAACnC,SAAS,CAATA,CAAD,CADV,CAFI,CAQJ,CAAV,EAAqB,CAArB,EAAwBQ,IAAxB,CAA6B,SAAST,CAAT,CAAe,CACxC,GAAIA,CAAI,CAACqC,MAAT,CAAiB,CACb,MAAOnD,CAAAA,CAAG,CAACoD,UAAJ,CAAe,gBAAf,CAAiC,kBAAjC,CACV,CACDN,CAAW,CAAG,OAAd,CACA,MAAO9C,CAAAA,CAAG,CAACoD,UAAJ,CAAe,mBAAf,CAAoC,kBAApC,CAEV,CAPD,EAOGlB,IAPH,CAOQ,SAASmB,CAAT,CAAkB,CACtB,GAAIC,CAAAA,CAAM,CAAG,CACTtC,SAAS,CAAEA,CADF,CAAb,CAGA,GAAmB,SAAf,EAAA8B,CAAJ,CAA8B,CAC1BQ,CAAM,CAACC,SAAP,CAAmBF,CACtB,CAFD,IAEO,CACHC,CAAM,CAACE,QAAP,CAAkBH,CACrB,CAEDI,MAAM,CAACC,QAAP,CAAgBC,IAAhB,CAAuBzD,CAAG,CAAC0D,WAAJ,CAAgB,uBAAhB,CAAyCN,CAAzC,IAC1B,CAlBD,EAkBGO,IAlBH,CAkBQ9D,CAAY,CAAC8C,SAlBrB,CAmBH,CAED,MAAqD,CASjD,KAAQ,eAAW,CACf,MAAO,IAAItC,CAAAA,CACd,CAXgD,CAaxD,CA1IK,CAAN","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 * Module to manage content bank actions, such as delete or rename.\n *\n * @module core_contentbank/actions\n * @package core_contentbank\n * @copyright 2020 Sara Arjona \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/templates',\n 'core/url',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, Templates, Url, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE_CONTENT: string}}\n */\n var ACTIONS = {\n DELETE_CONTENT: '[data-action=\"deletecontent\"]',\n };\n\n /**\n * Actions class.\n */\n var Actions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n Actions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE_CONTENT).click(function(e) {\n e.preventDefault();\n\n var contentname = $(this).data('contentname');\n var contentid = $(this).data('contentid');\n var contextid = $(this).data('contextid');\n\n var strings = [\n {\n key: 'deletecontent',\n component: 'core_contentbank'\n },\n {\n key: 'deletecontentconfirm',\n component: 'core_contentbank',\n param: {\n name: contentname,\n }\n },\n {\n key: 'delete',\n component: 'core'\n },\n ];\n\n var deleteButtonText = '';\n Str.get_strings(strings).then(function(langStrings) {\n var modalTitle = langStrings[0];\n var modalContent = langStrings[1];\n deleteButtonText = langStrings[2];\n\n return ModalFactory.create({\n title: modalTitle,\n body: modalContent,\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n });\n }).done(function(modal) {\n modal.setSaveButtonText(deleteButtonText);\n modal.getRoot().on(ModalEvents.save, function() {\n // The action is now confirmed, sending an action for it.\n return deleteContent(contentid, contextid);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n // Show the modal.\n modal.show();\n\n return;\n }).catch(Notification.exception);\n });\n };\n\n /**\n * Delete content from the content bank.\n *\n * @param {int} contentid The content to delete.\n * @param {int} contextid The contextid where the content belongs.\n */\n function deleteContent(contentid, contextid) {\n var request = {\n methodname: 'core_contentbank_delete_content',\n args: {\n contentids: {contentid}\n }\n };\n\n var requestType = 'success';\n Ajax.call([request])[0].then(function(data) {\n if (data.result) {\n return Str.get_string('contentdeleted', 'core_contentbank');\n }\n requestType = 'error';\n return Str.get_string('contentnotdeleted', 'core_contentbank');\n\n }).done(function(message) {\n var params = {\n contextid: contextid\n };\n if (requestType == 'success') {\n params.statusmsg = message;\n } else {\n params.errormsg = message;\n }\n // Redirect to the main content bank page and display the message as a notification.\n window.location.href = Url.relativeUrl('contentbank/index.php', params, false);\n }).fail(Notification.exception);\n }\n\n return /** @alias module:core_contentbank/actions */ {\n // Public variables and functions.\n\n /**\n * Initialise the contentbank actions.\n *\n * @method init\n * @return {Actions}\n */\n 'init': function() {\n return new Actions();\n }\n };\n});\n"],"file":"actions.min.js"}
\ No newline at end of file
+{"version":3,"sources":["../src/actions.js"],"names":["define","$","Ajax","Notification","Str","Templates","Url","ModalFactory","ModalEvents","ACTIONS","DELETE_CONTENT","RENAME_CONTENT","Actions","registerEvents","prototype","click","e","preventDefault","contentname","data","contentid","contextid","deleteButtonText","get_strings","key","component","param","name","then","langStrings","modalTitle","modalContent","create","title","body","type","types","SAVE_CANCEL","large","done","modal","setSaveButtonText","getRoot","on","save","deleteContent","hidden","destroy","show","catch","exception","saveButtonText","render","newname","val","renameContent","requestType","call","methodname","args","contentids","result","get_string","message","params","statusmsg","errormsg","window","location","href","relativeUrl","fail","id","addNotification","fetchNotifications"],"mappings":"AAuBAA,OAAM,4BAAC,CACH,QADG,CAEH,WAFG,CAGH,mBAHG,CAIH,UAJG,CAKH,gBALG,CAMH,UANG,CAOH,oBAPG,CAQH,mBARG,CAAD,CASN,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAAqCC,CAArC,CAAgDC,CAAhD,CAAqDC,CAArD,CAAmEC,CAAnE,CAAgF,IAOxEC,CAAAA,CAAO,CAAG,CACVC,cAAc,CAAE,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CAA6B,CACzBV,OAAO,CAAEA,CADgB,CAEzB5B,IAAI,CAAE,OAFmB,CAA7B,EAIAhC,CAAY,CAACuE,kBAAb,EACH,CAEJ,CAzBD,EAyBGzB,KAzBH,CAyBS9C,CAAY,CAAC+C,SAzBtB,CA0BH,CAED,MAAqD,CASjD,KAAQ,eAAW,CACf,MAAO,IAAItC,CAAAA,CACd,CAXgD,CAaxD,CAtOK,CAAN","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 * Module to manage content bank actions, such as delete or rename.\n *\n * @module core_contentbank/actions\n * @package core_contentbank\n * @copyright 2020 Sara Arjona \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/templates',\n 'core/url',\n 'core/modal_factory',\n 'core/modal_events'],\nfunction($, Ajax, Notification, Str, Templates, Url, ModalFactory, ModalEvents) {\n\n /**\n * List of action selectors.\n *\n * @type {{DELETE_CONTENT: string}}\n */\n var ACTIONS = {\n DELETE_CONTENT: '[data-action=\"deletecontent\"]',\n RENAME_CONTENT: '[data-action=\"renamecontent\"]',\n };\n\n /**\n * Actions class.\n */\n var Actions = function() {\n this.registerEvents();\n };\n\n /**\n * Register event listeners.\n */\n Actions.prototype.registerEvents = function() {\n $(ACTIONS.DELETE_CONTENT).click(function(e) {\n e.preventDefault();\n\n var contentname = $(this).data('contentname');\n var contentid = $(this).data('contentid');\n var contextid = $(this).data('contextid');\n\n var strings = [\n {\n key: 'deletecontent',\n component: 'core_contentbank'\n },\n {\n key: 'deletecontentconfirm',\n component: 'core_contentbank',\n param: {\n name: contentname,\n }\n },\n {\n key: 'delete',\n component: 'core'\n },\n ];\n\n var deleteButtonText = '';\n Str.get_strings(strings).then(function(langStrings) {\n var modalTitle = langStrings[0];\n var modalContent = langStrings[1];\n deleteButtonText = langStrings[2];\n\n return ModalFactory.create({\n title: modalTitle,\n body: modalContent,\n type: ModalFactory.types.SAVE_CANCEL,\n large: true\n });\n }).done(function(modal) {\n modal.setSaveButtonText(deleteButtonText);\n modal.getRoot().on(ModalEvents.save, function() {\n // The action is now confirmed, sending an action for it.\n return deleteContent(contentid, contextid);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n // Show the modal.\n modal.show();\n\n return;\n }).catch(Notification.exception);\n });\n\n $(ACTIONS.RENAME_CONTENT).click(function(e) {\n e.preventDefault();\n\n var contentname = $(this).data('contentname');\n var contentid = $(this).data('contentid');\n\n var strings = [\n {\n key: 'renamecontent',\n component: 'core_contentbank'\n },\n {\n key: 'rename',\n component: 'core_contentbank'\n },\n ];\n\n var saveButtonText = '';\n Str.get_strings(strings).then(function(langStrings) {\n var modalTitle = langStrings[0];\n saveButtonText = langStrings[1];\n\n return ModalFactory.create({\n title: modalTitle,\n body: Templates.render('core_contentbank/renamecontent', {'contentid': contentid, 'name': contentname}),\n type: ModalFactory.types.SAVE_CANCEL\n });\n }).then(function(modal) {\n modal.setSaveButtonText(saveButtonText);\n modal.getRoot().on(ModalEvents.save, function() {\n // The action is now confirmed, sending an action for it.\n var newname = $(\"#newname\").val();\n return renameContent(contentid, newname);\n });\n\n // Handle hidden event.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Destroy when hidden.\n modal.destroy();\n });\n\n // Show the modal.\n modal.show();\n\n return;\n }).catch(Notification.exception);\n });\n };\n\n /**\n * Delete content from the content bank.\n *\n * @param {int} contentid The content to delete.\n * @param {int} contextid The contextid where the content belongs.\n */\n function deleteContent(contentid, contextid) {\n var request = {\n methodname: 'core_contentbank_delete_content',\n args: {\n contentids: {contentid}\n }\n };\n\n var requestType = 'success';\n Ajax.call([request])[0].then(function(data) {\n if (data.result) {\n return Str.get_string('contentdeleted', 'core_contentbank');\n }\n requestType = 'error';\n return Str.get_string('contentnotdeleted', 'core_contentbank');\n\n }).done(function(message) {\n var params = {\n contextid: contextid\n };\n if (requestType == 'success') {\n params.statusmsg = message;\n } else {\n params.errormsg = message;\n }\n // Redirect to the main content bank page and display the message as a notification.\n window.location.href = Url.relativeUrl('contentbank/index.php', params, false);\n }).fail(Notification.exception);\n }\n\n /**\n * Rename content in the content bank.\n *\n * @param {int} contentid The content to rename.\n * @param {string} name The new name for the content.\n */\n function renameContent(contentid, name) {\n var request = {\n methodname: 'core_contentbank_rename_content',\n args: {\n contentid: contentid,\n name: name\n }\n };\n var requestType = 'success';\n Ajax.call([request])[0].then(function(data) {\n if (data) {\n return Str.get_string('contentrenamed', 'core_contentbank');\n }\n requestType = 'error';\n return Str.get_string('contentnotrenamed', 'core_contentbank');\n\n }).then(function(message) {\n var params = null;\n if (requestType == 'success') {\n params = {\n id: contentid,\n statusmsg: message\n };\n // Redirect to the content view page and display the message as a notification.\n window.location.href = Url.relativeUrl('contentbank/view.php', params, false);\n } else {\n // Fetch error notifications.\n Notification.addNotification({\n message: message,\n type: 'error'\n });\n Notification.fetchNotifications();\n }\n return;\n }).catch(Notification.exception);\n }\n\n return /** @alias module:core_contentbank/actions */ {\n // Public variables and functions.\n\n /**\n * Initialise the contentbank actions.\n *\n * @method init\n * @return {Actions}\n */\n 'init': function() {\n return new Actions();\n }\n };\n});\n"],"file":"actions.min.js"}
\ No newline at end of file
diff --git a/contentbank/amd/src/actions.js b/contentbank/amd/src/actions.js
index caa25c53780..561cb998341 100644
--- a/contentbank/amd/src/actions.js
+++ b/contentbank/amd/src/actions.js
@@ -39,6 +39,7 @@ function($, Ajax, Notification, Str, Templates, Url, ModalFactory, ModalEvents)
*/
var ACTIONS = {
DELETE_CONTENT: '[data-action="deletecontent"]',
+ RENAME_CONTENT: '[data-action="renamecontent"]',
};
/**
@@ -108,6 +109,54 @@ function($, Ajax, Notification, Str, Templates, Url, ModalFactory, ModalEvents)
return;
}).catch(Notification.exception);
});
+
+ $(ACTIONS.RENAME_CONTENT).click(function(e) {
+ e.preventDefault();
+
+ var contentname = $(this).data('contentname');
+ var contentid = $(this).data('contentid');
+
+ var strings = [
+ {
+ key: 'renamecontent',
+ component: 'core_contentbank'
+ },
+ {
+ key: 'rename',
+ component: 'core_contentbank'
+ },
+ ];
+
+ var saveButtonText = '';
+ Str.get_strings(strings).then(function(langStrings) {
+ var modalTitle = langStrings[0];
+ saveButtonText = langStrings[1];
+
+ return ModalFactory.create({
+ title: modalTitle,
+ body: Templates.render('core_contentbank/renamecontent', {'contentid': contentid, 'name': contentname}),
+ type: ModalFactory.types.SAVE_CANCEL
+ });
+ }).then(function(modal) {
+ modal.setSaveButtonText(saveButtonText);
+ modal.getRoot().on(ModalEvents.save, function() {
+ // The action is now confirmed, sending an action for it.
+ var newname = $("#newname").val();
+ return renameContent(contentid, newname);
+ });
+
+ // Handle hidden event.
+ modal.getRoot().on(ModalEvents.hidden, function() {
+ // Destroy when hidden.
+ modal.destroy();
+ });
+
+ // Show the modal.
+ modal.show();
+
+ return;
+ }).catch(Notification.exception);
+ });
};
/**
@@ -146,6 +195,49 @@ function($, Ajax, Notification, Str, Templates, Url, ModalFactory, ModalEvents)
}).fail(Notification.exception);
}
+ /**
+ * Rename content in the content bank.
+ *
+ * @param {int} contentid The content to rename.
+ * @param {string} name The new name for the content.
+ */
+ function renameContent(contentid, name) {
+ var request = {
+ methodname: 'core_contentbank_rename_content',
+ args: {
+ contentid: contentid,
+ name: name
+ }
+ };
+ var requestType = 'success';
+ Ajax.call([request])[0].then(function(data) {
+ if (data) {
+ return Str.get_string('contentrenamed', 'core_contentbank');
+ }
+ requestType = 'error';
+ return Str.get_string('contentnotrenamed', 'core_contentbank');
+
+ }).then(function(message) {
+ var params = null;
+ if (requestType == 'success') {
+ params = {
+ id: contentid,
+ statusmsg: message
+ };
+ // Redirect to the content view page and display the message as a notification.
+ window.location.href = Url.relativeUrl('contentbank/view.php', params, false);
+ } else {
+ // Fetch error notifications.
+ Notification.addNotification({
+ message: message,
+ type: 'error'
+ });
+ Notification.fetchNotifications();
+ }
+ return;
+ }).catch(Notification.exception);
+ }
+
return /** @alias module:core_contentbank/actions */ {
// Public variables and functions.
diff --git a/contentbank/classes/content.php b/contentbank/classes/content.php
index a77b7a08e84..27975cb61f4 100644
--- a/contentbank/classes/content.php
+++ b/contentbank/classes/content.php
@@ -24,6 +24,7 @@
namespace core_contentbank;
+use core_text;
use stored_file;
use stdClass;
use coding_exception;
@@ -102,6 +103,33 @@ abstract class content {
return $DB->update_record('contentbank_content', $this->content);
}
+ /**
+ * Set a new name to the content.
+ *
+ * @param string $name The name of the content.
+ * @return bool True if the content has been succesfully updated. False otherwise.
+ * @throws \coding_exception if not loaded.
+ */
+ public function set_name(string $name): bool {
+ if (empty($name)) {
+ return false;
+ }
+
+ // Clean name.
+ $name = clean_param($name, PARAM_TEXT);
+ if (core_text::strlen($name) > 255) {
+ $name = core_text::substr($name, 0, 255);
+ }
+
+ $oldname = $this->content->name;
+ $this->content->name = $name;
+ $updated = $this->update_content();
+ if (!$updated) {
+ $this->content->name = $oldname;
+ }
+ return $updated;
+ }
+
/**
* Returns the name of the content.
*
diff --git a/contentbank/classes/contenttype.php b/contentbank/classes/contenttype.php
index 46e92a914bf..05922b7e01c 100644
--- a/contentbank/classes/contenttype.php
+++ b/contentbank/classes/contenttype.php
@@ -24,7 +24,6 @@
namespace core_contentbank;
-use coding_exception;
use moodle_url;
/**
@@ -39,7 +38,7 @@ abstract class contenttype {
/** Plugin implements uploading feature */
const CAN_UPLOAD = 'upload';
- /** @var context This content's context. **/
+ /** @var context This contenttype's context. **/
protected $context = null;
/**
@@ -99,6 +98,18 @@ abstract class contenttype {
return $DB->delete_records('contentbank_content', ['id' => $content->get_id()]);
}
+ /**
+ * Rename this content from the content_bank.
+ * This method can be overwritten by the plugins if they need to change some other specific information.
+ *
+ * @param content $content The content to rename.
+ * @param string $name The name of the content.
+ * @return boolean true if the content has been renamed; false otherwise.
+ */
+ public function rename_content(content $content, string $name): bool {
+ return $content->set_name($name);
+ }
+
/**
* Returns the contenttype name of this content.
*
@@ -240,6 +251,41 @@ abstract class contenttype {
return true;
}
+ /**
+ * Check if the user can managed this content.
+ *
+ * @param content $content The content to be managed.
+ * @return bool True if content could be managed. False otherwise.
+ */
+ public final function can_manage(content $content): bool {
+ global $USER;
+
+ if ($this->context->id != $content->get_content()->contextid) {
+ // The content has to have exactly the same context as this contenttype.
+ return false;
+ }
+
+ // Check main contentbank management permission.
+ $hascapability = has_capability('moodle/contentbank:manageanycontent', $this->context);
+ if ($content->get_content()->usercreated == $USER->id) {
+ // This content has been created by the current user; check if they can manage their content.
+ $hascapability = $hascapability || has_capability('moodle/contentbank:manageowncontent', $this->context);
+ }
+
+ return $hascapability && $this->is_manage_allowed($content);
+ }
+
+ /**
+ * Returns if content allows managing.
+ *
+ * @param content $content The content to be managed.
+ * @return bool True if content allows uploading. False otherwise.
+ */
+ protected function is_manage_allowed(content $content): bool {
+ // Plugins can overwrite this function to add any check they need.
+ return true;
+ }
+
/**
* Returns the plugin supports the feature.
*
diff --git a/contentbank/classes/external/rename_content.php b/contentbank/classes/external/rename_content.php
new file mode 100644
index 00000000000..18d36f32347
--- /dev/null
+++ b/contentbank/classes/external/rename_content.php
@@ -0,0 +1,136 @@
+.
+
+/**
+ * External API to rename content bank content.
+ *
+ * @package core_contentbank
+ * @copyright 2020 Amaia Anabitarte
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace core_contentbank\external;
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once($CFG->libdir . '/externallib.php');
+
+use external_api;
+use external_function_parameters;
+use external_single_structure;
+use external_value;
+use external_warnings;
+
+/**
+ * This is the external method for renaming a content.
+ *
+ * @copyright 2020 Amaia Anabitarte
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class rename_content extends external_api {
+ /**
+ * rename_content parameters.
+ *
+ * @since Moodle 3.9
+ * @return external_function_parameters
+ */
+ public static function execute_parameters(): external_function_parameters {
+ return new external_function_parameters(
+ [
+ 'contentid' => new external_value(PARAM_INT, 'The content id to rename', VALUE_REQUIRED),
+ 'name' => new external_value(PARAM_RAW, 'The new name for the content', VALUE_REQUIRED),
+ ]
+ );
+ }
+
+ /**
+ * Rename content from the contentbank.
+ *
+ * @since Moodle 3.9
+ * @param int $contentid The content id to rename.
+ * @param string $name The new name.
+ * @return array True if the content has been renamed; false and the warning, otherwise.
+ */
+ public static function execute(int $contentid, string $name): array {
+ global $DB;
+
+ $result = false;
+ $warnings = [];
+
+ $params = self::validate_parameters(self::execute_parameters(), [
+ 'contentid' => $contentid,
+ 'name' => $name,
+ ]);
+ $params['name'] = clean_param($params['name'], PARAM_TEXT);
+ try {
+ $record = $DB->get_record('contentbank_content', ['id' => $contentid], '*', MUST_EXIST);
+ $contenttypeclass = "\\$record->contenttype\\contenttype";
+ if (class_exists($contenttypeclass)) {
+ $context = \context::instance_by_id($record->contextid, MUST_EXIST);
+ self::validate_context($context);
+ $contenttype = new $contenttypeclass($context);
+ $contentclass = "\\$record->contenttype\\content";
+ $content = new $contentclass($record);
+ // Check capability.
+ if ($contenttype->can_manage($content)) {
+ // This content can be renamed.
+ if ($contenttype->rename_content($content, $params['name'])) {
+ $result = true;
+ } else {
+ $warnings[] = [
+ 'item' => $contentid,
+ 'warningcode' => 'contentnotrenamed',
+ 'message' => get_string('contentnotrenamed', 'core_contentbank')
+ ];
+ }
+ } else {
+ // The user has no permission to manage this content.
+ $warnings[] = [
+ 'item' => $contentid,
+ 'warningcode' => 'nopermissiontomanage',
+ 'message' => get_string('nopermissiontomanage', 'core_contentbank')
+ ];
+ }
+ }
+ } catch (\moodle_exception $e) {
+ // The content or the context don't exist.
+ $warnings[] = [
+ 'item' => $contentid,
+ 'warningcode' => 'exception',
+ 'message' => $e->getMessage()
+ ];
+ }
+
+ return [
+ 'result' => $result,
+ 'warnings' => $warnings
+ ];
+ }
+
+ /**
+ * rename_content return.
+ *
+ * @since Moodle 3.9
+ * @return external_single_structure
+ */
+ public static function execute_returns(): external_single_structure {
+ return new external_single_structure([
+ 'result' => new external_value(PARAM_BOOL, 'The processing result'),
+ 'warnings' => new external_warnings()
+ ]);
+ }
+}
diff --git a/contentbank/templates/renamecontent.mustache b/contentbank/templates/renamecontent.mustache
new file mode 100644
index 00000000000..ea638d53207
--- /dev/null
+++ b/contentbank/templates/renamecontent.mustache
@@ -0,0 +1,30 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see .
+}}
+{{!
+ @template core_contentbank/renamecontent
+
+ Example context (json):
+ {
+ "contentid": 17,
+ "name": "Accordion"
+ }
+
+}}
+
+
+
+
diff --git a/contentbank/view.php b/contentbank/view.php
index 4c4a4c05213..d34205cda4e 100644
--- a/contentbank/view.php
+++ b/contentbank/view.php
@@ -35,7 +35,10 @@ $record = $DB->get_record('contentbank_content', ['id' => $id], '*', MUST_EXIST)
$context = context::instance_by_id($record->contextid, MUST_EXIST);
require_capability('moodle/contentbank:access', $context);
-$returnurl = new \moodle_url('/contentbank/index.php');
+$statusmsg = optional_param('statusmsg', '', PARAM_RAW);
+$errormsg = optional_param('errormsg', '', PARAM_RAW);
+
+$returnurl = new \moodle_url('/contentbank/index.php', ['contextid' => $context->id]);
$plugin = core_plugin_manager::instance()->get_plugin_info($record->contenttype);
if (!$plugin || !$plugin->is_enabled()) {
print_error('unsupported', 'core_contentbank', $returnurl);
@@ -46,7 +49,6 @@ $title = get_string('contentbank');
if ($PAGE->course) {
require_login($PAGE->course->id);
}
-$returnurl = new \moodle_url('/contentbank/index.php', ['contextid' => $context->id]);
$PAGE->set_url(new \moodle_url('/contentbank/view.php', ['id' => $id]));
$PAGE->set_context($context);
@@ -57,13 +59,32 @@ $PAGE->set_title($title);
$PAGE->set_pagetype('contenbank');
$contenttypeclass = "\\$record->contenttype\\contenttype";
-$contenttype = new $contenttypeclass($context);
$contentclass = "\\$record->contenttype\\content";
+if (!class_exists($contenttypeclass) || !class_exists($contentclass)) {
+ print_error('contenttypenotfound', 'error', $returnurl, $record->contenttype);
+}
+$contenttype = new $contenttypeclass($context);
$content = new $contentclass($record);
+
+// Create the cog menu with all the secondary actions, such as delete, rename...
+$actionmenu = new action_menu();
+$actionmenu->set_alignment(action_menu::TR, action_menu::BR);
+if ($contenttype->can_manage($content)) {
+ // Add the rename content item to the menu.
+ $attributes = [
+ 'data-action' => 'renamecontent',
+ 'data-contentname' => $content->get_name(),
+ 'data-contentid' => $content->get_id(),
+ ];
+ $actionmenu->add_secondary_action(new action_menu_link(
+ new moodle_url('#'),
+ new pix_icon('e/styleparagraph', get_string('rename')),
+ get_string('rename'),
+ false,
+ $attributes
+ ));
+}
if ($contenttype->can_delete($content)) {
- // Create the cog menu with all the secondary actions, such as delete, rename...
- $actionmenu = new action_menu();
- $actionmenu->set_alignment(action_menu::TR, action_menu::BR);
// Add the delete content item to the menu.
$attributes = [
'data-action' => 'deletecontent',
@@ -78,18 +99,24 @@ if ($contenttype->can_delete($content)) {
false,
$attributes
));
-
- // Add the cog menu to the header.
- $PAGE->add_header_action(html_writer::div(
- $OUTPUT->render($actionmenu),
- 'd-print-none',
- ['id' => 'region-main-settings-menu']
- ));
}
+// Add the cog menu to the header.
+$PAGE->add_header_action(html_writer::div(
+ $OUTPUT->render($actionmenu),
+ 'd-print-none',
+ ['id' => 'region-main-settings-menu']
+));
+
echo $OUTPUT->header();
echo $OUTPUT->box_start('generalbox');
+// If needed, display notifications.
+if ($errormsg !== '') {
+ echo $OUTPUT->notification($errormsg);
+} else if ($statusmsg !== '') {
+ echo $OUTPUT->notification($statusmsg, 'notifysuccess');
+}
if ($contenttype->can_access()) {
echo $contenttype->get_view_content($record);
}
diff --git a/lang/en/contentbank.php b/lang/en/contentbank.php
index c1c682be81a..1d3b885f488 100644
--- a/lang/en/contentbank.php
+++ b/lang/en/contentbank.php
@@ -24,23 +24,27 @@
$string['author'] = 'Author';
$string['contentdeleted'] = 'The content has been deleted.';
+$string['contentname'] = 'Content name';
$string['contentnotdeleted'] = 'An error was encountered while trying to delete the content.';
+$string['contentnotrenamed'] = 'An error was encountered while trying to rename the content.';
+$string['contentrenamed'] = 'The content has been renamed.';
$string['deletecontent'] = 'Delete content';
$string['deletecontentconfirm'] = 'Are you sure you want to delete the content \'{$a->name}\' and all associated files? This action cannot be undone.';
$string['file'] = 'Upload content';
$string['file_help'] = 'Files may be stored in the content bank for use in courses. Only files used by content types enabled on the site may be uploaded.';
$string['name'] = 'Content';
$string['nopermissiontodelete'] = 'You do not have permission to delete content.';
+$string['nopermissiontomanage'] = 'You do not have permission to manage content.';
$string['privacy:metadata:content:contenttype'] = 'The contenttype plugin of the content in the content bank.';
$string['privacy:metadata:content:name'] = 'Name of the content in the content bank.';
$string['privacy:metadata:content:timecreated'] = 'The time when the content was created.';
$string['privacy:metadata:content:timemodified'] = 'The time when the content was modified.';
$string['privacy:metadata:content:usercreated'] = 'The user has created the content.';
-$string['privacy:metadata:content:usercreated'] = 'The user who created the content.';
-$string['privacy:metadata:content:usermodified'] = 'Last user has modified the content.';
$string['privacy:metadata:content:usermodified'] = 'The last user who modified the content.';
$string['privacy:metadata:contentbankcontent'] = 'Stores the content of the content bank.';
$string['privacy:metadata:userid'] = 'The ID of the user creating or modifying content bank content.';
+$string['rename'] = 'Rename';
+$string['renamecontent'] = 'Rename content';
$string['timecreated'] = 'Time created';
$string['unsupported'] = 'This content type is not supported.';
$string['upload'] = 'Upload';
diff --git a/lang/en/role.php b/lang/en/role.php
index 12a250e00bf..21530dead6c 100644
--- a/lang/en/role.php
+++ b/lang/en/role.php
@@ -153,7 +153,9 @@ $string['confirmunassignno'] = 'Cancel';
$string['contentbank:access'] = 'Access the content bank';
$string['contentbank:deleteanycontent'] = 'Delete any content from the content bank';
$string['contentbank:deleteowncontent'] = 'Delete content from own content bank';
-$string['contentbank:upload'] = 'Upload content to the content bank';
+$string['contentbank:manageanycontent'] = 'Manage any content from the content bank (rename, move, publish, share, etc.)';
+$string['contentbank:manageowncontent'] = 'Manage content from own content bank (rename, move, publish, share, etc.)';
+$string['contentbank:upload'] = 'Upload new content in the content bank';
$string['context'] = 'Context';
$string['course:activityvisibility'] = 'Hide/show activities';
$string['course:bulkmessaging'] = 'Send a message to many people';
diff --git a/lib/db/access.php b/lib/db/access.php
index 155d223427e..93b736ac5b7 100644
--- a/lib/db/access.php
+++ b/lib/db/access.php
@@ -2522,4 +2522,26 @@ $capabilities = array(
'user' => CAP_ALLOW,
]
],
+
+ // Manage (rename, move, publish, share, etc.) any content from the content bank.
+ 'moodle/contentbank:manageanycontent' => [
+ 'riskbitmask' => RISK_DATALOSS,
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_COURSE,
+ 'archetypes' => array(
+ 'manager' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ )
+ ],
+
+ // Manage (rename, move, publish, share, etc.) content created by yourself.
+ 'moodle/contentbank:manageowncontent' => [
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_COURSE,
+ 'archetypes' => array(
+ 'manager' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ )
+ ],
);
diff --git a/lib/db/services.php b/lib/db/services.php
index a57a95dff56..2c4c81d6dc7 100644
--- a/lib/db/services.php
+++ b/lib/db/services.php
@@ -2773,6 +2773,15 @@ $functions = array(
'ajax' => 'true',
'capabilities' => 'moodle/contentbank:deleteanycontent',
],
+ 'core_contentbank_rename_content' => [
+ 'classname' => 'core_contentbank\external\rename_content',
+ 'methodname' => 'execute',
+ 'classpath' => '',
+ 'description' => 'Rename a content in the content bank.',
+ 'type' => 'write',
+ 'ajax' => 'true',
+ 'capabilities' => 'moodle/contentbank:manageowncontent',
+ ],
);
$services = array(
diff --git a/version.php b/version.php
index abaa9c3ed39..4beeb5db493 100644
--- a/version.php
+++ b/version.php
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2020050200.00; // YYYYMMDD = weekly release date of this DEV branch.
+$version = 2020050200.02; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '3.9dev+ (Build: 20200502)'; // Human-friendly version name