Skip to content

Commit

Permalink
add a button in post form to browse through repository
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed Apr 15, 2024
1 parent cf17932 commit 9588bbd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion classes/post_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ 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 +141,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 array(
'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

0 comments on commit 9588bbd

Please sign in to comment.