]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes for empty logs array MDL-6145
authormoodler <moodler>
Wed, 27 Sep 2006 07:41:38 +0000 (07:41 +0000)
committermoodler <moodler>
Wed, 27 Sep 2006 07:41:38 +0000 (07:41 +0000)
course/lib.php

index 6e4a20e37831c67163b41efb67ef513952f59a66..419e306d23cf41a449f113672bfb00195576f89e 100644 (file)
@@ -387,6 +387,11 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
     echo "<th class=\"c5 header\">".get_string('info')."</th>\n";
     echo "</tr>\n";
 
+    if (empty($logs['logs'])) {
+        echo "</table>\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'));