You are here

function tft_edit_term_form in Taxonomy File Tree 7

Same name and namespace in other branches
  1. 7.2 includes/tft.pages.inc \tft_edit_term_form()

Edit a term form.

1 string reference to 'tft_edit_term_form'
tft_menu in ./tft.module
Implementation of hook_menu().

File

./tft.admin.inc, line 425

Code

function tft_edit_term_form($form, $form_state, $tid) {

  // Check that a vocabulary is set for Taxonomy File Tree
  tft_check_vocabulary_setting();
  if (!tft_term_access($tid)) {
    drupal_set_message(t("You do not have access to this folder. You cannot modify or delete it."), 'error');
    if ($destination = str_replace('%23', '#', $_GET['destination'])) {
      drupal_goto($destination);
    }
    else {
      drupal_goto();
    }
  }
  if (tft_is_archive_folder($tid)) {
    drupal_set_message(t("Archive folders cannot be edited."), 'error');
    if ($destination = str_replace('%23', '#', $_GET['destination'])) {
      drupal_goto($destination);
    }
    else {
      drupal_goto();
    }
  }
  $name = db_query("SELECT name FROM {taxonomy_term_data} WHERE tid = :tid", array(
    ':tid' => $tid,
  ))
    ->fetchField();

  // If no name was found
  if (!$name) {
    drupal_set_message(t("An error occured. The '@tid' folder could not be found. Please contac tthe site administrator.", array(
      '@tid' => $tid,
    )), 'error');
    if ($destination = str_replace('%23', '#', $_GET['destination'])) {
      drupal_goto($destination);
    }
    else {
      drupal_goto();
    }
  }
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t("Name"),
    '#required' => TRUE,
    '#default_value' => $name,
    '#weight' => -10,
  );
  $form['tid'] = array(
    '#type' => 'hidden',
    '#value' => $tid,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t("Save"),
  );
  $form['cancel'] = array(
    '#value' => '<a href="/' . str_replace('%23', '#', $_GET['destination']) . '">' . t("cancel") . '</a>',
  );
  return $form;
}