From 3c7da16d2d7c7e5253e8e404dc34254c7af60d33 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 1 Dec 2008 19:19:29 +0000 Subject: [PATCH] MDL-17485 roles: fixed use and definition of review use of moodle/user:viewuseractivitiesreport --- course/user.php | 4 ++++ lib/db/access.php | 5 ++--- lib/weblib.php | 7 ++++--- user/tabs.php | 4 ++++ version.php | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/course/user.php b/course/user.php index 61f7491947..d090d99ba8 100644 --- a/course/user.php +++ b/course/user.php @@ -75,6 +75,10 @@ } else if ($course->showgrades and has_capability('moodle/grade:viewall', $personalcontext)) { // ok - can view grades of this user - parent most probably $modes[] = 'grade'; + + } else if ($course->showgrades and $anyreport) { + // ok - can view grades of this user - parent most probably + $modes[] = 'grade'; } if (empty($modes)) { diff --git a/lib/db/access.php b/lib/db/access.php index b4a7d2a8a3..8fc3555dca 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -887,14 +887,13 @@ $moodle_capabilities = array( ) ), + // designed for parent role - not used in legacy roles 'moodle/user:viewuseractivitiesreport' => array( + 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_USER, 'legacy' => array( - 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW ) ), diff --git a/lib/weblib.php b/lib/weblib.php index 7ac9dc9c3d..ca2b28f7b4 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4640,7 +4640,9 @@ function print_user($user, $course, $messageselect=false, $return=false) { $context = get_context_instance(CONTEXT_COURSE, $course->id); if (isset($user->context->id)) { - $usercontext = get_context_instance_by_id($user->context->id); + $usercontext = $user->context; + } else { + $usercontext = get_context_instance(CONTEXT_USER, $user->id); } if (empty($string)) { // Cache all the strings for the rest of the page @@ -4724,8 +4726,7 @@ has_capability('moodle/course:viewhiddenuserfields', $context)) { $output .= ''.get_string('notes','notes').'
'; } - if (has_capability('moodle/user:viewuseractivitiesreport', $context) || (isset($usercontext) && has_capability('moodle/user:viewuseractivitiesreport', $usercontext))) { - $timemidnight = usergetmidnight(time()); + if (has_capability('moodle/site:viewreports', $context) or has_capability('moodle/user:viewuseractivitiesreport', $usercontext)) { $output .= ''. $string->activity .'
'; } if (has_capability('moodle/role:assign', $context) and get_user_roles($context, $user->id, false)) { // I can unassing and user has some role diff --git a/user/tabs.php b/user/tabs.php index 842348bb48..eed80872f3 100644 --- a/user/tabs.php +++ b/user/tabs.php @@ -223,6 +223,10 @@ // ok - can view grades of this user - parent most probably $gradeaccess = true; + } else if ($course->showgrades and $anyreport) { + // ok - can view grades of this user - parent most probably + $gradeaccess = true; + } else { $gradeaccess = false; } diff --git a/version.php b/version.php index d1b115d901..e6ccc20f09 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2008113001; // YYYYMMDD = date of the last version bump + $version = 2008120100; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20081128)'; // Human-friendly version name -- 2.39.5