You are here

function tft_archive_file_form in Taxonomy File Tree 7.2

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

Form callback: archive a node form.

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

File

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

Code

function tft_archive_file_form($form, $form_state, $nid) {
  $node = node_load($nid);
  $redirect = FALSE;
  if (!node_access('update', $node)) {
    drupal_set_message(t("You cannot edit this file."), 'error');
    $redirect = TRUE;
  }
  elseif (empty($node->{"taxonomy_vocabulary_" . variable_get('tft_vocabulary_vid', 0)})) {
    drupal_set_message(t("This file is not part of any tree. You cannot archive it."), '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 file @title ?", array(
    '@title' => $node->title,
  )));
  $form['#node'] = $node;
  $form['name'] = array(
    '#type' => 'hidden',
    '#value' => $node->title,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t("Archive"),
  );
  $form['cancel'] = array(
    '#markup' => '<a href="/' . str_replace('%23', '#', $_GET['destination']) . '">' . t("cancel") . '</a>',
  );
  return $form;
}