MDL-55937 assign: Check for group submission caps when userid=0
This commit is contained in:
+18
-1
@@ -2831,7 +2831,12 @@ class assign {
|
||||
$item = $this->get_submission($submissionid);
|
||||
|
||||
// Check permissions.
|
||||
$this->require_view_submission($item->userid);
|
||||
if (empty($item->userid)) {
|
||||
// Group submission.
|
||||
$this->require_view_group_submission($item->groupid);
|
||||
} else {
|
||||
$this->require_view_submission($item->userid);
|
||||
}
|
||||
$o .= $this->get_renderer()->render(new assign_header($this->get_instance(),
|
||||
$this->get_context(),
|
||||
$this->show_intro(),
|
||||
@@ -3026,6 +3031,18 @@ class assign {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an error if the permissions to view this users' group submission are missing.
|
||||
*
|
||||
* @param int $groupid Group id.
|
||||
* @throws required_capability_exception
|
||||
*/
|
||||
public function require_view_group_submission($groupid) {
|
||||
if (!$this->can_view_group_submission($groupid)) {
|
||||
throw new required_capability_exception($this->context, 'mod/assign:viewgrades', 'nopermission', '');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an error if the permissions to view this users submission are missing.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user