Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
fd892c6f
Commit
fd892c6f
authored
Jul 31, 2012
by
Sam Hemelryk
Browse files
Merge branch 'MDL-32931_master' of
git://github.com/dmonllao/moodle
parents
ac881779
ba4ee840
Changes
1
Hide whitespace changes
Inline
Side-by-side
mod/forum/lib.php
View file @
fd892c6f
...
...
@@ -1310,23 +1310,33 @@ function forum_print_overview($courses,&$htmlarray) {
return
;
}
// get all forum logs in ONE query (much better!)
// Courses to search for new posts
$coursessqls
=
array
();
$params
=
array
();
$sql
=
"SELECT instance,cmid,l.course,COUNT(l.id) as count FROM
{
log
}
l "
.
" JOIN
{
course_modules
}
cm ON cm.id = cmid "
.
" WHERE ("
;
foreach
(
$courses
as
$course
)
{
$sql
.
=
'(l.course = ? AND l.time > ?) OR '
;
$params
[]
=
$course
->
id
;
$params
[]
=
$course
->
lastaccess
;
}
$sql
=
substr
(
$sql
,
0
,
-
3
);
// take off the last OR
$sql
.
=
") AND l.module = 'forum' AND action = 'add post' "
.
" AND userid != ? GROUP BY cmid,l.course,instance"
;
// If the user has never entered into the course all posts are pending
if
(
$course
->
lastaccess
==
0
)
{
$coursessqls
[]
=
'(f.course = ?)'
;
$params
[]
=
$course
->
id
;
// Only posts created after the course last access
}
else
{
$coursessqls
[]
=
'(f.course = ? AND p.created > ?)'
;
$params
[]
=
$course
->
id
;
$params
[]
=
$course
->
lastaccess
;
}
}
$params
[]
=
$USER
->
id
;
$coursessql
=
implode
(
' OR '
,
$coursessqls
);
$sql
=
"SELECT f.id, COUNT(*) as count "
.
'FROM {forum} f '
.
'JOIN {forum_discussions} d ON d.forum = f.id '
.
'JOIN {forum_posts} p ON p.discussion = d.id '
.
"WHERE (
$coursessql
) "
.
'AND p.userid != ? '
.
'GROUP BY f.id'
;
if
(
!
$new
=
$DB
->
get_records_sql
(
$sql
,
$params
))
{
$new
=
array
();
// avoid warnings
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment