You are here

function tft_taxonomy_access_access_form in Taxonomy File Tree 7.2

Form callback: access control form.

1 string reference to 'tft_taxonomy_access_access_form'
tft_taxonomy_access_menu in modules/tft_taxonomy_access/tft_taxonomy_access.module
Implements hook_menu().

File

modules/tft_taxonomy_access/tft_taxonomy_access.module, line 114
Taxonomy Access integration.

Code

function tft_taxonomy_access_access_form($form, $form_state, $tid) {
  $parts = explode('#', str_replace('%23', '#', !empty($_GET['destination']) ? $_GET['destination'] : ''));
  $form['actions']['cancel'] = array(
    '#markup' => l(t("cancel"), $parts[0], array(
      'attributes' => array(
        'class' => array(
          'tft-cancel-button',
        ),
      ),
      'fragment' => isset($parts[1]) ? $parts[1] : '',
    )),
  );
  if (!$tid) {
    drupal_set_message(t("You cannot set any access rules for the root folder. If you want to prevent people to access any files, remove the <em>Access file tree</em> permission."));
    return $form;
  }
  else {
    $form['tid'] = array(
      '#type' => 'value',
      '#value' => $tid,
    );
    $form['grants']['#tree'] = TRUE;
    $roles = _taxonomy_access_user_roles();
    $active_rids = db_query('SELECT rid FROM {taxonomy_access_default} WHERE vid = 0')
      ->fetchCol();
    foreach ($active_rids as $rid) {
      $form['grants'][$rid]['#tree'] = TRUE;
      $form['grants'][$rid]['view'] = array(
        '#title' => t("Allow %role to view folder", array(
          '%role' => $roles[$rid],
        )),
        '#type' => 'checkbox',
        '#default_value' => tft_taxonomy_access_load_term_grant('view', $tid, $rid),
      );
      $form['grants'][$rid]['update'] = array(
        '#title' => t("Allow %role to edit folder", array(
          '%role' => $roles[$rid],
        )),
        '#type' => 'checkbox',
        '#default_value' => tft_taxonomy_access_load_term_grant('update', $tid, $rid),
      );
      $form['grants'][$rid]['delete'] = array(
        '#title' => t("Allow %role to delete folder", array(
          '%role' => $roles[$rid],
        )),
        '#type' => 'checkbox',
        '#default_value' => tft_taxonomy_access_load_term_grant('delete', $tid, $rid),
      );
    }
    $form['actions']['#weight'] = 100;
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t("Save"),
      '#weight' => -10,
    );
    return $form;
  }
}