Skip to content

Commit

Permalink
integration with term_merge module
Browse files Browse the repository at this point in the history
  • Loading branch information
tanius committed Jan 31, 2015
1 parent 4b4b4d2 commit e5ae01f
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions drupal_annotation/annotation.module
Original file line number Diff line number Diff line change
Expand Up @@ -377,24 +377,44 @@ function annotation_type_get_names() {
return $names;
}

/**
* Implements hook_term_merge() from term_merge module.
*
* @param object $term_trunk
* Fully loaded taxonomy term object of the term trunk, term into which
* merging occurs, aka 'destination'
* @param object $term_branch
* Fully loaded taxonomy term object of the term branch, term that is being
* merged, aka 'source'
* @param array $context
* Array $context as it is passed to term_merge_action() - you can get a
* little more info about context about merging from this array
*/
function annotation_term_merge($term_trunk, $term_branch, $context) {

// Update all branch term references to reference trunk term instead.
$altered = db_update('annotation')
->fields(array('tid' => $term_trunk->tid))
->condition('tid', $term_branch->tid)
->execute();
}

/**
* Implements hook_taxonomy_term_delete().
*/

function annotation_taxonomy_term_delete($term)
{
// remove all references to this term from the annotations table

$altered = db_update('annotation')
->fields(array('tid' => NULL))
->condition('tid', $term->tid)
->execute();

// delete annotations which now have neither tag nor comment
$deleted = db_delete('annotation')
->condition('tid', NULL)
->condition('text', '')
->execute();
function annotation_taxonomy_term_delete($term) {

// Remove all references to this term from the annotations table.
$altered = db_update('annotation')
->fields(array('tid' => NULL))
->condition('tid', $term->tid)
->execute();

// Delete annotations which now have neither tag nor comment.
$deleted = db_delete('annotation')
->condition('tid', NULL)
->condition('text', '')
->execute();
}

/**
Expand Down

0 comments on commit e5ae01f

Please sign in to comment.