Permalink
Browse files

Merge branch 'navigationlib_userreports' of git://github.com/stronk7/…

…moodle
  • Loading branch information...
Sam Hemelryk
Sam Hemelryk committed May 30, 2011
2 parents 91bad7a + 5fba673 commit 9efd421e0ec9c58d58aab2bc0dbf7cd7067c8707
Showing with 13 additions and 6 deletions.
  1. +13 −6 lib/navigationlib.php
View
@@ -1700,9 +1700,16 @@ protected function load_for_user($user=null, $forceforcontext=false) {
}
// Add a reports tab and then add reports the the user has permission to see.
- $anyreport = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
+ $anyreport = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
- $viewreports = ($anyreport || ($course->showreports && $iscurrentuser && $forceforcontext));
+ $outlinetreport = ($anyreport || has_capability('coursereport/outline:view', $coursecontext));
+ $logtodayreport = ($anyreport || has_capability('coursereport/log:viewtoday', $coursecontext));
+ $logreport = ($anyreport || has_capability('coursereport/log:view', $coursecontext));
+ $statsreport = ($anyreport || has_capability('coursereport/stats:view', $coursecontext));
+
+ $somereport = $outlinetreport || $logtodayreport || $logreport || $statsreport;
+
+ $viewreports = ($anyreport || $somereport || ($course->showreports && $iscurrentuser && $forceforcontext));
if ($viewreports) {
$reporttab = $usernode->add(get_string('activityreports'));
$reportargs = array('user'=>$user->id);
@@ -1711,21 +1718,21 @@ protected function load_for_user($user=null, $forceforcontext=false) {
} else {
$reportargs['id'] = SITEID;
}
- if ($viewreports || has_capability('coursereport/outline:view', $coursecontext)) {
+ if ($viewreports || $outlinetreport) {
$reporttab->add(get_string('outlinereport'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'outline'))));
$reporttab->add(get_string('completereport'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'complete'))));
}
- if ($viewreports || has_capability('coursereport/log:viewtoday', $coursecontext)) {
+ if ($viewreports || $logtodayreport) {
$reporttab->add(get_string('todaylogs'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'todaylogs'))));
}
- if ($viewreports || has_capability('coursereport/log:view', $coursecontext)) {
+ if ($viewreports || $logreport ) {
$reporttab->add(get_string('alllogs'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'alllogs'))));
}
if (!empty($CFG->enablestats)) {
- if ($viewreports || has_capability('coursereport/stats:view', $coursecontext)) {
+ if ($viewreports || $statsreport) {
$reporttab->add(get_string('stats'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'stats'))));
}
}

0 comments on commit 9efd421

Please sign in to comment.