From 9cba7a8c80cd411c2242cd3bba769791d463be43 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 15 Mar 2006 09:56:57 +0000 Subject: [PATCH] Added some more efficiencies to the code, but something seems to be wrong with this function as the SQL is not finding any new posts at all for me. Needs checking! --- mod/forum/lib.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index bfb627402c..1e7878bfd5 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -745,7 +745,7 @@ function forum_user_complete($course, $user, $mod, $forum) { function forum_print_overview($courses,&$htmlarray) { global $USER, $CFG; - + if (empty($courses) || !is_array($courses) || count($courses) == 0) { return array(); } @@ -754,9 +754,6 @@ function forum_print_overview($courses,&$htmlarray) { return; } - $strforum = get_string('modulename','forum'); - $strnumunread = get_string('overviewnumunread','forum'); - $strnumpostssince = get_string('overviewnumpostssince','forum'); // get all forum logs in ONE query (much better!) $sql = "SELECT instance,cmid,l.course,COUNT(l.id) as count FROM {$CFG->prefix}log l " @@ -801,6 +798,14 @@ function forum_print_overview($courses,&$htmlarray) { $unread = array(); } + if (empty($unread) and empty($new)) { + return; + } + + $strforum = get_string('modulename','forum'); + $strnumunread = get_string('overviewnumunread','forum'); + $strnumpostssince = get_string('overviewnumpostssince','forum'); + foreach ($forums as $forum) { $str = ''; $count = 0; -- 2.39.5