You are here

function nat_sync_form in Node Auto Term [NAT] 5

Same name and namespace in other branches
  1. 6.2 nat.admin.inc \nat_sync_form()
  2. 6 nat.admin.inc \nat_sync_form()
  3. 7.2 nat.admin.inc \nat_sync_form()
  4. 7 nat.admin.inc \nat_sync_form()

Sync the NAT table with the node table for associated vocabularies.

1 string reference to 'nat_sync_form'
nat_menu in ./nat.module
Implementation of hook_menu().

File

./nat.module, line 274
NAT - node auto term - is a helper module that automatically creates a term using the same title as a node.

Code

function nat_sync_form() {
  $vocabularies = _nat_get_vocabularies();
  if (empty($vocabularies)) {
    drupal_set_message(t('The NAT module requires at least one vocabulary to be defined.'), 'error');
    drupal_goto('admin/content/taxonomy');
  }
  $nat_config = _nat_variable_get();
  $options = array();
  foreach ($nat_config['types'] as $type => $associations) {
    if (!empty($associations)) {
      foreach ($associations as $vid) {
        $options[$type . '|' . $vid] = t('@type ‹-› !vocabulary', array(
          '@type' => $type,
          '!vocabulary' => $vocabularies[$vid],
        ));
      }
    }
  }
  if (empty($options)) {
    drupal_set_message(t('There are no vocabularies available to sync.'));
    drupal_goto('admin/settings/nat');
  }
  $form['sync'] = array(
    '#type' => 'fieldset',
    '#title' => t('Sync associations'),
    '#description' => t('The Sync operation will create NAT associations (and terms) for nodes (marked for NAT association) not present in the NAT table.'),
    '#collapsible' => TRUE,
  );
  $form['sync']['vocabularies'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select the vocabularies to sync with associated node tables'),
    '#description' => t('Any nodes not already NAT associated with the selected vocabularies will be associated.'),
    '#required' => TRUE,
    '#options' => $options,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Sync tables'),
  );
  return $form;
}