MDL-58259 mod_forum: Check if attachments allowed
If the current user is not allowed to submit attachments with a post, and attachments are incldued, they are now dropped.
This commit is contained in:
committed by
Jun Pataleta
parent
787573a007
commit
02660c64ff
@@ -824,6 +824,13 @@ class mod_forum_external extends external_api {
|
||||
throw new moodle_exception('nopostforum', 'forum');
|
||||
}
|
||||
|
||||
if (!empty($options['attachmentsid'])) {
|
||||
// Ensure that the user has permissions to create attachments.
|
||||
if (!has_capability('mod/forum:createattachment', $context)) {
|
||||
$options['attachmentsid'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$thresholdwarning = forum_check_throttling($forum, $cm);
|
||||
forum_check_blocking_threshold($thresholdwarning);
|
||||
|
||||
@@ -1004,6 +1011,13 @@ class mod_forum_external extends external_api {
|
||||
throw new moodle_exception('cannotcreatediscussion', 'forum');
|
||||
}
|
||||
|
||||
if (!empty($options['attachmentsid'])) {
|
||||
// Ensure that the user has permissions to create attachments.
|
||||
if (!has_capability('mod/forum:createattachment', $context)) {
|
||||
$options['attachmentsid'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$thresholdwarning = forum_check_throttling($forum, $cm);
|
||||
forum_check_blocking_threshold($thresholdwarning);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user