mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
merged fix for 5551
This commit is contained in:
parent
9fd66c6642
commit
92998e94bd
2 changed files with 8 additions and 4 deletions
|
@ -2706,12 +2706,16 @@ function forum_user_has_posted($forumid,$did,$userid) {
|
|||
return record_exists('forum_posts','discussion',$did,'userid',$userid);
|
||||
}
|
||||
|
||||
function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode='') {
|
||||
function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode='', $edit=0) {
|
||||
// $forum is an object
|
||||
global $USER, $SESSION;
|
||||
|
||||
if ($forum->type == "eachuser") {
|
||||
return (! forum_user_has_posted_discussion($forum->id, $USER->id));
|
||||
if ($edit) { // fix for 5551, if 1 post per user, should allow edit, if poster is owner
|
||||
$post = get_record('forum_posts','id',$edit);
|
||||
return ($post->userid == $USER->id); // editting your own post?
|
||||
} else {
|
||||
return (! forum_user_has_posted_discussion($forum->id, $USER->id));
|
||||
}
|
||||
} else if ($forum->type == 'qanda') {
|
||||
return isteacher($forum->course);
|
||||
} else if ($forum->type == "teacher") {
|
||||
|
|
|
@ -748,7 +748,7 @@
|
|||
if (!empty($parent) && !forum_user_can_see_post($forum,$discussion,$post)) {
|
||||
error("You cannot reply to this post");
|
||||
}
|
||||
if (empty($parent) && !forum_user_can_post_discussion($forum)) {
|
||||
if (empty($parent) && !forum_user_can_post_discussion($forum, false, '', $edit)) {
|
||||
error("You cannot start a new discussion in this forum");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue