function tft_edit_term_form in Taxonomy File Tree 7.2
Same name and namespace in other branches
- 7 tft.admin.inc \tft_edit_term_form()
Form: edit a term.
1 string reference to 'tft_edit_term_form'
- tft_menu in ./
tft.module - Implementation of hook_menu().
File
- includes/
tft.pages.inc, line 183 - Defines all page callbacks for TFT.
Code
function tft_edit_term_form($form, $form_state, $tid) {
global $user;
if (!tft_term_access($tid, $user, 'edit')) {
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();
}
}
// @todo OG logic !!
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 contact the 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"),
);
$parts = explode('#', str_replace('%23', '#', $_GET['destination']));
$form['cancel'] = array(
'#markup' => l(t("cancel"), $parts[0], array(
'attributes' => array(
'class' => array(
'tft-cancel-button',
),
),
'fragment' => isset($parts[1]) ? $parts[1] : '',
)),
);
return $form;
}