function webform_localization_webform_properties_sync in Webform Localization 7.4
Same name and namespace in other branches
- 7 includes/webform_localization.sync.inc \webform_localization_webform_properties_sync()
Sync webform configured properties with its translated versions.
Parameters
int $nid: A node Id.
1 call to webform_localization_webform_properties_sync()
- _webform_localization_webform_configure_form_submit in ./
webform_localization.module - Handle specific localization options in Webform Configure Form.
File
- includes/
webform_localization.sync.inc, line 20 - Webform Localization General Properties, Roles and Emails Sync Functions.
Code
function webform_localization_webform_properties_sync($nid) {
// Gets webform localization options that match this node ID.
$webform_localization_options = webform_localization_get_config($nid, TRUE);
if (count($webform_localization_options['webform_properties']) > 0) {
$node_list = _webform_localization_translation_set_node_list($nid);
if (count($node_list) > 1) {
// Select all webforms that match these node IDs.
$result = db_select('webform')
->fields('webform')
->condition('nid', $node_list, 'IN')
->execute()
->fetchAllAssoc('nid', PDO::FETCH_ASSOC);
if ($result) {
$origin = $result[$nid];
unset($result[$nid]);
// Sync each translated version.
foreach ($result as $webform) {
foreach ($webform_localization_options['webform_properties'] as $property) {
$webform[$property] = $origin[$property];
}
drupal_write_record('webform', $webform, array(
'nid',
));
}
}
}
}
}