You are here

function simplenews_admin_newsletter_form_submit in Simplenews 7.2

Form submit callback for a newsletter form.

File

includes/simplenews.admin.inc, line 610
Newsletter admin, subscription admin, simplenews settings

Code

function simplenews_admin_newsletter_form_submit($form, &$form_state) {

  //dpm($form_state);
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  if ($op == t('Delete')) {
    $form_state['redirect'] = 'admin/config/services/simplenews/categories/' . $form_state['values']['newsletter_id'] . '/delete';
    return;
  }
  $newsletter = $form_state['newsletter'];
  entity_form_submit_build_entity('simplenews_newsletter', $newsletter, $form, $form_state);
  switch (simplenews_newsletter_save($newsletter)) {
    case SAVED_NEW:
      drupal_set_message(t('Created new newsletter %name.', array(
        '%name' => $newsletter->name,
      )));
      watchdog('simplenews', 'Created new newsletter %name.', array(
        '%name' => $newsletter->name,
        WATCHDOG_NOTICE,
        l(t('edit'), 'admin/config/services/simplenews/categories/' . $newsletter->newsletter_id . '/edit'),
      ));
      break;
    case SAVED_UPDATED:
      drupal_set_message(t('Updated newsletter %name.', array(
        '%name' => $newsletter->name,
      )));
      watchdog('simplenews', 'Updated newsletter %name.', array(
        '%name' => $newsletter->name,
      ), WATCHDOG_NOTICE, l(t('edit'), 'admin/config/services/simplenews/categories/' . $newsletter->newsletter_id . '/edit'));
      break;
  }
  $form_state['values']['newsletter_id'] = $newsletter->newsletter_id;
  $form_state['newsletter_id'] = $newsletter->newsletter_id;
  $form_state['redirect'] = 'admin/config/services/simplenews';
}