Fixed a warning for empty array in forum print_overview for my moodle

This commit is contained in:
mjollnir_
2005-09-07 05:43:27 +00:00
parent 7686b6b1d0
commit 95d71ad3a3
+7 -4
View File
@@ -743,8 +743,13 @@ function forum_print_overview($course,$lastaccess) {
return;
}
// get all forum logs in ONE query (much better!)
$new = get_records_sql("SELECT instance,cmid,COUNT(l.id) as count FROM {$CFG->prefix}log l JOIN {$CFG->prefix}course_modules cm ON cm.id = cmid WHERE time > $lastaccess AND l.course = ".$course->id
." AND l.module = 'forum' AND action LIKE 'add%' AND userid != ".$USER->id." GROUP BY cmid,instance");
if (!$new = get_records_sql("SELECT instance,cmid,COUNT(l.id) as count FROM {$CFG->prefix}log l "
." JOIN {$CFG->prefix}course_modules cm ON cm.id = cmid "
." WHERE time > $lastaccess AND l.course = ".$course->id
." AND l.module = 'forum' AND action LIKE 'add%' "
." AND userid != ".$USER->id." GROUP BY cmid,instance")) {
$new = array(); // avoid warnings;
}
foreach ($forums as $forum) {
$count = 0;
$unread = 0;
@@ -3385,8 +3390,6 @@ function forum_tp_count_forum_read_records($userid, $forumid, $groupid=false) {
$groupsel = ' AND (d.groupid = '.$groupid.' OR d.groupid = -1)';
}
error_log("forumcount");
if ($CFG->dbtype === 'postgres7') {
// this query takes 20ms, vs several minutes for the one below
$sql = " SELECT COUNT (DISTINCT u.id ) "