backporting MDL-8578 students can post and reply in news forums

This commit is contained in:
toyomoyo
2007-03-19 02:46:33 +00:00
parent 30739f6651
commit 3140dc600d
4 changed files with 51 additions and 7 deletions
+17 -5
View File
@@ -3043,7 +3043,13 @@ function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode=
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!has_capability('mod/forum:startdiscussion', $context)) {
if ($forum->type == 'news') {
$capname = 'mod/forum:addnews';
} else {
$capname = 'mod/forum:startdiscussion';
}
if (!has_capability($capname, $context)) {
return false;
}
@@ -3076,12 +3082,18 @@ function forum_user_can_post($forum, $user=NULL) {
error('Course Module ID was incorrect');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (isset($user)) {
$canreply = has_capability('mod/forum:replypost', $context, $user->id, false)
if ($forum->type == 'news') {
$capname = 'mod/forum:replynews';
} else {
$capname = 'mod/forum:replypost';
}
if (!empty($user)) {
$canreply = has_capability($capname, $context, $user->id, false)
&& !has_capability('moodle/legacy:guest', $context, $user->id, false);
} else {
$canreply = has_capability('mod/forum:replypost', $context, NULL, false)
$canreply = has_capability($capname, $context, NULL, false)
&& !has_capability('moodle/legacy:guest', $context, NULL, false);
}