]> git.mjollnir.org Git - moodle.git/commitdiff
Added some more efficiencies to the code, but something seems to be wrong
authormoodler <moodler>
Wed, 15 Mar 2006 09:56:57 +0000 (09:56 +0000)
committermoodler <moodler>
Wed, 15 Mar 2006 09:56:57 +0000 (09:56 +0000)
with this function as the SQL is not finding any new posts at all for me.

Needs checking!

mod/forum/lib.php

index bfb627402c05febe8b6375484b7c2830bd5ab99c..1e7878bfd55ee2c3eac835327b4362305825edbd 100644 (file)
@@ -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;