You are here

function tft_archive_term_form in Taxonomy File Tree 7.2

Same name and namespace in other branches
  1. 7 tft.admin.inc \tft_archive_term_form()

Form callback: archive a term form.

1 string reference to 'tft_archive_term_form'
tft_archive_menu in modules/tft_archive/tft_archive.module
Implements hook_menu().

File

modules/tft_archive/includes/tft_archive.pages.inc, line 35
Page and form callbacks.

Code

function tft_archive_term_form($form, $form_state, $tid) {
  $redirect = FALSE;
  if (!tft_term_access($tid)) {
    drupal_set_message(t("You do not have access to this folder. You cannot edit or delete it."), 'error');
    $redirect = TRUE;
  }
  elseif (tft_archive_is_archive_folder($tid)) {
    drupal_set_message(t("Archive folders cannot be archived."), 'error');
    $redirect = TRUE;
  }
  $name = db_query("SELECT name FROM {taxonomy_term_data} WHERE tid = :tid", array(
    ':tid' => $tid,
  ))
    ->fetchField();
  if (!$name) {
    drupal_set_message(t("An error occured. The '@tid' folder could not be found. Please contact the site administrator.", array(
      '@tid' => $tid,
    )), 'error');
    $redirect = TRUE;
  }
  if ($redirect) {
    if ($destination = str_replace('%23', '#', $_GET['destination'])) {
      drupal_goto($destination);
    }
    else {
      drupal_goto();
    }
  }
  drupal_set_title(t("Are you sure you want to archive folder @term ?", array(
    '@term' => $name,
  )));
  $form['tid'] = array(
    '#type' => 'hidden',
    '#value' => $tid,
  );
  $form['name'] = array(
    '#type' => 'hidden',
    '#value' => $name,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t("Archive"),
  );
  $form['cancel'] = array(
    '#markup' => '<a href="/' . str_replace('%23', '#', $_GET['destination']) . '">' . t("cancel") . '</a>',
  );
  return $form;
}