From: moodler Date: Wed, 15 Mar 2006 09:56:57 +0000 (+0000) Subject: Added some more efficiencies to the code, but something seems to be wrong X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9cba7a8c80cd411c2242cd3bba769791d463be43;p=moodle.git 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! --- 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;