diff --git a/report/stats/graph.php b/report/stats/graph.php index b4463e16536..8505e33ac96 100644 --- a/report/stats/graph.php +++ b/report/stats/graph.php @@ -57,7 +57,8 @@ if (!empty($userid)) { if (!report_stats_can_access_user_report($user, $course, true)) { require_capability('report/stats:view', $coursecontext); } - +} else if ($mode === STATS_MODE_DETAILED) { + print_error('invaliduser'); } else { require_capability('report/stats:view', $coursecontext); } diff --git a/report/stats/locallib.php b/report/stats/locallib.php index 0a0b6f1e414..78bbda6b05f 100644 --- a/report/stats/locallib.php +++ b/report/stats/locallib.php @@ -161,7 +161,11 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) { echo ''; echo ''; - if (!empty($report) && !empty($time)) { + // Display the report if: + // - A report has been selected. + // - A time frame has been provided + // - If the mode is not detailed OR a valid user has been selected. + if (!empty($report) && !empty($time) && ($mode !== STATS_MODE_DETAILED || !empty($userid))) { if ($report == STATS_REPORT_LOGINS && $course->id != SITEID) { print_error('reportnotavailable'); }