summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-04 06:50:07 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-04 06:50:07 +0000
commitbc37b6dc0ede6ae3f6ef26cf06a006ab92c4b7c3 (patch)
tree66850826b7afdd1e646f84281e00d10edc465909 /modules
parentc7824035b448bf6887fa6a243db8d76aede2fd98 (diff)
downloadbrdo-bc37b6dc0ede6ae3f6ef26cf06a006ab92c4b7c3.tar.gz
brdo-bc37b6dc0ede6ae3f6ef26cf06a006ab92c4b7c3.tar.bz2
#526120 by catch: Remove the related terms feature from Taxonomy module. This can now be accomplished with Field API.
Diffstat (limited to 'modules')
-rw-r--r--modules/taxonomy/taxonomy.admin.inc7
-rw-r--r--modules/taxonomy/taxonomy.install50
-rw-r--r--modules/taxonomy/taxonomy.module42
-rw-r--r--modules/taxonomy/taxonomy.test24
4 files changed, 13 insertions, 110 deletions
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index 6734e339a..a3cf56644 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -114,7 +114,6 @@ function taxonomy_form_vocabulary(&$form_state, $edit = array()) {
'help' => '',
'nodes' => array(),
'hierarchy' => 0,
- 'relations' => 0,
'tags' => 0,
'multiple' => 0,
'required' => 0,
@@ -188,11 +187,6 @@ function taxonomy_form_vocabulary(&$form_state, $edit = array()) {
'#type' => 'value',
'#value' => '0',
);
- // Enable "related terms" by default.
- $form['relations'] = array(
- '#type' => 'value',
- '#value' => '1',
- );
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
if (isset($edit['vid'])) {
@@ -745,7 +739,6 @@ function taxonomy_form_term(&$form_state, $vocabulary, $edit = array()) {
$exclude[] = $edit['tid'];
$form['advanced']['parent'] = _taxonomy_term_select(t('Parents'), $parent, $vocabulary->vid, t('Parent terms') . '.', 1, '<' . t('root') . '>', $exclude);
- $form['advanced']['relations'] = _taxonomy_term_select(t('Related terms'), array_keys(taxonomy_get_related($edit['tid'])), $vocabulary->vid, NULL, 1, '<' . t('none') . '>', array($edit['tid']));
}
$form['advanced']['synonyms'] = array(
'#type' => 'textarea',
diff --git a/modules/taxonomy/taxonomy.install b/modules/taxonomy/taxonomy.install
index 40b1be298..807c93375 100644
--- a/modules/taxonomy/taxonomy.install
+++ b/modules/taxonomy/taxonomy.install
@@ -140,43 +140,6 @@ function taxonomy_schema() {
),
'primary key' => array('tid', 'vid'),
);
-
- $schema['taxonomy_term_relation'] = array(
- 'description' => 'Stores non-hierarchical relationships between terms.',
- 'fields' => array(
- 'trid' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Primary Key: Unique term relation ID.',
- ),
- 'tid1' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The {taxonomy_term_data}.tid of the first term in a relationship.',
- ),
- 'tid2' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The {taxonomy_term_data}.tid of the second term in a relationship.',
- ),
- ),
- 'unique keys' => array(
- 'tid1_tid2' => array('tid1', 'tid2'),
- ),
- 'indexes' => array(
- 'tid2' => array('tid2'),
- ),
- 'foreign keys' => array(
- 'tid1' => array('taxonomy_term_data' => 'tid'),
- 'tid2' => array('taxonomy_term_data' => 'tid'),
- ),
- 'primary key' => array('trid'),
- );
-
$schema['taxonomy_term_synonym'] = array(
'description' => 'Stores term synonyms.',
'fields' => array(
@@ -362,3 +325,16 @@ function taxonomy_update_7002() {
}
return $ret;
}
+
+/**
+ * Remove the related terms setting from vocabularies.
+ *
+ * This setting has not been used since Drupal 6. The {taxonomy_relations} table
+ * itself is retained to allow for data to be upgraded.
+ */
+function taxonomy_update_7003() {
+ $ret = array();
+ db_drop_field($ret, 'taxonomy_vocabulary', 'relations');
+
+ return $ret;
+}
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 812b43c65..578293eba 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -436,25 +436,6 @@ function taxonomy_term_save($term) {
module_invoke_all('taxonomy_term_insert', $term);
}
- db_delete('taxonomy_term_relation')
- ->condition(db_or()
- ->condition('tid1', $term->tid)
- ->condition('tid2', $term->tid)
- )
- ->execute();
-
- if (!empty($term->relations)) {
- foreach ($term->relations as $related_id) {
- if ($related_id != 0) {
- db_insert('taxonomy_term_relation')
- ->fields(array(
- 'tid1' => $term->tid,
- 'tid2' => $related_id
- ))
- ->execute();
- }
- }
- }
db_delete('taxonomy_term_hierarchy')
->condition('tid', $term->tid)
->execute();
@@ -545,12 +526,6 @@ function taxonomy_term_delete($tid) {
db_delete('taxonomy_term_hierarchy')
->condition('tid', $tid)
->execute();
- db_delete('taxonomy_term_relation')
- ->condition(db_or()
- ->condition('tid1', $tid)
- ->condition('tid2', $tid)
- )
- ->execute();
db_delete('taxonomy_term_synonym')
->condition('tid', $tid)
->execute();
@@ -974,23 +949,6 @@ function taxonomy_node_type($op, $info) {
}
/**
- * Find all term objects related to a given term ID.
- */
-function taxonomy_get_related($tid, $key = 'tid') {
- if ($tid) {
- $result = db_query('SELECT t.*, tid1, tid2 FROM {taxonomy_term_relation}, {taxonomy_term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = :tid1 OR tid2 = :tid2) AND t.tid != :tid ORDER BY weight, name', array(':tid' => $tid, ':tid1' => $tid, ':tid2' => $tid));
- $related = array();
- foreach ($result as $term) {
- $related[$term->$key] = $term;
- }
- return $related;
- }
- else {
- return array();
- }
-}
-
-/**
* Find all parents of a given term ID.
*/
function taxonomy_get_parents($tid, $key = 'tid') {
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 89e3912db..3d20928a3 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -395,30 +395,6 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
}
/**
- * Test related terms.
- */
- function testTaxonomyTermRelations() {
- // Create two taxonomy terms.
- $term1 = $this->createTerm($this->vocabulary);
- $term2 = $this->createTerm($this->vocabulary);
-
- // Edit $term1 and add $term2 as a relationship.
- $edit = array();
- $edit['relations[]'] = $term2->tid;
- $this->drupalPost('taxonomy/term/' . $term1->tid . '/edit', $edit, t('Save'));
- $related = taxonomy_get_related($term1->tid);
- $this->assertTrue(isset($related[$term2->tid]), t('Related term was found'));
- // Create a third term.
- $term3 = $this->createTerm($this->vocabulary);
- $edit['relations[]'] = $term3->tid;
- $this->drupalPost('taxonomy/term/' . $term1->tid . '/edit', $edit, t('Save'));
-
- $related = taxonomy_get_related($term1->tid);
- $this->assertTrue(isset($related[$term3->tid]), t('Related term was found'));
- $this->assertFalse(isset($related[$term2->tid]), t('Term relationship no longer exists'));
- }
-
- /**
* Test synonyms.
*/
function testTaxonomySynonyms() {