Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion classes/post_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public function definition() {
$modform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');

// The message.
$modform->addElement('editor', 'message', get_string('message', 'moodleoverflow'), null);
$modform->addElement('editor', 'message', get_string('message', 'moodleoverflow'), null,
self::editor_options($modcontext, (empty($post->id) ? null : $post->id)));
$modform->setType('message', PARAM_RAW);
$modform->addRule('message', get_string('required'), 'required', null, 'client');

Expand Down Expand Up @@ -141,6 +142,25 @@ public static function attachment_options($moodleoverflow) {
'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK,
];
}

/**
* Returns the options array to use in forum text editor
*
* @param context_module $context
* @param int $postid post id, use null when adding new post
* @return array
*/
public static function editor_options(context_module $context, $postid) {
global $COURSE, $PAGE, $CFG;
$maxbytes = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $COURSE->maxbytes);
return [
'maxfiles' => EDITOR_UNLIMITED_FILES,
'maxbytes' => $maxbytes,
'trusttext' => true,
'return_types' => FILE_INTERNAL | FILE_EXTERNAL,
'subdirs' => file_area_contains_subdirs($context, 'mod_forum', 'post', $postid),
];
}
}


Expand Down
5 changes: 4 additions & 1 deletion locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once(dirname(__FILE__) . '/lib.php');
require_once($CFG->libdir . '/portfoliolib.php');

/**
* Get all discussions in a moodleoverflow instance.
Expand Down Expand Up @@ -1449,7 +1451,8 @@ function moodleoverflow_print_post($post, $discussion, $moodleoverflow, $cm, $co
$mustachedata->withinreviewperiod = $reviewable;

// Prepare the post.
$mustachedata->postcontent = format_text($post->message, $post->messageformat, ['context' => $modulecontext]);
$options = (array) portfolio_format_text_options() + ['context' => $modulecontext];
$mustachedata->postcontent = format_text($post->message, $post->messageformat, $options);

// Load the attachments.
$mustachedata->attachments = get_attachments($post, $cm);
Expand Down
2 changes: 1 addition & 1 deletion templates/post.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<br>
{{/image}}
{{^image}}
<a href="{{filepath}}">
<a class="icon-size-6" href="{{filepath}}">
{{{icon}}}
</a>
<a href="{{filepath}}">
Expand Down