mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
Added has_capability checks
This commit is contained in:
parent
25c38f25a1
commit
1a3e93ffe6
@ -15,8 +15,10 @@
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (! (isteacher($course->id) or ($course->showreports and $USER->id == $user))) {
|
||||
if (! (has_capability('moodle/site:viewreports', $context)
|
||||
or ($course->showreports and $USER->id == $user)) ) {
|
||||
error("Sorry, you aren't allowed to see this.");
|
||||
}
|
||||
|
||||
|
@ -24,15 +24,10 @@
|
||||
if (! $course = get_record('course', 'id', $id) ) {
|
||||
error('That\'s an invalid course id');
|
||||
}
|
||||
|
||||
if (! isteacher($course->id)) {
|
||||
error('Only teachers can view logs');
|
||||
}
|
||||
|
||||
if (! $course->category) {
|
||||
if (!isadmin()) {
|
||||
error('Only administrators can look at the site logs');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
if (!has_capability('moodle/site:viewreports', $context)) {
|
||||
error('You need do not have the required permission to view this report');
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
|
||||
@ -51,7 +46,7 @@
|
||||
if (!$u = get_record('user', 'id', $user) ) {
|
||||
error('That\'s an invalid user!');
|
||||
}
|
||||
$userinfo = fullname($u, isteacher($course->id));
|
||||
$userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
|
||||
}
|
||||
if ($date) {
|
||||
$dateinfo = userdate($date, get_string('strftimedaydate'));
|
||||
|
@ -13,8 +13,9 @@
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
if (! isteacher($course->id)) {
|
||||
error("Only teachers can view logs");
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
if (!has_capability('moodle/site:viewreports', $context)) {
|
||||
error('You need do not have the required permission to view this report');
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user