function webform_localization_node_view in Webform Localization 7.4
Same name and namespace in other branches
- 7 webform_localization.module \webform_localization_node_view()
Implements hook_node_view().
File
- ./
webform_localization.module, line 310 - Webform localization module.
Code
function webform_localization_node_view($node, $view_mode) {
if (!in_array($node->type, webform_variable_get('webform_node_types'))) {
return;
}
if ($nid = webform_localization_single_webform_nid($node)) {
// NOTE:
// Perhaps not most eficient way.. a possible alternative
// @todo rewrite the webform load and view process as a
// independent function to reuse.
$source_node = node_load($nid);
// We replace the webform with the node translation source.
$node->webform = $source_node->webform;
// This fool webform_node_view to avoid errors with drafts in between pages.
$translation_nid = $node->nid;
if (($node->webform['allow_draft'] || $node->webform['auto_save']) && $user->uid != 0) {
$node->nid = $source_node->nid;
}
// Call node view implementation to update the $node->content.
webform_node_view($node, $view_mode);
// Reset the nid if we used the drafts fix.
$node->nid = $translation_nid;
}
}