Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…moodle
  • Loading branch information...
commit 9efd421e0ec9c58d58aab2bc0dbf7cd7067c8707 2 parents 91bad7a + 5fba673
Sam Hemelryk authored May 30, 2011

Showing 1 changed file with 13 additions and 6 deletions. Show diff stats Hide diff stats

  1. 19  lib/navigationlib.php
19  lib/navigationlib.php
@@ -1700,9 +1700,16 @@ protected function load_for_user($user=null, $forceforcontext=false) {
1700 1700
         }
1701 1701
 
1702 1702
         // Add a reports tab and then add reports the the user has permission to see.
1703  
-        $anyreport  = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
  1703
+        $anyreport      = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
1704 1704
 
1705  
-        $viewreports = ($anyreport || ($course->showreports && $iscurrentuser && $forceforcontext));
  1705
+        $outlinetreport = ($anyreport || has_capability('coursereport/outline:view', $coursecontext));
  1706
+        $logtodayreport = ($anyreport || has_capability('coursereport/log:viewtoday', $coursecontext));
  1707
+        $logreport      = ($anyreport || has_capability('coursereport/log:view', $coursecontext));
  1708
+        $statsreport    = ($anyreport || has_capability('coursereport/stats:view', $coursecontext));
  1709
+
  1710
+        $somereport     = $outlinetreport || $logtodayreport || $logreport || $statsreport;
  1711
+
  1712
+        $viewreports = ($anyreport || $somereport || ($course->showreports && $iscurrentuser && $forceforcontext));
1706 1713
         if ($viewreports) {
1707 1714
             $reporttab = $usernode->add(get_string('activityreports'));
1708 1715
             $reportargs = array('user'=>$user->id);
@@ -1711,21 +1718,21 @@ protected function load_for_user($user=null, $forceforcontext=false) {
1711 1718
             } else {
1712 1719
                 $reportargs['id'] = SITEID;
1713 1720
             }
1714  
-            if ($viewreports || has_capability('coursereport/outline:view', $coursecontext)) {
  1721
+            if ($viewreports || $outlinetreport) {
1715 1722
                 $reporttab->add(get_string('outlinereport'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'outline'))));
1716 1723
                 $reporttab->add(get_string('completereport'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'complete'))));
1717 1724
             }
1718 1725
 
1719  
-            if ($viewreports || has_capability('coursereport/log:viewtoday', $coursecontext)) {
  1726
+            if ($viewreports || $logtodayreport) {
1720 1727
                 $reporttab->add(get_string('todaylogs'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'todaylogs'))));
1721 1728
             }
1722 1729
 
1723  
-            if ($viewreports || has_capability('coursereport/log:view', $coursecontext)) {
  1730
+            if ($viewreports || $logreport ) {
1724 1731
                 $reporttab->add(get_string('alllogs'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'alllogs'))));
1725 1732
             }
1726 1733
 
1727 1734
             if (!empty($CFG->enablestats)) {
1728  
-                if ($viewreports || has_capability('coursereport/stats:view', $coursecontext)) {
  1735
+                if ($viewreports || $statsreport) {
1729 1736
                     $reporttab->add(get_string('stats'), new moodle_url('/course/user.php', array_merge($reportargs, array('mode'=>'stats'))));
1730 1737
                 }
1731 1738
             }

0 notes on commit 9efd421

Please sign in to comment.
Something went wrong with that request. Please try again.