merged fix for 5551

This commit is contained in:
toyomoyo 2006-05-22 02:39:14 +00:00
parent 9fd66c6642
commit 92998e94bd
2 changed files with 8 additions and 4 deletions

View file

@ -2706,12 +2706,16 @@ function forum_user_has_posted($forumid,$did,$userid) {
return record_exists('forum_posts','discussion',$did,'userid',$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 // $forum is an object
global $USER, $SESSION; global $USER, $SESSION;
if ($forum->type == "eachuser") { 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') { } else if ($forum->type == 'qanda') {
return isteacher($forum->course); return isteacher($forum->course);
} else if ($forum->type == "teacher") { } else if ($forum->type == "teacher") {

View file

@ -748,7 +748,7 @@
if (!empty($parent) && !forum_user_can_see_post($forum,$discussion,$post)) { if (!empty($parent) && !forum_user_can_see_post($forum,$discussion,$post)) {
error("You cannot reply to this 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"); error("You cannot start a new discussion in this forum");
} }