function mailchimp_signup_form_submit in Mailchimp 7.4
Same name and namespace in other branches
- 7.5 modules/mailchimp_signup/includes/mailchimp_signup.admin.inc \mailchimp_signup_form_submit()
- 7.3 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 233 - 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['include_interest_groups'] = $form_state['values']['include_interest_groups'];
$signup->settings['placeholder'] = $form_state['values']['placeholder'];
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();
}
}
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');
}
}