You are here

function subscriptions_taxonomy_form_alter in Subscriptions 5.2

Implementation of hook_form_alter().

Adds the Taxonomy Settings part to admin/settings/subscriptions.

File

./subscriptions_taxonomy.module, line 136
Subscriptions to taxonomy terms.

Code

function subscriptions_taxonomy_form_alter($form_id, &$form) {
  global $user;
  $tr = 't';
  if ($form_id == 'subscriptions_settings_form') {
    $form['taxonomy'] = array(
      '#type' => 'fieldset',
      '#title' => t('Taxonomy settings'),
      '#collapsible' => TRUE,
      '#weight' => -8,
    );
    $vocabularies = taxonomy_get_vocabularies();
    $select[0] = '<' . t('none') . '>';
    foreach ($vocabularies as $vocabulary) {
      $select[$vocabulary->vid] = $vocabulary->name;
    }
    $form['taxonomy']['subscriptions_restricted_taxa'] = array(
      '#type' => 'select',
      '#title' => t('Restricted vocabularies'),
      '#default_value' => variable_get('subscriptions_restricted_taxa', array()),
      '#options' => $select,
      '#description' => t('Select vocabularies for which only the subscribed terms should be listed on the %Subscriptions | %Categories page.<br />This helps to reduce the size of the listing, especially for free-tagging vocabularies with large numbers of terms.', array(
        '%Subscriptions' => t('Subscriptions'),
        '%Categories' => $tr('Categories'),
      )),
      '#multiple' => TRUE,
    );
    $form['taxonomy']['subscriptions_omitted_taxa'] = array(
      '#type' => 'select',
      '#title' => t('Omitted vocabularies'),
      '#default_value' => variable_get('subscriptions_omitted_taxa', array()),
      '#options' => $select,
      '#description' => t('Select vocabularies which should be <strong>omitted</strong> from subscription listings; this means the terms of those vocabularies will be unlisted, i.e. they will be removed from subscription listings.<br />The content may still be available for subscribing via different kinds of subscriptions, but subscribing by category will be unavailable for the terms in the selected vocabularies.'),
      '#multiple' => TRUE,
    );

    // @ TODO write the code that supports this setting

    /*
    $form['taxonomy']['subscriptions_allow_vid'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow vocabularies subscription'),
      '#default_value' => variable_get('subscriptions_allow_vid', 1),
      '#description' => t('Allow users to subscribe to an entire vocabluary of terms.'),
    );
    */
  }
}