Commit 520416d9 authored by Dries's avatar Dries

- In the taxonomy administration pages, the dropdown to select a term's
parent is supposed to exclude terms that are descendants of the current
term, to avoid creating cycles. However, the terms with the first few
term IDs are excluded instead.  Patch by JonBob.
parent 56e5c29b
......@@ -136,10 +136,12 @@ function _taxonomy_confirm_del_vocabulary($vid) {
function taxonomy_form_term($edit = array()) {
global $vocabulary_id;
if (!$vocabulary_id) {
$vocabulary_id = $edit["vid"];
}
$vocabulary = taxonomy_get_vocabulary($vocabulary_id);
$form = form_textfield(t("Term name"), "name", $edit["name"], 50, 64, t("Required") . ". " . t("The name for this term. Example: 'Linux'."));
$form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") . ". " . t("A description of the term."));
......@@ -147,13 +149,16 @@ function taxonomy_form_term($edit = array()) {
$form .= _taxonomy_term_select(t("Related terms"), "relations", array_keys(taxonomy_get_related($edit["tid"])), $vocabulary_id, t("Optional") . ". ", 1, "<" . t("none") . ">", array($edit["tid"]));
}
if ($vocabulary->hierarchy) {
$parent = array_keys(taxonomy_get_parents($edit["tid"]));
$children = taxonomy_get_tree($vocabulary_id, $edit["tid"]);
// you can't be son of yourself or your children
$exclude = array_keys($children);
// you can't be son of yourself nor of your children
foreach ($children as $child) {
$exclude[] = $child->tid;
}
$exclude[] = $edit["tid"];
if ($vocabulary->hierarchy == 1) {
$form .= _taxonomy_term_select(t("Parent"), "parent", $parent, $vocabulary_id, t("Required") . ". " . la(t("Parent term"), array("mod" => "taxonomy", "op" => "help"), "parent") .".", 0, "<" . t("root") . ">", $exclude);
}
......
......@@ -136,10 +136,12 @@ function _taxonomy_confirm_del_vocabulary($vid) {
function taxonomy_form_term($edit = array()) {
global $vocabulary_id;
if (!$vocabulary_id) {
$vocabulary_id = $edit["vid"];
}
$vocabulary = taxonomy_get_vocabulary($vocabulary_id);
$form = form_textfield(t("Term name"), "name", $edit["name"], 50, 64, t("Required") . ". " . t("The name for this term. Example: 'Linux'."));
$form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") . ". " . t("A description of the term."));
......@@ -147,13 +149,16 @@ function taxonomy_form_term($edit = array()) {
$form .= _taxonomy_term_select(t("Related terms"), "relations", array_keys(taxonomy_get_related($edit["tid"])), $vocabulary_id, t("Optional") . ". ", 1, "<" . t("none") . ">", array($edit["tid"]));
}
if ($vocabulary->hierarchy) {
$parent = array_keys(taxonomy_get_parents($edit["tid"]));
$children = taxonomy_get_tree($vocabulary_id, $edit["tid"]);
// you can't be son of yourself or your children
$exclude = array_keys($children);
// you can't be son of yourself nor of your children
foreach ($children as $child) {
$exclude[] = $child->tid;
}
$exclude[] = $edit["tid"];
if ($vocabulary->hierarchy == 1) {
$form .= _taxonomy_term_select(t("Parent"), "parent", $parent, $vocabulary_id, t("Required") . ". " . la(t("Parent term"), array("mod" => "taxonomy", "op" => "help"), "parent") .".", 0, "<" . t("root") . ">", $exclude);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment