mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-35556 completion: Improve user completion data permission checking
This commit is contained in:
parent
6109f2112c
commit
f493d528c2
3 changed files with 75 additions and 19 deletions
|
@ -46,25 +46,9 @@ if ($userid) {
|
|||
|
||||
|
||||
// Check permissions
|
||||
require_login($course);
|
||||
require_login();
|
||||
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$personalcontext = context_user::instance($user->id);
|
||||
|
||||
$can_view = false;
|
||||
|
||||
// Can view own report
|
||||
if ($USER->id == $user->id) {
|
||||
$can_view = true;
|
||||
} else if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
|
||||
$can_view = true;
|
||||
} else if (has_capability('report/completion:view', $coursecontext)) {
|
||||
$can_view = true;
|
||||
} else if (has_capability('report/completion:view', $personalcontext)) {
|
||||
$can_view = true;
|
||||
}
|
||||
|
||||
if (!$can_view) {
|
||||
if (!completion_can_view_data($user->id, $course)) {
|
||||
print_error('cannotviewreport');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue