Skip to content

Commit

Permalink
MDL-74321 mod_forum: Pass course module to forum_check_throttling()
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Mar 28, 2022
1 parent 2c2686d commit 9d827a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions mod/forum/classes/local/managers/capability.php
Expand Up @@ -120,7 +120,8 @@ public function can_create_discussions(stdClass $user, int $groupid = null) : bo
}

// If the user reaches the number of posts equal to warning/blocking setting then return the value of canpost in $warningobj.
if ($warningobj = forum_check_throttling($this->forumrecord)) {
$cmrecord = $this->forum->get_course_module_record();
if ($warningobj = forum_check_throttling($this->forumrecord, $cmrecord)) {
return $warningobj->canpost;
}

Expand Down Expand Up @@ -328,7 +329,7 @@ public function can_post_in_discussion(stdClass $user, discussion_entity $discus

$status = forum_user_can_post($forumrecord, $discussionrecord, $user, $coursemodule, $course, $context);
// If the user reaches the number of posts equal to warning/blocking setting then logically and canpost value with $status.
if ($warningobj = forum_check_throttling($forumrecord)) {
if ($warningobj = forum_check_throttling($forumrecord, $coursemodule)) {
return $status && $warningobj->canpost;
}
return $status;
Expand Down
3 changes: 2 additions & 1 deletion mod/forum/classes/local/renderers/discussion.php
Expand Up @@ -235,7 +235,8 @@ public function render(
}

$exporteddiscussion['throttlingwarningmsg'] = '';
if (($warningobj = forum_check_throttling($this->forumrecord)) && $warningobj->canpost) {
$cmrecord = $this->forum->get_course_module_record();
if (($warningobj = forum_check_throttling($this->forumrecord, $cmrecord)) && $warningobj->canpost) {
$throttlewarnnotification = (new notification(
get_string($warningobj->errorcode, $warningobj->module, $warningobj->additional)
))->set_show_closebutton();
Expand Down

0 comments on commit 9d827a2

Please sign in to comment.