summaryrefslogtreecommitdiff
path: root/modules/taxonomy
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-07-07 21:06:27 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-07-07 21:06:27 -0700
commit7191d0649aefc23924a741a0d0151df7cc04ebc2 (patch)
treeba7048e8e91620e0f63c3add5477385bb3a06610 /modules/taxonomy
parent261b66d38c31a5888eee071623412cabbbeebcb5 (diff)
downloadbrdo-7191d0649aefc23924a741a0d0151df7cc04ebc2.tar.gz
brdo-7191d0649aefc23924a741a0d0151df7cc04ebc2.tar.bz2
Issue #949616 by catch, a.mikheychik, adamdicarlo, dixon_, anavarre: Fixed Multiple parent relations confirmation form loses term description.
Diffstat (limited to 'modules/taxonomy')
-rw-r--r--modules/taxonomy/taxonomy.admin.inc28
-rw-r--r--modules/taxonomy/taxonomy.test29
2 files changed, 29 insertions, 28 deletions
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index b0bb2a175..a236cfed1 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -674,9 +674,6 @@ function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary =
if (isset($form_state['confirm_delete'])) {
return array_merge($form, taxonomy_term_confirm_delete($form, $form_state, $term->tid));
}
- elseif (isset($form_state['confirm_parents'])) {
- return array_merge($form, taxonomy_term_confirm_parents($form, $form_state, $vocabulary));
- }
$form['name'] = array(
'#type' => 'textfield',
@@ -811,12 +808,6 @@ function taxonomy_form_term_submit($form, &$form_state) {
$form_state['confirm_delete'] = TRUE;
return;
}
- // Rebuild the form to confirm enabling multiple parents.
- elseif ($form_state['triggering_element']['#value'] == t('Save') && count($form_state['values']['parent']) > 1 && $form['#vocabulary']->hierarchy < 2) {
- $form_state['rebuild'] = TRUE;
- $form_state['confirm_parents'] = TRUE;
- return;
- }
$term = taxonomy_form_term_submit_build_taxonomy_term($form, $form_state);
@@ -873,25 +864,6 @@ function taxonomy_form_term_submit_build_taxonomy_term($form, &$form_state) {
}
/**
- * Form builder for the confirmation of multiple term parents.
- *
- * @ingroup forms
- * @see taxonomy_form_term()
- */
-function taxonomy_term_confirm_parents($form, &$form_state, $vocabulary) {
- foreach (element_children($form_state['values']) as $key) {
- $form[$key] = array(
- '#type' => 'value',
- '#value' => $form_state['values'][$key],
- );
- }
- $question = t('Set multiple term parents?');
- $description = '<p>' . t("Adding multiple parents to a term will cause the %vocabulary vocabulary to look for multiple parents on every term. Because multiple parents are not supported when using the drag and drop outline interface, drag and drop will be disabled if you enable this option. If you choose to have multiple parents, you will only be able to set parents by using the term edit form.", array('%vocabulary' => $vocabulary->name)) . '</p>';
- $description .= '<p>' . t("You may re-enable the drag and drop interface at any time by reducing multiple parents to a single parent for the terms in this vocabulary.") . '</p>';
- return confirm_form($form, $question, drupal_get_destination(), $description, t('Set multiple parents'));
-}
-
-/**
* Form builder for the term delete form.
*
* @ingroup forms
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 97cfe448f..80ddc849c 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -761,6 +761,35 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
}
/**
+ * Test saving a term with multiple parents through the UI.
+ */
+ function testTermMultipleParentsInterface() {
+ // Add a new term to the vocabulary so that we can have multiple parents.
+ $parent = $this->createTerm($this->vocabulary);
+
+ // Add a new term with multiple parents.
+ $edit = array(
+ 'name' => $this->randomName(12),
+ 'description[value]' => $this->randomName(100),
+ 'parent[]' => array(0, $parent->tid),
+ );
+ // Save the new term.
+ $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add', $edit, t('Save'));
+
+ // Check that the term was successfully created.
+ $terms = taxonomy_get_term_by_name($edit['name']);
+ $term = reset($terms);
+ $this->assertNotNull($term, t('Term found in database'));
+ $this->assertEqual($edit['name'], $term->name, t('Term name was successfully saved.'));
+ $this->assertEqual($edit['description[value]'], $term->description, t('Term description was successfully saved.'));
+ // Check that the parent tid is still there. The other parent (<root>) is
+ // not added by taxonomy_get_parents().
+ $parents = taxonomy_get_parents($term->tid);
+ $parent = reset($parents);
+ $this->assertEqual($edit['parent[]'][1], $parent->tid, t('Term parents were successfully saved.'));
+ }
+
+ /**
* Test taxonomy_get_term_by_name().
*/
function testTaxonomyGetTermByName() {