function flag_node_translation_change in Flag 7.2
Same name and namespace in other branches
- 7.3 flag.module \flag_node_translation_change()
Implements hook_node_translation_change().
(Hook provided by translation_helpers module.)
File
- ./
flag.module, line 707 - The Flag module.
Code
function flag_node_translation_change($node) {
if (isset($node->translation_change)) {
// If there is only one node remaining, track by nid rather than tnid.
// Otherwise, use the new tnid.
$content_id = $node->translation_change['new_tnid'] == 0 ? $node->translation_change['remaining_nid'] : $node->translation_change['new_tnid'];
foreach (flag_get_flags('node') as $flag) {
if ($flag->i18n) {
db_update('flag_content')
->fields(array(
'content_id' => $content_id,
))
->condition('fid', $flag->fid)
->condition('content_id', $node->translation_change['old_tnid'])
->execute();
db_update('flag_counts')
->fields(array(
'content_id' => $content_id,
))
->condition('fid', $flag->fid)
->condition('content_id', $node->translation_change['old_tnid'])
->execute();
}
}
}
}