You are here

function simplenews_admin_categories in Simplenews 7.2

Same name and namespace in other branches
  1. 7 includes/simplenews.admin.inc \simplenews_admin_categories()

Menu callback: list admin form with list of available list categories.

See also

simplenews_admin_newsletter_categories_submit()

theme_simplenews_admin_newsletter_categories()

1 string reference to 'simplenews_admin_categories'
simplenews_menu in ./simplenews.module
Implements hook_menu().

File

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

Code

function simplenews_admin_categories() {
  $form['#tree'] = TRUE;
  if ($newsletters = entity_load('simplenews_newsletter')) {
    foreach ($newsletters as $newsletter) {
      $form[$newsletter->newsletter_id]['#newsletter'] = $newsletter;
      $form[$newsletter->newsletter_id]['name'] = array(
        '#markup' => check_plain($newsletter->name),
      );
      $form[$newsletter->newsletter_id]['weight'] = array(
        '#type' => 'weight',
        '#delta' => 10,
        '#default_value' => $newsletter->weight,
      );
      $form[$newsletter->newsletter_id]['edit'] = array(
        '#type' => 'link',
        '#title' => t('edit newsletter'),
        '#href' => "admin/config/services/simplenews/categories/{$newsletter->newsletter_id}/edit",
      );
    }
  }

  // Only make this form include a submit button and weight if more than one
  // newsletter exists.
  if (count($newsletters) > 1) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
    );
  }
  elseif (!empty($newsletters)) {
    $form[$newsletter->newsletter_id]['weight'] = array(
      '#type' => 'value',
      '#value' => 0,
    );
  }
  return $form;
}