Ejemplo n.º 1
0
function send_notify_emails()
{
    $db = BoincDb::get();
    $t = time() - (86400 + 3600);
    // 1-hour slop factor
    $query = "select notify.* from " . $db->db_name . ".notify, " . $db->db_name . ".forum_preferences where forum_preferences.pm_notification=2 and notify.userid = forum_preferences.userid and notify.create_time > {$t}";
    $notifies = BoincNotify::enum_general($query);
    $userid = 0;
    $message = "";
    $i = 1;
    foreach ($notifies as $notify) {
        if ($userid && $notify->userid != $userid && strlen($message)) {
            send_notify_email($userid, $message);
            $message = "";
            $found = false;
            $i = 1;
        }
        $userid = $notify->userid;
        $x = null;
        switch ($notify->type) {
            case NOTIFY_FRIEND_REQ:
                $x = friend_notify_req_email_line($notify);
                break;
            case NOTIFY_FRIEND_ACCEPT:
                $x = friend_notify_accept_email_line($notify);
                break;
            case NOTIFY_PM:
                $x = pm_email_line($notify);
                break;
            case NOTIFY_SUBSCRIBED_POST:
                $x = subscribed_post_email_line($notify);
                break;
        }
        if ($x) {
            $message .= "{$i}) {$x}\n";
            $i++;
        } else {
            $notify->delete();
        }
    }
    if ($userid && strlen($message)) {
        send_notify_email($userid, $message);
    }
}
Ejemplo n.º 2
0
function send_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}";
    $notifies = BoincNotify::enum_general($query);
    $userid = 0;
    $message = "";
    $i = 1;
    foreach ($notifies as $notify) {
        if ($userid && $notify->userid != $userid) {
            send_notify_email($userid, $message);
            $message = "";
            $i = 1;
        }
        $userid = $notify->userid;
        $message .= "{$i}) ";
        switch ($notify->type) {
            case NOTIFY_FRIEND_REQ:
                $message .= friend_notify_req_email_line($notify);
                break;
            case NOTIFY_FRIEND_ACCEPT:
                $message .= friend_notify_accept_email_line($notify);
                break;
            case NOTIFY_PM:
                $message .= pm_email_line($notify);
                break;
            case NOTIFY_SUBSCRIBED_POST:
                $message .= subscribed_post_email_line($notify);
                break;
        }
        $message .= "\n";
        $i++;
    }
    if ($userid) {
        send_notify_email($userid, $message);
    }
}