From: moodler Date: Thu, 9 Oct 2003 04:58:09 +0000 (+0000) Subject: Some changes so that forum_cron is not fooled in case there is already X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ec2137ba4928baaa966e2e7a21de0863695aae74;p=moodle.git Some changes so that forum_cron is not fooled in case there is already a real $USER variable present (eg if cron.php was run manually) and so the timezones are not calculated incorrectly. --- diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 48c48649c1..45e66aa594 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -189,6 +189,10 @@ function forum_cron () { global $CFG, $USER; + if (!empty($USER)) { // Remember real USER account if necessary + $realuser = $USER; + } + $cutofftime = time() - $CFG->maxeditingtime; if ($posts = forum_get_unmailed_posts($cutofftime)) { @@ -238,8 +242,11 @@ function forum_cron () { $mailcount=0; foreach ($users as $userto) { - /// Override the language of get_string, so that mail is in correct language for the receiver. - $USER->lang = $userto->lang; + /// Override the language and timezone of the "current" user, so that + /// mail is customised for the receiver. + $USER->lang = $userto->lang; + $USER->timezone = $userto->timezone; + $canreply = forum_user_can_post($forum, $userto); $by->name = "$userfrom->firstname $userfrom->lastname"; @@ -310,6 +317,10 @@ function forum_cron () { } } + if (!empty($realuser)) { // Restore real USER if necessary + $USER = $realuser; + } + return true; }