Skip to content

Commit

Permalink
MDL-55937 assign: Check for group submission caps when userid=0
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Aug 15, 2017
1 parent f3625f4 commit 2ba3ce9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2889,7 +2889,12 @@ protected function view_plugin_content($pluginsubtype) {
$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(),
Expand Down Expand Up @@ -3084,6 +3089,18 @@ protected function view_footer() {
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.
*
Expand Down

0 comments on commit 2ba3ce9

Please sign in to comment.