MDL-37710 Assign: Fix pluginfile permission checks for student viewing their own team submission.

This change adds a function to the assign class to allow the permissions for a group submission
to be checked and updates all the submission plugins to call it.
This commit is contained in:
Damyon Wiese 2013-01-29 16:07:08 +08:00
parent cbb26eb0ec
commit 3e1b63f1c8
4 changed files with 62 additions and 29 deletions

View file

@ -92,21 +92,15 @@ function assignsubmission_comments_comment_permissions(stdClass $options) {
if ($assignment->get_instance()->id != $submission->assignment) {
throw new comment_exception('invalidcontext');
}
if (!has_capability('mod/assign:grade', $context)) {
if (!has_capability('mod/assign:submit', $context)) {
return array('post' => false, 'view' => false);
} else if ($assignment->get_instance()->teamsubmission) {
$group = $assignment->get_submission_group($USER->id);
$groupid = 0;
if ($group) {
$groupid = $group->id;
}
if ($groupid != $submission->groupid) {
return array('post' => false, 'view' => false);
}
} else if ($submission->userid != $USER->id) {
return array('post' => false, 'view' => false);
}
if ($assignment->get_instance()->teamsubmission &&
!$assignment->can_view_group_submission($submission->groupid)) {
return array('post' => false, 'view' => false);
}
if (!$assignment->get_instance()->teamsubmission &&
!$assignment->can_view_submission($submission->userid)) {
return array('post' => false, 'view' => false);
}
return array('post' => true, 'view' => true);