Compare commits
12 Commits
v3.7.0-rc2
..
v3.7.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 89457b26d1 | |||
| c0f098cd57 | |||
| a67061dc4a | |||
| 117e4bd40d | |||
| 743d66bfbd | |||
| f6548dfbae | |||
| 88f6ca6cbe | |||
| f2eb04c170 | |||
| 429649efbf | |||
| b6c3b130c4 | |||
| fa53cd8b98 | |||
| 136d8c97de |
+1
-1
@@ -207,7 +207,7 @@ before_script:
|
||||
# We need the official upstream for comparison
|
||||
git remote add upstream https://github.com/moodle/moodle.git;
|
||||
|
||||
git fetch upstream master;
|
||||
git fetch upstream MOODLE_37_STABLE;
|
||||
export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
|
||||
export GIT_COMMIT="$TRAVIS_COMMIT";
|
||||
export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Direktori admin';
|
||||
$string['availablelangs'] = 'Paket bahasa yang tersedia';
|
||||
$string['chooselanguagehead'] = 'Pilih bahasa';
|
||||
$string['chooselanguagesub'] = 'Silakan pilih bahasa untuk instalasi. Bahasa ini juga akan digunakan sebagai bahasa default untuk situs, meskipun mungkin akan diubah kemudian.';
|
||||
$string['clialreadyconfigured'] = 'Berkas konfigurasi config.php sudah ada. Silakan gunakan admin /cli/install_database.php untuk menginstal Moodle untuk situs ini.';
|
||||
$string['clialreadyinstalled'] = 'File konfigurasi config.php sudah ada. Silakan gunakan admin/cli/install_database.php untuk menginstal Moodle untuk situs ini.';
|
||||
$string['databasehost'] = 'Host basis data';
|
||||
$string['databasename'] = 'Nama basis data';
|
||||
$string['databasetypehead'] = 'Pilih pengandar basis data';
|
||||
$string['dataroot'] = 'Direktori data';
|
||||
$string['dbprefix'] = 'Prefiks tabel';
|
||||
$string['installation'] = 'Instalasi';
|
||||
$string['pathssubadmindir'] = 'Beberapa hosting menggunakan / admin sebagai URL khusus untuk Anda mengakses panel kontrol atau sesuatu. Sayangnya ini bertentangan dengan lokasi standar untuk halaman admin Moodle. Anda dapat memperbaikinya dengan mengganti nama direktori admin di instalasi Anda, dan meletakkan nama baru itu di sini. Misalnya: <em> moodleadmin </em>. Ini akan memperbaiki tautan admin di Moodle.';
|
||||
$string['pathssubdataroot'] = '<p> Direktori tempat Moodle akan menyimpan semua konten file yang diunggah oleh pengguna. </p> <p> Direktori ini harus dapat dibaca dan ditulis oleh pengguna server web (biasanya \'www-data\', \'nobody\', atau \' apache \'). </p> <p> Itu tidak boleh diakses secara langsung melalui web. </p> <p> Jika direktori saat ini tidak ada, proses instalasi akan berusaha membuatnya. </p>';
|
||||
$string['pathssubdirroot'] = '<p> Jalur lengkap ke direktori yang berisi kode Moodle. </p>';
|
||||
$string['pathssubwwwroot'] = '<p> Alamat lengkap tempat Moodle akan diakses yaitu alamat yang akan dimasukkan pengguna ke bilah alamat peramban mereka untuk mengakses Moodle. </p> <p> Tidak mungkin mengakses Moodle menggunakan banyak alamat. Jika situs Anda dapat diakses melalui beberapa alamat, maka pilih yang termudah dan buat pengalihan permanen untuk masing-masing alamat lainnya. </p> <p> Jika situs Anda dapat diakses baik dari Internet, dan dari jaringan internal (kadang-kadang disebut Intranet), lalu gunakan alamat publik di sini. </p> <p> Jika alamat saat ini tidak benar, silakan ubah URL di bilah alamat peramban Anda dan mulai kembali instalasi. </p>';
|
||||
$string['pathsunsecuredataroot'] = 'Lokasi dataroot tidak aman';
|
||||
$string['pathswrongadmindir'] = 'Direktori admin tidak ada';
|
||||
$string['phpextension'] = 'Ekstensi PHP {$a}';
|
||||
$string['phpversion'] = 'Versi PHP';
|
||||
$string['phpversionhelp'] = '<p> Moodle membutuhkan versi PHP setidaknya 5.6.5 atau 7.1 (7.0.x memiliki beberapa keterbatasan mesin). </p> <p> Anda saat ini menjalankan versi {$a}. </p> <p> Anda harus meningkatkan versi PHP atau pindah ke host dengan versi PHP yang lebih baru. </p>';
|
||||
$string['welcomep10'] = '{$a->installername} ({$a->installerversion})';
|
||||
$string['welcomep20'] = 'Anda melihat halaman ini karena Anda telah berhasil memasang dan meluncurkan paket <strong> {$a->packname} {$a->packversion}</strong> di komputer Anda. Selamat!';
|
||||
$string['welcomep30'] = 'Rilis <strong> {$a->installername}</strong> ini mencakup aplikasi untuk menciptakan lingkungan tempat <strong> Moodle </strong> yang akan digunakan, yaitu:';
|
||||
$string['welcomep40'] = 'Paket juga termasuk <strong>Moodle {$a->moodlerelease} ({$a->moodleversion})</strong>.';
|
||||
$string['welcomep50'] = 'Penggunaan semua aplikasi dalam paket ini diatur oleh lisensi masing-masing. Paket <strong>{$a->installername}</strong> lengkap adalah <a href="http://www.opensource.org/docs/definition_plain.html"> sumber terbuka </a> dan didistribusikan di bawah lisensi <a href="http://www.gnu.org/copyleft/gpl.html"> GPL </a>.';
|
||||
$string['welcomep60'] = 'Halaman-halaman berikut akan menuntun Anda melalui beberapa langkah yang mudah diikuti untuk mengonfigurasi dan menyiapkan <strong> Moodle </strong> di komputer Anda. Anda dapat menerima pengaturan bawaan atau, secara opsional, mengubahnya sesuai dengan kebutuhan Anda.';
|
||||
$string['welcomep70'] = 'Klik tombol "Selanjutnya" di bawah untuk melanjutkan dengan penyiapan <strong> Moodle </strong>.';
|
||||
$string['wwwroot'] = 'Alamat web';
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['next'] = 'Ijayo';
|
||||
$string['previous'] = 'Iliyopita';
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors"],function(a,b,c,d,e){var f={THREADED:2,NESTED:3,FLAT_OLDEST_FIRST:1,FLAT_NEWEST_FIRST:-1},g=function(a){var b=a.find(e.post.inpageSubmitBtnText),c=a.find(e.post.loadingIconContainer),d=a.outerWidth();a.css("width",d),b.addClass("hidden"),c.removeClass("hidden")},h=function(a){var b=a.find(e.post.inpageSubmitBtnText),c=a.find(e.post.loadingIconContainer);a.css("width",""),b.removeClass("hidden"),c.addClass("hidden")},i=function(i){i.on("click",e.post.inpageSubmitBtn,function(j){j.preventDefault();var k,l=a(j.currentTarget),m=l.parent().find(e.post.inpageReplyButton),n=l.parents(e.post.inpageReplyForm).get(0),o=n.elements.post.value.trim(),p=n.elements.reply.value,q=n.elements.subject.value,r=l.parents(e.post.forumContent),s=void 0!=n.elements.privatereply&&n.elements.privatereply.checked,t=parseInt(i.find(e.post.modeSelect).get(0).value);o.length&&(g(l),m.prop("disabled",!0),d.addDiscussionPost(p,q,o,s).then(function(a){var b=a.messages.reduce(function(a,b){return"success"==b.type&&(a+="<p>"+b.message+"</p>"),a},"");return c.addNotification({message:b,type:"success"}),a}).then(function(a){n.reset();var c=a.post;switch(k=c.id,t){case f.THREADED:return b.render("mod_forum/forum_discussion_threaded_post",c);case f.NESTED:return b.render("mod_forum/forum_discussion_nested_post",c);default:return b.render("mod_forum/forum_discussion_post",c)}}).then(function(a,c){var d;return t!=f.FLAT_OLDEST_FIRST&&t!=f.FLAT_NEWEST_FIRST||(d=r.parents(e.post.repliesContainer).children().get(0)),void 0==d&&(d=r.siblings(e.post.repliesContainer).children().get(0)),t==f.FLAT_NEWEST_FIRST?b.prependNodeContents(d,a,c):b.appendNodeContents(d,a,c)}).then(function(){return h(l),m.prop("disabled",!1),r.find(e.post.inpageReplyContent).hide()}).then(function(){location.href="#p"+k})["catch"](function(a){return h(l),m.prop("disabled",!1),c.exception(a)}))})};return{init:function(a){i(a)}}});
|
||||
define(["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors"],function(a,b,c,d,e){var f={THREADED:2,NESTED:3,FLAT_OLDEST_FIRST:1,FLAT_NEWEST_FIRST:-1},g={MOODLE:0},h=function(a){var b=a.find(e.post.inpageSubmitBtnText),c=a.find(e.post.loadingIconContainer),d=a.outerWidth();a.css("width",d),b.addClass("hidden"),c.removeClass("hidden")},i=function(a){var b=a.find(e.post.inpageSubmitBtnText),c=a.find(e.post.loadingIconContainer);a.css("width",""),b.removeClass("hidden"),c.addClass("hidden")},j=function(j){j.on("click",e.post.inpageSubmitBtn,function(k){k.preventDefault();var l,m=a(k.currentTarget),n=m.parent().find(e.post.inpageReplyButton),o=m.parents(e.post.inpageReplyForm).get(0),p=o.elements.post.value.trim(),q=g.MOODLE,r=!0,s=o.elements.reply.value,t=o.elements.subject.value,u=m.parents(e.post.forumContent),v=void 0!=o.elements.privatereply&&o.elements.privatereply.checked,w=parseInt(j.find(e.post.modeSelect).get(0).value);p.length&&(h(m),n.prop("disabled",!0),d.addDiscussionPost(s,t,p,q,v,r).then(function(a){var b=a.messages.reduce(function(a,b){return"success"==b.type&&(a+="<p>"+b.message+"</p>"),a},"");return c.addNotification({message:b,type:"success"}),a}).then(function(a){o.reset();var c=a.post;switch(l=c.id,w){case f.THREADED:return b.render("mod_forum/forum_discussion_threaded_post",c);case f.NESTED:return b.render("mod_forum/forum_discussion_nested_post",c);default:return b.render("mod_forum/forum_discussion_post",c)}}).then(function(a,c){var d;return w!=f.FLAT_OLDEST_FIRST&&w!=f.FLAT_NEWEST_FIRST||(d=u.parents(e.post.repliesContainer).children().get(0)),void 0==d&&(d=u.siblings(e.post.repliesContainer).children().get(0)),w==f.FLAT_NEWEST_FIRST?b.prependNodeContents(d,a,c):b.appendNodeContents(d,a,c)}).then(function(){return i(m),n.prop("disabled",!1),u.find(e.post.inpageReplyContent).hide()}).then(function(){location.href="#p"+l})["catch"](function(a){return i(m),n.prop("disabled",!1),c.exception(a)}))})};return{init:function(a){j(a)},CONTENT_FORMATS:g}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(e){e.on("click",d.post.inpageReplyLink,function(e){if(e.preventDefault(),window.location.hash){var f=window.location.href.split("#")[0];history.pushState({},document.title,f)}var g=a(e.currentTarget).parents(d.post.forumCoreContent),h=g.find(d.post.forumSubject),i=a(e.currentTarget).parents(d.post.forumContent),j={postid:a(i).data("post-id"),reply_url:a(e.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:h.html(),canreplyprivately:a(e.currentTarget).data("can-reply-privately")};if(i.find(d.post.inpageReplyContent).length){var k=i.find(d.post.inpageReplyContent);k.slideToggle(300),k.is(":visible")&&k.find("textarea").focus()}else b.render("mod_forum/inpage_reply",j).then(function(a,c){return b.appendNodeContents(g,a,c)}).then(function(){return i.find(d.post.inpageReplyContent).slideToggle(300).find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}});
|
||||
define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(f){f.on("click",d.post.inpageReplyLink,function(f){if(f.preventDefault(),window.location.hash){var g=window.location.href.split("#")[0];history.pushState({},document.title,g)}var h=a(f.currentTarget).parents(d.post.forumCoreContent),i=h.find(d.post.forumSubject),j=a(f.currentTarget).parents(d.post.forumContent),k={postid:a(j).data("post-id"),reply_url:a(f.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:i.html(),canreplyprivately:a(f.currentTarget).data("can-reply-privately"),postformat:e.CONTENT_FORMATS.MOODLE};if(j.find(d.post.inpageReplyContent).length){var l=j.find(d.post.inpageReplyContent);l.slideToggle(300),l.is(":visible")&&l.find("textarea").focus()}else b.render("mod_forum/inpage_reply",k).then(function(a,c){return b.appendNodeContents(h,a,c)}).then(function(){return j.find(d.post.inpageReplyContent).slideToggle(300).find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["core/ajax"],function(a){var b=function(b,c,d){var e={methodname:"mod_forum_set_subscription_state",args:{forumid:b,discussionid:c,targetstate:d}};return a.call([e])[0]},c=function(b,c,d,e){var f={methodname:"mod_forum_add_discussion_post",args:{postid:b,message:d,subject:c,options:[{name:"private",value:e}]}};return a.call([f])[0]},d=function(b,c,d){var e={methodname:"mod_forum_toggle_favourite_state",args:{discussionid:c,targetstate:d}};return a.call([e])[0]},e=function(b,c,d){var e={methodname:"mod_forum_set_lock_state",args:{forumid:b,discussionid:c,targetstate:d}};return a.call([e])[0]},f=function(b,c,d){var e={methodname:"mod_forum_set_pin_state",args:{discussionid:c,targetstate:d}};return a.call([e])[0]};return{setDiscussionSubscriptionState:b,addDiscussionPost:c,setDiscussionLockState:e,setFavouriteDiscussionState:d,setPinDiscussionState:f}});
|
||||
define(["core/ajax"],function(a){var b=function(b,c,d){var e={methodname:"mod_forum_set_subscription_state",args:{forumid:b,discussionid:c,targetstate:d}};return a.call([e])[0]},c=function(b,c,d,e,f,g){var h={methodname:"mod_forum_add_discussion_post",args:{postid:b,message:d,messageformat:e,subject:c,options:[{name:"private",value:f},{name:"topreferredformat",value:g}]}};return a.call([h])[0]},d=function(b,c,d){var e={methodname:"mod_forum_toggle_favourite_state",args:{discussionid:c,targetstate:d}};return a.call([e])[0]},e=function(b,c,d){var e={methodname:"mod_forum_set_lock_state",args:{forumid:b,discussionid:c,targetstate:d}};return a.call([e])[0]},f=function(b,c,d){var e={methodname:"mod_forum_set_pin_state",args:{discussionid:c,targetstate:d}};return a.call([e])[0]};return{setDiscussionSubscriptionState:b,addDiscussionPost:c,setDiscussionLockState:e,setFavouriteDiscussionState:d,setPinDiscussionState:f}});
|
||||
@@ -42,6 +42,13 @@ define([
|
||||
FLAT_NEWEST_FIRST: -1
|
||||
};
|
||||
|
||||
/**
|
||||
* Moodle formats taken from the FORMAT_* constants declared in lib/weblib.php.
|
||||
* @type {Object}
|
||||
*/
|
||||
var CONTENT_FORMATS = {
|
||||
MOODLE: 0
|
||||
};
|
||||
/**
|
||||
* Show the loading icon for the submit button.
|
||||
*
|
||||
@@ -83,6 +90,11 @@ define([
|
||||
var allButtons = submitButton.parent().find(Selectors.post.inpageReplyButton);
|
||||
var form = submitButton.parents(Selectors.post.inpageReplyForm).get(0);
|
||||
var message = form.elements.post.value.trim();
|
||||
// For now, we consider the inline reply post written using the FORMAT_MOODLE (because a textarea is displayed).
|
||||
// In the future, other formats should be supported, letting users to use their preferred editor and format.
|
||||
var messageformat = CONTENT_FORMATS.MOODLE;
|
||||
// The message post will be converted from messageformat to FORMAT_HTML.
|
||||
var topreferredformat = true;
|
||||
var postid = form.elements.reply.value;
|
||||
var subject = form.elements.subject.value;
|
||||
var currentRoot = submitButton.parents(Selectors.post.forumContent);
|
||||
@@ -94,7 +106,7 @@ define([
|
||||
showSubmitButtonLoadingIcon(submitButton);
|
||||
allButtons.prop('disabled', true);
|
||||
|
||||
Repository.addDiscussionPost(postid, subject, message, isprivatereply)
|
||||
Repository.addDiscussionPost(postid, subject, message, messageformat, isprivatereply, topreferredformat)
|
||||
.then(function(context) {
|
||||
var message = context.messages.reduce(function(carry, message) {
|
||||
if (message.type == 'success') {
|
||||
@@ -161,6 +173,7 @@ define([
|
||||
return {
|
||||
init: function(root) {
|
||||
registerEventListeners(root);
|
||||
}
|
||||
},
|
||||
CONTENT_FORMATS: CONTENT_FORMATS
|
||||
};
|
||||
});
|
||||
|
||||
@@ -60,7 +60,8 @@ define([
|
||||
"reply_url": $(e.currentTarget).attr('href'),
|
||||
sesskey: M.cfg.sesskey,
|
||||
parentsubject: currentSubject.html(),
|
||||
canreplyprivately: $(e.currentTarget).data('can-reply-privately')
|
||||
canreplyprivately: $(e.currentTarget).data('can-reply-privately'),
|
||||
postformat: InPageReply.CONTENT_FORMATS.MOODLE
|
||||
};
|
||||
|
||||
if (!currentRoot.find(Selectors.post.inpageReplyContent).length) {
|
||||
|
||||
@@ -43,16 +43,20 @@ define(['core/ajax'], function(Ajax) {
|
||||
return Ajax.call([request])[0];
|
||||
};
|
||||
|
||||
var addDiscussionPost = function(postid, subject, message, isprivatereply) {
|
||||
var addDiscussionPost = function(postid, subject, message, messageformat, isprivatereply, topreferredformat) {
|
||||
var request = {
|
||||
methodname: 'mod_forum_add_discussion_post',
|
||||
args: {
|
||||
postid: postid,
|
||||
message: message,
|
||||
messageformat: messageformat,
|
||||
subject: subject,
|
||||
options: [{
|
||||
name: "private",
|
||||
value: isprivatereply,
|
||||
}, {
|
||||
name: "topreferredformat",
|
||||
value: topreferredformat,
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1178,7 +1178,7 @@ class mod_forum_external extends external_api {
|
||||
'postid' => new external_value(PARAM_INT, 'the post id we are going to reply to
|
||||
(can be the initial discussion post'),
|
||||
'subject' => new external_value(PARAM_TEXT, 'new post subject'),
|
||||
'message' => new external_value(PARAM_RAW, 'new post message (only html format allowed)'),
|
||||
'message' => new external_value(PARAM_RAW, 'new post message (html assumed if messageformat is not provided)'),
|
||||
'options' => new external_multiple_structure (
|
||||
new external_single_structure(
|
||||
array(
|
||||
@@ -1188,12 +1188,14 @@ class mod_forum_external extends external_api {
|
||||
private (bool); make this reply private to the author of the parent post, default to false.
|
||||
inlineattachmentsid (int); the draft file area id for inline attachments
|
||||
attachmentsid (int); the draft file area id for attachments
|
||||
topreferredformat (bool); convert the message & messageformat to FORMAT_HTML, defaults to false
|
||||
'),
|
||||
'value' => new external_value(PARAM_RAW, 'the value of the option,
|
||||
this param is validated in the external function.'
|
||||
)
|
||||
)
|
||||
), 'Options', VALUE_DEFAULT, array())
|
||||
), 'Options', VALUE_DEFAULT, array()),
|
||||
'messageformat' => new external_format_value('message', VALUE_DEFAULT)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1203,13 +1205,14 @@ class mod_forum_external extends external_api {
|
||||
*
|
||||
* @param int $postid the post id we are going to reply to
|
||||
* @param string $subject new post subject
|
||||
* @param string $message new post message (only html format allowed)
|
||||
* @param string $message new post message (html assumed if messageformat is not provided)
|
||||
* @param array $options optional settings
|
||||
* @param string $messageformat The format of the message, defaults to FORMAT_HTML for BC
|
||||
* @return array of warnings and the new post id
|
||||
* @since Moodle 3.0
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function add_discussion_post($postid, $subject, $message, $options = array()) {
|
||||
public static function add_discussion_post($postid, $subject, $message, $options = array(), $messageformat = FORMAT_HTML) {
|
||||
global $CFG, $USER;
|
||||
require_once($CFG->dirroot . "/mod/forum/lib.php");
|
||||
|
||||
@@ -1228,7 +1231,8 @@ class mod_forum_external extends external_api {
|
||||
'postid' => $postid,
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'options' => $options
|
||||
'options' => $options,
|
||||
'messageformat' => $messageformat,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1258,7 +1262,8 @@ class mod_forum_external extends external_api {
|
||||
'discussionsubscribe' => true,
|
||||
'private' => false,
|
||||
'inlineattachmentsid' => 0,
|
||||
'attachmentsid' => null
|
||||
'attachmentsid' => null,
|
||||
'topreferredformat' => false
|
||||
);
|
||||
foreach ($params['options'] as $option) {
|
||||
$name = trim($option['name']);
|
||||
@@ -1279,6 +1284,9 @@ class mod_forum_external extends external_api {
|
||||
$value = 0;
|
||||
}
|
||||
break;
|
||||
case 'topreferredformat':
|
||||
$value = clean_param($option['value'], PARAM_BOOL);
|
||||
break;
|
||||
default:
|
||||
throw new moodle_exception('errorinvalidparam', 'webservice', '', $name);
|
||||
}
|
||||
@@ -1292,13 +1300,24 @@ class mod_forum_external extends external_api {
|
||||
$thresholdwarning = forum_check_throttling($forumrecord, $cm);
|
||||
forum_check_blocking_threshold($thresholdwarning);
|
||||
|
||||
// If we want to force a conversion to the preferred format, let's do it now.
|
||||
if ($options['topreferredformat']) {
|
||||
// We always are going to honor the preferred format. We are creating a new post.
|
||||
$preferredformat = editors_get_preferred_format();
|
||||
// If the post is not HTML and the preferred format is HTML, convert to it.
|
||||
if ($params['messageformat'] != FORMAT_HTML and $preferredformat == FORMAT_HTML) {
|
||||
$params['message'] = format_text($params['message'], $params['messageformat'], ['context' => $context]);
|
||||
}
|
||||
$params['messageformat'] = $preferredformat;
|
||||
}
|
||||
|
||||
// Create the post.
|
||||
$post = new stdClass();
|
||||
$post->discussion = $discussion->get_id();
|
||||
$post->parent = $parent->id;
|
||||
$post->subject = $params['subject'];
|
||||
$post->message = $params['message'];
|
||||
$post->messageformat = FORMAT_HTML; // Force formatting for now.
|
||||
$post->messageformat = $params['messageformat'];
|
||||
$post->messagetrust = trusttext_trusted($context);
|
||||
$post->itemid = $options['inlineattachmentsid'];
|
||||
$post->attachments = $options['attachmentsid'];
|
||||
|
||||
+15
-1
@@ -36,6 +36,7 @@ $confirm = optional_param('confirm', 0, PARAM_INT);
|
||||
$groupid = optional_param('groupid', null, PARAM_INT);
|
||||
$subject = optional_param('subject', '', PARAM_TEXT);
|
||||
$prefilledpost = optional_param('post', '', PARAM_TEXT);
|
||||
$prefilledpostformat = optional_param('postformat', FORMAT_MOODLE, PARAM_INT);
|
||||
$prefilledprivatereply = optional_param('privatereply', false, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/mod/forum/post.php', array(
|
||||
@@ -251,6 +252,17 @@ if (!empty($forum)) {
|
||||
print_error('cannotreplytoprivatereply', 'forum');
|
||||
}
|
||||
|
||||
// We always are going to honor the preferred format. We are creating a new post.
|
||||
$preferredformat = editors_get_preferred_format();
|
||||
|
||||
// Only if there are prefilled contents coming.
|
||||
if (!empty($prefilledpost)) {
|
||||
// If the prefilled post is not HTML and the preferred format is HTML, convert to it.
|
||||
if ($prefilledpostformat != FORMAT_HTML and $preferredformat == FORMAT_HTML) {
|
||||
$prefilledpost = format_text($prefilledpost, $prefilledpostformat, ['context' => $modcontext]);
|
||||
}
|
||||
}
|
||||
|
||||
// Load up the $post variable.
|
||||
$post = new stdClass();
|
||||
$post->course = $course->id;
|
||||
@@ -261,6 +273,7 @@ if (!empty($forum)) {
|
||||
$post->userid = $USER->id;
|
||||
$post->parentpostauthor = $parent->userid;
|
||||
$post->message = $prefilledpost;
|
||||
$post->messageformat = $preferredformat;
|
||||
$post->isprivatereply = $prefilledprivatereply;
|
||||
$canreplyprivately = $capabilitymanager->can_reply_privately_to_post($USER, $parententity);
|
||||
|
||||
@@ -737,7 +750,8 @@ $mformpost->set_data(
|
||||
'subject' => $post->subject,
|
||||
'message' => array(
|
||||
'text' => $currenttext,
|
||||
'format' => empty($post->messageformat) ? editors_get_preferred_format() : $post->messageformat,
|
||||
'format' => !isset($post->messageformat) || !is_numeric($post->messageformat) ?
|
||||
editors_get_preferred_format() : $post->messageformat,
|
||||
'itemid' => $draftideditor
|
||||
),
|
||||
'discussionsubscribe' => $discussionsubscribe,
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<div class="row pb-1">
|
||||
<span>
|
||||
<textarea rows="5" name="post" title="post" class="w-100" placeholder="{{#str}} replyplaceholder, forum {{/str}}"></textarea>
|
||||
<input type="hidden" name="postformat" value="{{postformat}}"/>
|
||||
</span>
|
||||
<input type="hidden" name="subject" value="{{#str}} inpagereplysubject, forum, {{parentsubject}} {{/str}}"/>
|
||||
<input type="hidden" name="reply" value="{{postid}}"/>
|
||||
|
||||
@@ -1581,11 +1581,38 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
if ($createdpost['postid'] == $thispost['id']) {
|
||||
$this->assertEquals('some subject', $thispost['subject']);
|
||||
$this->assertEquals('some text here...', $thispost['message']);
|
||||
$this->assertEquals(FORMAT_HTML, $thispost['messageformat']); // This is the default if format was not specified.
|
||||
$tested = true;
|
||||
}
|
||||
}
|
||||
$this->assertTrue($tested);
|
||||
|
||||
// Let's simulate a call with any other format, it should be stored that way.
|
||||
global $DB; // Yes, we are going to use DB facilities too, because cannot rely on other functions for checking
|
||||
// the format. They eat it completely (going back to FORMAT_HTML. So we only can trust DB for further
|
||||
// processing.
|
||||
$formats = [FORMAT_PLAIN, FORMAT_MOODLE, FORMAT_MARKDOWN, FORMAT_HTML];
|
||||
$options = [];
|
||||
foreach ($formats as $format) {
|
||||
$createdpost = mod_forum_external::add_discussion_post($discussion->firstpost,
|
||||
'with some format', 'some formatted here...', $options, $format);
|
||||
$createdpost = external_api::clean_returnvalue(mod_forum_external::add_discussion_post_returns(), $createdpost);
|
||||
$dbformat = $DB->get_field('forum_posts', 'messageformat', ['id' => $createdpost['postid']]);
|
||||
$this->assertEquals($format, $dbformat);
|
||||
}
|
||||
|
||||
// Now let's try the 'topreferredformat' option. That should end with the content
|
||||
// transformed and the format being FORMAT_HTML (when, like in this case, user preferred
|
||||
// format is HTML, inferred from editor in preferences).
|
||||
$options = [['name' => 'topreferredformat', 'value' => true]];
|
||||
$createdpost = mod_forum_external::add_discussion_post($discussion->firstpost,
|
||||
'interesting subject', 'with some https://example.com link', $options, FORMAT_MOODLE);
|
||||
$createdpost = external_api::clean_returnvalue(mod_forum_external::add_discussion_post_returns(), $createdpost);
|
||||
$dbpost = $DB->get_record('forum_posts', ['id' => $createdpost['postid']]);
|
||||
// Format HTML and content converted, we should get.
|
||||
$this->assertEquals(FORMAT_HTML, $dbpost->messageformat);
|
||||
$this->assertEquals('<div class="text_to_html">with some https://example.com link</div>', $dbpost->message);
|
||||
|
||||
// Test inline and regular attachment in post
|
||||
// Create a file in a draft area for inline attachments.
|
||||
$draftidinlineattach = file_get_unused_draft_itemid();
|
||||
@@ -1658,7 +1685,6 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('nopostforum', $e->errorcode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -14,6 +14,7 @@ information provided here is intended especially for developers.
|
||||
* New external function mod_forum_external::get_forum_discussions returns a list of forum discussions optionally sorted and paginated.
|
||||
* External function mod_forum_external::get_forum_discussions_paginated has been deprecated.
|
||||
Use mod_forum_external::get_forum_discussions instead.
|
||||
* External function mod_forum_external::add_discussion_post() has a new 'messageformat' param to be able to handle other formats different from FORMAT_HTML (that continues being the default one). Also a new 'topreferredformat' option enables the automatic conversion between any format and the preferred format (given the editor preference) before contents are saved.
|
||||
|
||||
=== 3.6 ===
|
||||
|
||||
|
||||
+3
-3
@@ -29,11 +29,11 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2019051600.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2019052000.00; // 20190520 = branching date YYYYMMDD - do not modify!
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
$release = '3.7rc2 (Build: 20190516)'; // Human-friendly version name
|
||||
$release = '3.7 (Build: 20190520)'; // Human-friendly version name
|
||||
|
||||
$branch = '37'; // This version's branch.
|
||||
$maturity = MATURITY_RC; // This version's maturity level.
|
||||
$maturity = MATURITY_STABLE; // This version's maturity level.
|
||||
|
||||
Reference in New Issue
Block a user