MDL-47914 report_stats: better handling of user and mode

This commit is contained in:
Sam Hemelryk 2014-10-28 11:22:51 +13:00
parent d63a81c507
commit fc8977fbca
2 changed files with 7 additions and 2 deletions

View File

@ -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);
}

View File

@ -161,7 +161,11 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
echo '</div>';
echo '</form>';
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');
}