Пример #1
0
/**
 * @param  $user_id
 * @param  $mail_id
 * @param DateTime $when The approximate date/time the e-mail should be sent
 * @param bool $allow_duplicates If false, won't schedule this e-mail if it has already been sent
 *    in the past, or if it's currently scheduled to be sent. If true, will schedule the e-mail
 *    no matter what. If NULL (or omitted) then the mail template's preferred setting will be used
 * @return void
 */
function schedule_mail($user_id, $mail_id, $when = FALSE, $allow_duplicates = NULL)
{
    $db = new DbConn();
    $template = get_mail_template($mail_id, TRUE);
    if ($allow_duplicates === FALSE || is_null($allow_duplicates) && !$template->allowdupes) {
        $results = $db->query('select *
                           from mails_sent as ms, mail_template_versions as mtv
                           where ms.templateverid = mtv.id
                             and mtv.templateid = ?
                             and userid = ?', $mail_id, $user_id);
        if ($results->length > 0) {
            return FALSE;
        }
        $results = $db->query('select * from mails_scheduled where userid = ? and mailid = ?', $user_id, $mail_id);
        if ($results->length > 0) {
            return FALSE;
        }
    }
    if (!$when) {
        send_user_mail($template, $user_id);
        return TRUE;
    } else {
        $db->exec('insert into mails_scheduled (userid, mailid, due) values (?, ?, ?)', $user_id, $mail_id, $when);
        return TRUE;
    }
}
Пример #2
0
 function index()
 {
     $this->load->helper('mail');
     $db = new DbConn();
     $mails = $db->query('select * from mails_scheduled where due <= NOW()');
     while ($mail = $mails->next()) {
         $user_id = $mail->userid;
         $mail_id = $mail->mailid;
         $template = get_mail_template($mail_id, false);
         if (!$template) {
             continue;
         }
         send_user_mail($template, $user_id);
         $db->exec('delete from mails_scheduled where id = ?', $mail->id);
     }
 }
Пример #3
0
<?php

require_once 'common.inc';
$db = new DbConn();
$mails = $db->query('select * from mails_scheduled where due <= UTC_TIMESTAMP()');
while ($mail = $mails->next()) {
    $user_id = $mail->userid;
    $mail_id = $mail->mailid;
    $id = $mail->id;
    $template = get_mail_template($mail_id, false);
    if (!$template) {
        continue;
    }
    send_user_mail($template, $user_id);
    $db->exec('insert into mails_sent (userid, templateverid) values (?, ?)', $user_id, $template->id);
    $db->exec('delete from mails_scheduled where id = ?', $mail->id);
}
Пример #4
0
Файл: sav.php Проект: philum/cms
function publish_art($publish, $read, $bs)
{
    if (auth(4)) {
        if ($publish == 'on') {
            update($bs, 're', 1, 'id', $read);
            send_user_mail($_SESSION['read'], 'published_art');
            if ($bs == 'qdi') {
                send_track_to_user($read);
            }
        } elseif ($publish == 'off') {
            update($bs, 're', 0, 'id', $read);
        }
    }
}
Пример #5
0
Файл: spe.php Проект: philum/cms
function publish_art($publish, $read, $bs)
{
    if (auth(4)) {
        $base = $_SESSION[$bs];
        if ($publish == "on") {
            update($bs, "re", 1, "id", $read);
            send_user_mail($_SESSION['read'], 'published_art');
            if ($bs == 'qdi') {
                send_track_to_user($read);
            }
        } elseif ($publish == "off") {
            update($bs, "re", 0, "id", $read);
        }
    } else {
        alert(btn("txtalert", "bruu you cant do that"));
    }
}