function community_tags_community_tags_tags_removed in Community Tags 6.2
Implementation of hook_community_tags_tags_removed(). Remove redundant terms if configured to do so.
File
- ./
community_tags.module, line 741 - Implements community tagging of nodes using a specific vocabulary for Drupal v6.x
Code
function community_tags_community_tags_tags_removed($node, $user, $terms, $source, $removed_tags, $tags_removed_count) {
// check source for batch tag removal with term sync disabled
if ($source == 'community_tags:purge:no_sync') {
return;
}
// delete redundant terms
// only apply if content type/node type allows
$ctags_by_type = community_tags_tags_group_by($removed_tags, 'type');
foreach ($ctags_by_type as $type => $ctags_for_type) {
// now group by vid as logic depends on combination of vid and node type
$ctags_for_type_by_vid = community_tags_tags_group_by($ctags_for_type, 'vid');
foreach ($ctags_for_type_by_vid as $vid => $ctags_for_type_and_vid) {
if (_community_tags_is_opmode(COMMUNITY_TAGS_OPMODE_DELETE_ORPHAN_TERMS, $vid, $type)) {
// get the unique set of terms to cleanup
$ctags_for_type_and_vid_by_tid = community_tags_tags_group_by($ctags_for_type_and_vid, 'tid');
// @todo make sure this isn't too onerous - we're probably in an AJAX call here...
$tids = array_keys($ctags_for_type_and_vid_by_tid);
_community_tags_cleanup_orphaned_tags_by_tids($tids);
}
}
}
}