@@ -58,7 +58,8 @@ public function definition() {
58
58
$ modform ->addRule ('subject ' , get_string ('maximumchars ' , '' , 255 ), 'maxlength ' , 255 , 'client ' );
59
59
60
60
// The message.
61
- $ modform ->addElement ('editor ' , 'message ' , get_string ('message ' , 'moodleoverflow ' ), null );
61
+ $ modform ->addElement ('editor ' , 'message ' , get_string ('message ' , 'moodleoverflow ' ), null ,
62
+ self ::editor_options ($ modcontext , (empty ($ post ->id ) ? null : $ post ->id )));
62
63
$ modform ->setType ('message ' , PARAM_RAW );
63
64
$ modform ->addRule ('message ' , get_string ('required ' ), 'required ' , null , 'client ' );
64
65
@@ -141,6 +142,25 @@ public static function attachment_options($moodleoverflow) {
141
142
'return_types ' => FILE_INTERNAL | FILE_CONTROLLED_LINK ,
142
143
];
143
144
}
145
+
146
+ /**
147
+ * Returns the options array to use in forum text editor
148
+ *
149
+ * @param context_module $context
150
+ * @param int $postid post id, use null when adding new post
151
+ * @return array
152
+ */
153
+ public static function editor_options (context_module $ context , $ postid ) {
154
+ global $ COURSE , $ PAGE , $ CFG ;
155
+ $ maxbytes = get_user_max_upload_file_size ($ PAGE ->context , $ CFG ->maxbytes , $ COURSE ->maxbytes );
156
+ return array (
157
+ 'maxfiles ' => EDITOR_UNLIMITED_FILES ,
158
+ 'maxbytes ' => $ maxbytes ,
159
+ 'trusttext ' => true ,
160
+ 'return_types ' => FILE_INTERNAL | FILE_EXTERNAL ,
161
+ 'subdirs ' => file_area_contains_subdirs ($ context , 'mod_forum ' , 'post ' , $ postid )
162
+ );
163
+ }
144
164
}
145
165
146
166
0 commit comments