But, it hasnt been run for a looooong time, and i dont want it to send out emails for old forum posts. What can i do to reset the cron, so when it runs for the first time it doesnt send a gazillion emails.
For everyone else. Here is the snippet.
// Posts older than 2 days will not be mailed. This is to avoid the problem where
// cron has not been running for a long time, and then suddenly people are flooded
// with mail from the past few weeks or months
$timenow = time();
$endtime = $timenow - $CFG->maxeditingtime;
$starttime = $endtime - 48 * 3600; // Two days earlier
I am using Moodle 1.9.5+
I have looked in the cron.php script for the snippet you are referring to but I don't find it. Has it changed or am I looking in the wrong script?
But why are you looking for it ?
(I realize I'm replying to a post that is 5 years old, but I was looking for this setting today...)
We have the max editing time set to a really long time (like a year or something).
The cron code doesn't send out emails until the editing period is over, and that makes sense.
But, our users are now getting emails for posts that were posted between a year and a year and two days ago, due to the default start and end times.
Our site is probably weird in that we allow editing basically forever, and I get the argument that says that is weird because if someone replies, and then the parent post is edited, the conversation flow can be broken, but that is what we want.
I just want to either turn off emails for forum posts, or change it to email out after a certain amount of time. Different users want different behavior.
I haven't coded this up yet, but I'm thinking that if I change the code to be:
$endtime = $timenow - /*$CFG->maxeditingtime*/4*3600;
that will solve the issue. But, then of course, I have to reapply my change every upgrade...
It would probably have been better to have started a new thread. The state of Moodle does tend to change a fair amount over any given five-year period ;)
Rather than applying an arbitrary hard-coded metric, you could make use of capabilities. There isn't an appropriate capability present at the moment, but you could create a new capability to control editing posts without an editing period, and submit your patch to a new issue in the tracker.
This would probably be the most sustainable way of achieving what you want, whilst contributing back to the project for others who require a similar functionality.
Forum posts have been going out fine, and I did not set up a cron job for it. What am I missing?
on Admin / Notifications:
I receive the 'cron maintenance script has not been run in 24 hours' notice.
If I run it from that page, it seems fine; runs statistics, etc.
However, all forum posts have always been going out. I have not set anything up to do this; so is it automatic?
If the maintenance script notice is (just?) for statistics, is it that necessary to run it?
Where is the cron job that does run the forum posts (if not here?)
Why haven't I had to set it up to send forum posts (when it seems like that is the one crucial thing the cron job is supposed to do?)
Ugh. I used to think I could figure these things out:
Meanwhile, I have set up a new cronjob (hosted on Linux system; with correct director/domain) on the goodies cron tab in the host's web panel:
Wondering why I haven't had to do anything ... or what I'm missing.
thanks for hints,