diff --git a/course/lib.php b/course/lib.php index 6e4a20e3783..419e306d23c 100644 --- a/course/lib.php +++ b/course/lib.php @@ -387,6 +387,11 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per echo "".get_string('info')."\n"; echo "\n"; + if (empty($logs['logs'])) { + echo "\n"; + return; + } + $row = 1; foreach ($logs['logs'] as $log) { @@ -479,6 +484,10 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname, echo get_string('savedat').userdate(time(), $strftimedatetime)."\n"; echo $text; + if (empty($logs['logs'])) { + return true; + } + foreach ($logs['logs'] as $log) { if (isset($ldcache[$log->module][$log->action])) { $ld = $ldcache[$log->module][$log->action]; @@ -565,6 +574,11 @@ function print_log_xls($course, $user, $date, $order='l.time DESC', $modname, } } + if (empty($logs['logs'])) { + $workbook->close(); + return true; + } + $formatDate =& $workbook->add_format(); $formatDate->set_num_format(get_string('log_excel_date_format'));