Beispiel #1
0
	JSON OUTPUT INITIALIZATION
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'wysiwyg':
        // update wysiwyg ++ state
        $wysiwyg = isset($_REQUEST['enable']) ? 'on' : 'off';
        $pommo->_session['state']['mailing']['wysiwyg'] = $wysiwyg;
        PommoAPI::configUpdate(array('list_wysiwyg' => $wysiwyg), true);
        break;
    case 'savebody':
        $pommo->_session['state']['mailing']['body'] = $_REQUEST['body'];
        $pommo->_session['state']['mailing']['altbody'] = $_REQUEST['altbody'];
        break;
    case 'altbody':
        Pommo::requireOnce($pommo->_baseDir . 'inc/lib/lib.html2txt.php');
        $h2t =& new html2text($_REQUEST['body']);
        $json->add('altbody', $h2t->get_text());
        break;
    case 'getTemplateDescription':
        Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/templates.php');
        $template = PommoMailingTemplate::getDescriptions(array('id' => $_REQUEST['id']));
        $msg = empty($template[$_REQUEST['id']]) ? 'Aucune' : $template[$_REQUEST['id']];
        die($msg);
    default:
        $json->fail();
        break;
}
$json->success();
Beispiel #2
0
        $messages['confirm']['sub'] = $_POST['confirm_sub'];
        $messages['confirm']['msg'] = $_POST['confirm_msg'];
        $messages['activate'] = array();
        $messages['activate']['sub'] = $_POST['activate_sub'];
        $messages['activate']['msg'] = $_POST['activate_msg'];
        $messages['update'] = array();
        $messages['update']['sub'] = $_POST['update_sub'];
        $messages['update']['msg'] = $_POST['update_msg'];
        $notices = array();
        $notices['email'] = $_POST['notify_email'];
        $notices['subject'] = $_POST['notify_subject'];
        $notices['subscribe'] = $_POST['notify_subscribe'];
        $notices['unsubscribe'] = $_POST['notify_unsubscribe'];
        $notices['update'] = $_POST['notify_update'];
        $notices['pending'] = $_POST['notify_pending'];
        $input = array('messages' => serialize($messages), 'notices' => serialize($notices));
        PommoAPI::configUpdate($input, TRUE);
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields('messages'));
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$smarty->assign('t_subscribe', Pommo::_T('Subscription'));
$smarty->assign('t_unsubscribe', Pommo::_T('Unsubscription'));
$smarty->assign('t_pending', Pommo::_T('Pending'));
$smarty->assign('t_update', Pommo::_T('Update'));
$smarty->assign($_POST);
$smarty->display('admin/setup/config/messages.tpl');
Pommo::kill();
	JSON OUTPUT INITIALIZATION
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'updateOrdering':
        $when = '';
        foreach ($_REQUEST['order'] as $order => $fieldID) {
            if (is_numeric($order)) {
                $when .= $dbo->prepare("WHEN %i THEN %i", array($fieldID, $order)) . ' ';
            }
        }
        $query = "\n\t\t\tUPDATE " . $dbo->table['fields'] . "\n\t\t\tSET field_ordering = \n\t\t\t\tCASE field_id " . $when . " ELSE field_ordering END";
        if (!$dbo->query($dbo->prepare($query))) {
            $json->fail('Error Updating Order');
        }
        $json->add('query', $query);
        $json->success(Pommo::_T('Order Updated.'));
        break;
    case 'addOption':
        // validate field ID
        $field = current(PommoField::get(array('id' => $_REQUEST['field_id'])));
        if ($field['id'] != $_REQUEST['field_id']) {
            die('bad field ID');
        }
        if (!empty($_REQUEST['options'])) {
            $options = PommoField::optionAdd($field, $_REQUEST['options']);
        }
        if (!options) {
            $json->fail(Pommo::_T('Error with addition.'));
Beispiel #4
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::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
    $json = new PommoJSON();
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        // __ FORM IS VALID
        // TODO -> Which below logic is better? the computed diff, or send all fields for update?
        /*
        // make a difference between updated & original field
        $update = array_diff_assoc(PommoField::makeDB($_POST),$field);
        // restore the ID
        $update['id'] = $field['id'];
        */
        // let MySQL do the difference processing
        $update = PommoField::makeDB($_POST);
        if (!PommoField::update($update)) {
            $json->fail('error updating field');
        }
        $json->add('callbackFunction', 'updateField');
        $json->add('callbackParams', $update);
        $json->success(Pommo::_T('Settings updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields());
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$f_text = sprintf(Pommo::_T('%s - Any value will be accepted for text fields. They are useful for collecting names, addresses, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Text') . ')</strong>');
$f_check = sprintf(Pommo::_T('%s - Checkboxes can be toggled ON or OFF. They are useful for opt-ins and agreements.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Checkbox') . ')</strong>');
$f_num = sprintf(Pommo::_T('%s - Only Numeric values will be accepted for number fields.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Number') . ')</strong>');
$f_date = sprintf(Pommo::_T('%s - Only calendar values will be accepted for this field. A date selector (calendar popup) will appear next to the field to aid the subscriber in selecting a date.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Date') . ')</strong>');
$f_mult = sprintf(Pommo::_T('%s - Subscribers will be able to select a value from the options you provide below. Multiple choice fields have reliable values for organizing, and are useful for collecting Country, Interests, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Multiple Choice') . ')</strong>');
Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/validate.php');
$pommo->init();
$logger =& $pommo->_logger;
$dbo =& $pommo->_dbo;
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'addSubscriber':
        $json->setFailMsg(Pommo::_T('Error adding subscriber.'));
        // check if email is valid
        if (!PommoHelper::isEmail($_REQUEST['Email'])) {
            $json->fail(Pommo::_T('Invalid email.'));
        }
        // check if email has unsubscribed
        if (!isset($_REQUEST['force'])) {
            $unsubscribed = PommoSubscriber::GetIDByEmail($_REQUEST['Email'], 0);
            if (!empty($unsubscribed)) {
                $json->fail(sprintf(Pommo::_T('%s has already unsubscribed. To add the subscriber anyway, check the box to force the addition.'), '<strong>' . $_REQUEST['Email'] . '</strong>'));
            }
        }
        // check if duplicate
        if (PommoHelper::isDupe($_POST['Email'])) {
            $json->fail(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
        }
        $subscriber = array('email' => $_REQUEST['Email'], 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 1, 'data' => $_POST['d']);
        $flag = false;
        if (!PommoValidate::subscriberData($subscriber['data'], array('active' => FALSE, 'ignore' => TRUE))) {
Beispiel #7
0
        $group =& current(PommoGroup::get(array('id' => $state['group'])));
        $rules = PommoSQL::sortRules($group['rules']);
        switch ($_REQUEST['request']) {
            case 'update':
                if ($_REQUEST['type'] == 'or' && count($rules['and']) < 2) {
                    $json->add('callbackFunction', 'resume');
                    $json->success(Pommo::_T('At least 1 "and" rule must exist before an "or" rule takes effect.'));
                }
                PommoRules::changeType($group['id'], $_REQUEST['fieldID'], $_REQUEST['logic'], $_REQUEST['type']);
                break;
            case 'delete':
                PommoRules::deleteRule($group['id'], $_REQUEST['fieldID'], $_REQUEST['logic']);
                break;
        }
        $json->add('callbackFunction', 'redirect');
        $json->add('callbackParams', $pommo->_baseUrl . 'admin/subscribers/groups_edit.php');
        $json->serve();
        break;
    case 'renameGroup':
        if (!empty($_REQUEST['group_name'])) {
            if (PommoGroup::nameChange($state['group'], $_REQUEST['group_name'])) {
                $json->success(Pommo::_T('Group Renamed'));
            }
        }
        $json->fail('invalid group name');
        break;
    default:
        die('invalid request passed to ' . __FILE__);
        break;
}
die;