function simplenews_admin_category_form_submit in Simplenews 7
Form submit callback for a newsletter category form.
File
- includes/
simplenews.admin.inc, line 626 - Newsletter admin, subscription admin, simplenews settings
Code
function simplenews_admin_category_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']['tid'] . '/delete';
return;
}
$category = (object) $form_state['values'];
// Create or update taxonomy term.
$term = new stdClass();
$term->tid = $form_state['values']['tid'];
$term->vocabulary_machine_name = 'newsletter';
$term->vid = taxonomy_vocabulary_machine_name_load('newsletter')->vid;
$term->name = $form_state['values']['name'];
$term->description = $form_state['values']['description'];
$term->weight = $form_state['values']['weight'];
taxonomy_term_save($term);
$category->tid = $term->tid;
switch (simplenews_category_save($category)) {
case SAVED_NEW:
drupal_set_message(t('Created new newsletter category %name.', array(
'%name' => _simplenews_newsletter_name($category),
)));
watchdog('simplenews', 'Created new newsletter category %name.', array(
'%name' => _simplenews_newsletter_name($category),
WATCHDOG_NOTICE,
l(t('edit'), 'admin/config/services/simplenews/categories/' . $category->tid . '/edit'),
));
break;
case SAVED_UPDATED:
drupal_set_message(t('Updated newsletter category %name.', array(
'%name' => _simplenews_newsletter_name($category),
)));
watchdog('simplenews', 'Updated newsletter category %name.', array(
'%name' => _simplenews_newsletter_name($category),
), WATCHDOG_NOTICE, l(t('edit'), 'admin/config/services/simplenews/categories/' . $category->tid . '/edit'));
break;
}
$form_state['values']['tid'] = $category->tid;
$form_state['tid'] = $category->tid;
$form_state['redirect'] = 'admin/config/services/simplenews';
}