Commit bc37b6dc authored by webchick's avatar webchick

#526120 by catch: Remove the related terms feature from Taxonomy module. This...

#526120 by catch: Remove the related terms feature from Taxonomy module. This can now be accomplished with Field API.
parent c7824035
......@@ -27,6 +27,8 @@ Drupal 7.0, xxxx-xx-xx (development version)
* Removed comment controls for users.
* Removed display order settings for comment module. Comment display
order can now be customised using the Views module.
* Removed the 'related terms' feature from taxonomy module since this can
now be achieved with Field API.
* Added additional features to the default install profile, and implemented
a "slimmed down" install profile designed for developers.
* Added an administrator role which is assigned all permisions for
......
......@@ -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',
......
......@@ -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;
}
......@@ -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();
......@@ -973,23 +948,6 @@ function taxonomy_node_type($op, $info) {
drupal_static_reset('taxonomy_term_count_nodes');
}
/**
* 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.
*/
......
......@@ -394,30 +394,6 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
$this->vocabulary = $this->createVocabulary();
}
/**
* 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.
*/
......
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