From 296c6ac2326e2c76da40c21f800bc98ca2dce0e7 Mon Sep 17 00:00:00 2001 From: mchurch Date: Fri, 28 Dec 2007 16:04:30 +0000 Subject: [PATCH] MDL-12704 - Added error handling to print_recent_activity() to prevent fatal errors in the case of missing files. --- course/lib.php | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/course/lib.php b/course/lib.php index cadd68e961..67c4662e73 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1131,23 +1131,27 @@ function print_recent_activity($course) { $viewfullnames = has_capability('moodle/site:viewfullnames', $context); foreach ($mods as $mod) { // Each module gets it's own logs and prints them - include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php'); - $print_recent_activity = $mod->name.'_print_recent_activity'; - if (function_exists($print_recent_activity)) { - // - // NOTE: - // $isteacher (second parameter below) is to be deprecated! - // - // TODO: - // 1) Make sure that all _print_recent_activity functions are - // not using the $isteacher value. - // 2) Eventually, remove the $isteacher parameter from the - // function calls. - // - $modcontent = $print_recent_activity($course, $viewfullnames, $timestart); - if ($modcontent) { - $content = true; + if (file_exists($CFG->dirroot.'/mod/'.$mod->name.'/lib.php')) { + include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php'); + $print_recent_activity = $mod->name.'_print_recent_activity'; + if (function_exists($print_recent_activity)) { + // + // NOTE: + // $isteacher (second parameter below) is to be deprecated! + // + // TODO: + // 1) Make sure that all _print_recent_activity functions are + // not using the $isteacher value. + // 2) Eventually, remove the $isteacher parameter from the + // function calls. + // + $modcontent = $print_recent_activity($course, $viewfullnames, $timestart); + if ($modcontent) { + $content = true; + } } + } else { + /// Really need to indicate an error here to admins. Is there a way to do this? } } -- 2.39.5