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
+26
View File
@@ -85,6 +85,32 @@ $mod_forum_capabilities = array(
)
),
'mod/forum:addnews' => array(
'riskbitmask' => RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
),
'mod/forum:replynews' => array(
'riskbitmask' => RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
),
'mod/forum:viewrating' => array(
'captype' => 'read',
+7 -1
View File
@@ -165,8 +165,14 @@
/// If so, make sure the current person is allowed to see this discussion
/// Also, if we know they should be able to reply, then explicitly set $canreply
if ($forum->type == 'news') {
$capname = 'mod/forum:replynews';
} else {
$capname = 'mod/forum:replypost';
}
$groupmode = groupmode($course, $cm);
if ($canreply = has_capability('mod/forum:replypost', $modcontext)) { /// Check capability first, if not allowed, no point checking further
if ($canreply = has_capability($capname, $modcontext)) { /// Check capability first, if not allowed, no point checking further
// now check groups just in case user is not a member of group in which he can post
+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);
}
+1 -1
View File
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2006092002;
$module->version = 2006092003;
$module->requires = 2006082600; // Requires this Moodle version
$module->cron = 60;