You are here

function tac_lite_admin_settings in Taxonomy Access Control Lite 7

Same name and namespace in other branches
  1. 5 tac_lite.module \tac_lite_admin_settings()
  2. 6 tac_lite.module \tac_lite_admin_settings()

Returns the settings form

1 string reference to 'tac_lite_admin_settings'
tac_lite_menu in ./tac_lite.module
Implementation of hook_menu().

File

./tac_lite.module, line 100
Control access to site content based on taxonomy, roles and users.

Code

function tac_lite_admin_settings($form, &$form_state) {
  $vocabularies = taxonomy_get_vocabularies();
  if (!count($vocabularies)) {
    $form['body'] = array(
      '#type' => 'markup',
      '#markup' => t('You must <a href="!url">create a vocabulary</a> before you can use tac_lite.', array(
        '!url' => url('admin/structure/taxonomy/add/vocabulary'),
      )),
    );
    return $form;
  }
  else {
    $options = array();
    foreach ($vocabularies as $vid => $vocab) {
      $options[$vid] = $vocab->name;
    }
    $form['tac_lite_categories'] = array(
      '#type' => 'select',
      '#title' => t('Vocabularies'),
      '#default_value' => variable_get('tac_lite_categories', NULL),
      '#options' => $options,
      '#description' => t('Select one or more vocabularies to control privacy.  <br/>Use caution with hierarchical (nested) taxonomies as <em>visibility</em> settings may cause problems on node edit forms.<br/>Do not select free tagging vocabularies, they are not supported.'),
      '#multiple' => TRUE,
      '#required' => TRUE,
    );
    $scheme_options = array();

    // Currently only view, edit, delete permissions possible, so 7
    // permutations will be more than enough.
    for ($i = 1; $i < 8; $i++) {
      $scheme_options[$i] = $i;
    }
    $form['tac_lite_schemes'] = array(
      '#type' => 'select',
      '#title' => t('Number of Schemes'),
      '#description' => t('Each scheme allows for a different set of permissions.  For example, use scheme 1 for read-only permission; scheme 2 for read and update; scheme 3 for delete; etc.  Additional schemes increase the size of your node_access table, so use no more than you need.'),
      '#default_value' => variable_get('tac_lite_schemes', 1),
      '#options' => $scheme_options,
      '#required' => TRUE,
    );
    $form['tac_lite_rebuild'] = array(
      '#type' => 'checkbox',
      '#title' => t('Rebuild content permissions now'),
      '#default_value' => FALSE,
      // default false because usually only needed after scheme has been changed.
      '#description' => t('Do this once, after you have fully configured access by taxonomy.'),
      '#weight' => 9,
    );
    $ret = system_settings_form($form);

    // Special handling is required when this form is submitted.
    $ret['#submit'][] = '_tac_lite_admin_settings_submit';
    return $ret;
  }
}