diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-01-04 23:58:27 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-01-04 23:58:27 +0000 |
commit | 520416d97752fb111dc0ca7132c0c949fba86944 (patch) | |
tree | dba2b3bdfca10323e3b688125ca56a80f2e8b06e | |
parent | 56e5c29b40c7d926433c07e7bedb8f928a448997 (diff) | |
download | brdo-520416d97752fb111dc0ca7132c0c949fba86944.tar.gz brdo-520416d97752fb111dc0ca7132c0c949fba86944.tar.bz2 |
- 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.
-rw-r--r-- | modules/taxonomy.module | 11 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 11 |
2 files changed, 16 insertions, 6 deletions
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); } |