$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();
*********************************/ 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();
if (!SmartyValidate::is_registered_form('exchanger') || empty($_POST)) { // ___ USER HAS NOT SENT FORM ___ SmartyValidate::register_form('exchanger', true); SmartyValidate::register_validator('email', 'email', 'isEmail', false, false, false, 'exchanger'); $vMsg = array(); $vMsg['email'] = Pommo::_T('Invalid email address'); $smarty->assign('vMsg', $vMsg); $dbvals = array('exchanger' => $exchanger, 'email' => $pommo->_config['admin_email']); $smarty->assign($dbvals); } else { // ___ USER HAS SENT FORM ___ /********************************** JSON OUTPUT INITIALIZATION *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php'); $json = new PommoJSON(); if (SmartyValidate::is_valid($_POST, 'exchanger')) { // __ FORM IS VALID Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/messages.php'); $msg = PommoHelperMessages::testExchanger($_POST['email'], $exchanger) ? Pommo::_T('Mail Sent.') : Pommo::_T('Error Sending Mail'); $json->success($msg); } else { // __ FORM NOT VALID $json->addMsg(Pommo::_T('Please review and correct errors with your submission.')); $json->add('fieldErrors', $smarty->getInvalidFields('exchanger')); $json->fail(); } } $smarty->assign($_POST); $smarty->display('admin/setup/config/ajax.testexchanger.tpl'); Pommo::kill();
$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.')); } $json->add('callbackFunction', 'updateOptions'); $json->add('callbackParams', $options);
// __ 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>'); $f_comm = sprintf(Pommo::_T('%s -. If a subscriber enters a value for a comment field, it will be mailed to the admin notification email.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Comment') . ')</strong>'); switch ($field['type']) { case 'text': $smarty->assign('intro', $f_text);
PommoRules::addFieldRule($state['group'], $_REQUEST['field'], $_REQUEST['logic'], $values, $type); break; } $json->add('callbackFunction', 'redirect'); $json->add('callbackParams', $pommo->_baseUrl . 'admin/subscribers/groups_edit.php'); $json->serve(); break; case 'updateRule': Pommo::requireOnce($pommo->_baseDir . 'inc/classes/sql.gen.php'); $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'));