From 520416d97752fb111dc0ca7132c0c949fba86944 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 4 Jan 2003 23:58:27 +0000 Subject: - 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. --- modules/taxonomy.module | 11 ++++++++--- modules/taxonomy/taxonomy.module | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 9c6f051ad..6cb25f59b 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -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); } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 9c6f051ad..6cb25f59b 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -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); } -- cgit v1.2.3