Example #1
0
    Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
    $json = new PommoJSON();
    if ($state['tally'] > 0) {
        if ($state['ishtml'] == 'off') {
            $state['body'] = $state['altbody'];
            $state['altbody'] = '';
        }
        $mailing = PommoMailing::make(array(), TRUE);
        $state['status'] = 1;
        $state['current_status'] = 'stopped';
        $state['command'] = 'restart';
        $mailing = PommoHelper::arrayIntersect($state, $mailing);
        $code = PommoMailing::add($mailing);
        if (!PommoMailCtl::queueMake($group->_memberIDs)) {
            $json->fail('Unable to populate queue');
        }
        if (!PommoMailCtl::spawn($pommo->_baseUrl . 'admin/mailings/mailings_send4.php?code=' . $code)) {
            $json->fail('Unable to spawn background mailer');
        }
        // clear mailing composistion data from session
        PommoAPI::stateReset(array('mailing'));
        $json->add('callbackFunction', 'redirect');
        $json->add('callbackParams', $pommo->_baseUrl . 'admin/mailings/mailing_status.php');
    } else {
        $json->fail(Pommo::_T('Cannot send a mailing to 0 subscribers!'));
    }
    $json->serve();
}
$smarty->assign($state);
$smarty->display('admin/mailings/mailing/preview.tpl');
Pommo::kill();