You are here

function vppr_form_admin_settings_vppr in Vocabulary Permissions Per Role 6

@file Vocabulary Permissions Per Role - administration UI

1 string reference to 'vppr_form_admin_settings_vppr'
vppr_menu in ./vppr.module
Implementation of hook_menu().

File

./vppr.admin.inc, line 8
Vocabulary Permissions Per Role - administration UI

Code

function vppr_form_admin_settings_vppr() {
  $form = array();
  $vocabs = taxonomy_get_vocabularies();
  $roles = user_roles(TRUE);

  // List of roles without 'anonymous'.
  $perms = variable_get('vppr_perms', array(
    array(),
  ));
  foreach ($vocabs as $vocab) {
    $form['vppr_vocabs'][$vocab->vid] = array(
      '#value' => $vocab->name,
    );
    foreach ($roles as $rid => $role) {
      $form['vppr_perms'][$vocab->vid][$rid] = array(
        '#type' => 'checkbox',
        '#default_value' => isset($perms[$vocab->vid]) && isset($perms[$vocab->vid][$rid]) ? $perms[$vocab->vid][$rid] : 0,
      );
    }
    $form['vppr_perms']['#tree'] = TRUE;
  }
  foreach ($roles as $rid => $role) {
    $form['vppr_roles'][$rid] = array(
      '#value' => $role,
    );
  }
  $form['help'] = array(
    '#type' => 'item',
    '#description' => t('Tick a box above to allow editing that vocabulary for that role.'),
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}