You are here

function sendinblue_signup_form_submit in SendinBlue 7

Same name and namespace in other branches
  1. 7.2 includes/sendinblue_signup.admin.inc \sendinblue_signup_form_submit()

Submit handler for sendinblue_signup_form().

File

includes/sendinblue_signup.admin.inc, line 343
Sendinblue_signup module admin settings.

Code

function sendinblue_signup_form_submit($form, &$form_state) {
  if (isset($form_state['signup'])) {
    $signup = $form_state['signup'];
    $prior_settings = $signup->settings;
    if (!$form_state['values']['wrap_left']['form']['mode'][SENDINBLUE_SIGNUP_PAGE]) {
      $form_state['values']['wrap_left']['form']['path'] = '';
    }
  }
  else {
    $signup = sendinblue_signup_create();
    $prior_settings = array();
  }
  $signup->title = $form_state['values']['wrap_left']['form']['title'];
  $signup->name = $form_state['values']['wrap_left']['form']['name'];
  $signup->mode = array_sum($form_state['values']['wrap_left']['form']['mode']);
  $signup->settings['description'] = $form_state['values']['wrap_left']['form']['description'];
  $signup->settings['path'] = $form_state['values']['wrap_left']['form']['path'];
  $signup->settings['fields'] = $form_state['values']['wrap_left']['fields'];
  $signup->settings['subscription'] = $form_state['values']['wrap_left']['subscription'];
  $signup->settings['fields']['mergefields'] = $_POST["wrap_left"]["fields"]["mergefields"];
  if ($signup
    ->save()) {
    if (isset($form_state['values']['wrap_left']['form']['path'])) {
      if (!isset($prior_settings['path']) || $prior_settings['path'] != $signup->settings['path'] || !($signup->mode & SENDINBLUE_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/system/sendinblue/signup';
  }
  else {
    drupal_set_message(t('There has been an error saving your signup form.'), 'error');
  }
}