// Script to delete old notifications and send notification emails.
// Run once a day.
//
// We send emails for notifications generated in the last day.
// This is a slight kludge - since the timing of period tasks
// is not precise, notifications may be delivered twice or not at all.
// We use a 1-hour slop factor to err on the side of twice.
//
require_once("../inc/boinc_db.inc");
require_once("../inc/util.inc");
require_once("../project/project.inc");
// delete notifications older than 90 days
//
functiondelete_old_notifies(){
$t=time()-90*86400;
BoincNotify::delete_aux("create_time < $t");
}
functionsend_notify_email($userid,$message){
$user=BoincUser::lookup_id($userid);
$subject="Daily notification summary from ".PROJECT;
$body="The following events occurred in the past day at ".PROJECT.".
Fordetails,visityourAccountpageat
".URL_BASE."home.php
$message
---------------
Tochangeyouremailpreferencesfor".PROJECT.",visit:
".URL_BASE."edit_forum_preferences_form.php
Donotreplytothisemail.
";
send_email($user,$subject,$body);
echo"sending to $user->email_addr\n";
}
functionsend_notify_emails(){
$t=time()-(86400+3600);// 1-hour slop factor
$query="select notify.* from DBNAME.notify, DBNAME.forum_preferences where forum_preferences.pm_notification=2 and notify.userid = forum_preferences.userid and notify.create_time > $t";