function flag_node_translation_change in Flag 7.3
Same name and namespace in other branches
- 7.2 flag.module \flag_node_translation_change()
Implements hook_node_translation_change().
(Hook provided by translation_helpers module.)
File
- ./
flag.module, line 1080 - 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.
$entity_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('flagging')
->fields(array(
'entity_id' => $entity_id,
))
->condition('fid', $flag->fid)
->condition('entity_id', $node->translation_change['old_tnid'])
->execute();
db_update('flag_counts')
->fields(array(
'entity_id' => $entity_id,
))
->condition('fid', $flag->fid)
->condition('entity_id', $node->translation_change['old_tnid'])
->execute();
}
}
}
}