function mailchimp_signup_form_submit in Mailchimp 7.3
Same name and namespace in other branches
- 7.5 modules/mailchimp_signup/includes/mailchimp_signup.admin.inc \mailchimp_signup_form_submit()
- 7.4 modules/mailchimp_signup/includes/mailchimp_signup.admin.inc \mailchimp_signup_form_submit()
Submit handler for mailchimp_signup_form().
File
- modules/
mailchimp_signup/ includes/ mailchimp_signup.admin.inc, line 234 - mailchimp_signup module admin settings.
Code
function mailchimp_signup_form_submit($form, &$form_state) {
if (isset($form_state['signup'])) {
$signup = $form_state['signup'];
$prior_settings = $signup->settings;
if (!$form_state['values']['mode'][MAILCHIMP_SIGNUP_PAGE]) {
$form_state['values']['settings']['path'] = '';
}
}
else {
$signup = mailchimp_signup_create();
$prior_settings = array();
}
$mergefields = $form_state['values']['mergefields'];
foreach ($mergefields as $id => $val) {
if ($val) {
$mergefields[$id] = $form_state['mergevar_options'][$id];
}
}
$signup->title = $form_state['values']['title'];
$signup->name = $form_state['values']['name'];
$signup->mode = array_sum($form_state['values']['mode']);
$signup->mc_lists = array_filter($form_state['values']['mc_lists']);
$signup->settings = $form_state['values']['settings'];
$signup->settings['mergefields'] = $mergefields;
$signup->settings['description'] = $form_state['values']['description'];
$signup->settings['doublein'] = $form_state['values']['doublein'];
$signup->settings['send_welcome'] = $form_state['values']['send_welcome'];
$signup->settings['include_interest_groups'] = $form_state['values']['include_interest_groups'];
if ($signup
->save()) {
if (isset($form_state['values']['settings']['path'])) {
if (!isset($prior_settings['path']) || $prior_settings['path'] != $signup->settings['path'] || !($signup->mode & MAILCHIMP_SIGNUP_PAGE)) {
// We have a new (or removed) path. Rebuild menus.
menu_rebuild();
}
}
// update i18n translation sources
$language = language_default('language');
$t_strings = array(
'title',
'name',
'description',
);
foreach ($t_strings as $key) {
mailchimp_signup_tt("field:mailchimp_signup:form:{$signup->mcs_id}:{$key}", $form_state['values'][$key], $language, TRUE);
}
foreach ($mergefields as $id => $val) {
mailchimp_signup_tt("field:mailchimp_signup:form:{$signup->mcs_id}:mergefield:{$id}", $val['name'], $language, TRUE);
}
mailchimp_signup_tt("field:mailchimp_signup:form:{$signup->mcs_id}:confirmation_message", $form_state['values']['settings']['confirmation_message'], $language, TRUE);
mailchimp_signup_tt("field:mailchimp_signup:form:{$signup->mcs_id}:submit_button", $form_state['values']['settings']['submit_button'], $language, TRUE);
drupal_set_message(t('Signup form @name has been saved.', array(
'@name' => $signup->name,
)));
$form_state['redirect'] = 'admin/config/services/mailchimp/signup';
}
else {
drupal_set_message(t('There has been an error saving your signup form.'), 'error');
}
}