Skip to content

Commit

Permalink
MDL-52930 forum: Correct get_unmailed_posts logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Marshall authored and andrewnicols committed Feb 5, 2016
1 parent 80b0902 commit a9745eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mod/forum/lib.php
Expand Up @@ -2224,18 +2224,21 @@ function forum_get_unmailed_posts($starttime, $endtime, $now=null) {
if (empty($now)) {
$now = time();
}
$selectsql = "AND (p.created >= :ptimestart OR d.timestart >= :pptimestart)";
$params['pptimestart'] = $starttime;
$timedsql = "AND (d.timestart < :dtimestart AND (d.timeend = 0 OR d.timeend > :dtimeend))";
$params['dtimestart'] = $now;
$params['dtimeend'] = $now;
} else {
$timedsql = "";
$selectsql = "AND p.created >= :ptimestart";
}

return $DB->get_records_sql("SELECT p.*, d.course, d.forum
FROM {forum_posts} p
JOIN {forum_discussions} d ON d.id = p.discussion
WHERE p.mailed = :mailed
AND p.created >= :ptimestart
$selectsql
AND (p.created < :ptimeend OR p.mailnow = :mailnow)
$timedsql
ORDER BY p.modified ASC", $params);
Expand Down

0 comments on commit a9745eb

Please sign in to comment.