Added has_capability checks

This commit is contained in:
vyshane 2006-08-25 08:27:28 +00:00
parent 41d7209c7f
commit 6ac96fcb3c
3 changed files with 11 additions and 5 deletions

View File

@ -21,8 +21,10 @@
}
require_login();
if (!isteacher($course->id)) {
error("You need to be a teacher to use this page");
$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 reports for this course');
}
stats_check_uptodate($course->id);

View File

@ -33,8 +33,10 @@
}
require_login();
if (!isteacher($course->id)) {
error("You need to be a teacher to use this page");
$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 reports for this course');
}
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);

View File

@ -4,7 +4,9 @@
$courseoptions = array();
foreach ($courses as $c) {
if (isteacher($c->id)) {
$context = get_context_instance(CONTEXT_COURSE, $c->id);
if (has_capability('moodle/site:viewreports', $context)) {
$courseoptions[$c->id] = $c->shortname;
}
}