public finish ( $id, $cancel = false, $test = false ) |
function finish($id = 0, $cancel = false, $test = false)
{
global $pommo;
$dbo =& Pommo::$_dbo;
$status = $cancel ? 2 : 0;
$query = "\n DELETE FROM " . $dbo->table['mailing_current'] . "\n WHERE current_id=%i";
$query = $dbo->prepare($query, array($id));
if ($dbo->affected($query) < 1) {
return false;
}
if ($test) {
// remove if this was a test mailing
// remove all notices
Pommo_Mail_Ctl::delNotices($id, 0);
// remove mailing from DB
$query = "\n DELETE FROM " . $dbo->table['mailings'] . "\n WHERE mailing_id=%i";
$query = $dbo->prepare($query, array($id));
} else {
// shorten notices to last 50
Pommo_Mail_Ctl::delNotices($id);
// update mailing in DB
$query = "\n UPDATE " . $dbo->table['mailings'] . "\n SET\n finished=FROM_UNIXTIME(%i),\n status=%i,\n sent=(SELECT count(subscriber_id) FROM " . $dbo->table['queue'] . " WHERE status > 0)\n WHERE mailing_id=%i";
$query = $dbo->prepare($query, array(time(), $status, $id));
}
if (!$dbo->query($query)) {
return false;
}
return true;
}
function stop($finish = false) { $this->_mailer->SmtpClose(); if ($this->_test) { // don't respawn if this is a test mailing Pommo_Mail_Ctl::finish($this->_id, TRUE, TRUE); Pommo_Subscribers::delete(current($this->_hash)); session_destroy(); exit; } if ($finish) { Pommo_Mail_Ctl::finish($this->_id); $this->shutdown(Pommo::_T('Mailing Complete.')); } // respwn if (!Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'ajax/mailings_send4.php?' . 'code=' . $this->_code . '&serial=' . $this->_serial . '&id=' . $this->_id)) { $this->shutdown('*** RESPAWN FAILED! ***'); } $this->shutdown(sprintf(Pommo::_T('Runtime (%s seconds) reached, respawning.'), $this->_maxRunTime), false); }