]> git.mjollnir.org Git - moodle.git/commitdiff
mod/chat: chat_update_chat_times() smarter
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:21:09 +0000 (07:21 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:21:09 +0000 (07:21 +0000)
If cron hasn't run for a few days, it would take
several runs for chat_update_chat_times() to get things back on track.

Now it's all fixed in one go, saving a bit of DB traffic. It all adds
up...

mod/chat/lib.php

index 779e59dc3b39fbe073d88baad9b7c30b0f03a2e5..d559949b2da3e97e779e2f688603bd7fd576559e 100644 (file)
@@ -497,10 +497,14 @@ function chat_update_chat_times($chatid=0) {
                     $chat->schedule = 0;
                     break;
             case 2: // Repeat daily
-                    $chat->chattime += 24 * 3600;
+                    while ($chat->chattime <= $timenow) {
+                        $chat->chattime += 24 * 3600;
+                    }
                     break;
             case 3: // Repeat weekly
-                    $chat->chattime += 7 * 24 * 3600;
+                    while ($chat->chattime <= $timenow) {
+                        $chat->chattime += 7 * 24 * 3600;
+                    }
                     break;
         }
         update_record("chat", $chat);