]> git.mjollnir.org Git - moodle.git/commitdiff
Added has_capability checks
authorvyshane <vyshane>
Fri, 25 Aug 2006 08:51:50 +0000 (08:51 +0000)
committervyshane <vyshane>
Fri, 25 Aug 2006 08:51:50 +0000 (08:51 +0000)
course/report/log/graph.php
course/report/log/index.php
course/report/log/live.php

index 976e13f125b58d541a07d18c831db33389d3ed70..b2dd3117e4478caa14434dcbd696408d279fe49d 100644 (file)
     }
 
     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.");
     }
 
index 1b1cba928981a90cc261500559e0100cf6301092..850415781223f5620eaaf10e558350118e2fbcd6 100644 (file)
     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'));
index 33da4af39fbb79eba3a6b382bc9ea9acf4406658..a1c89b76befba7b25b49d1931ab6de6998865abf 100644 (file)
@@ -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);