From 0f620d4bf2bc5a967d72a6a088593b10ca083e41 Mon Sep 17 00:00:00 2001 From: patrickslee Date: Tue, 22 Nov 2005 04:08:02 +0000 Subject: [PATCH] Some mailing related Embargoed Announcements fixes. * The forum cron only mails posts those are created within the past two days, in which case posts those are scheduled to shown after more than two days will be ignored and not been mailed out. * When cron is marking old posts as mailed, it supposes everything is mailed so just marks everything older than now as mailed. We DO NOT want our delayed posts been marked as mailed. --- mod/forum/lib.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 4bcaf26ddfe..95f157162cf 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1153,7 +1153,7 @@ function forum_get_unmailed_posts($starttime, $endtime) { FROM {$CFG->prefix}forum_posts p, {$CFG->prefix}forum_discussions d WHERE p.mailed = 0 - AND p.created >= '$starttime' + AND (p.created >= '$starttime' OR OR d.timestart > 0) AND p.created < '$endtime' AND p.discussion = d.id AND ((d.timestart = 0 OR d.timestart <= '$now') @@ -1164,9 +1164,25 @@ function forum_get_unmailed_posts($starttime, $endtime) { function forum_mark_old_posts_as_mailed($endtime) { /// Marks posts before a certain time as being mailed already global $CFG; +/// Find out posts those are not showing immediately so we can exclude them + $now = time(); + $delayed_posts = get_records_sql("SELECT p.id, p.discussion + FROM {$CFG->prefix}forum_posts p, + {$CFG->prefix}forum_discussions d + WHERE p.mailed = 0 + AND p.discussion = d.id + AND d.timestart > '$now'"); + $delayed_ids = array(); + if ($delayed_posts) { + foreach ($delayed_posts as $post) { + $delayed_ids[] = $post->id; + } + } else { + $delayed_ids[] = 0; + } return execute_sql("UPDATE {$CFG->prefix}forum_posts SET mailed = '1' - WHERE created < '$endtime' AND mailed ='0'"); + WHERE id NOT IN (".implode(',',$delayed_ids).") AND created < '$endtime' AND mailed ='0'"); } function forum_get_user_posts($forumid, $userid) {