}
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.");
}
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);
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'));
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);