function webform_localization_emails_sync in Webform Localization 7
Same name and namespace in other branches
- 7.4 includes/webform_localization.sync.inc \webform_localization_emails_sync()
Sync webform emails recipients with its translated versions.
Parameters
$nid: A node Id.
2 calls to webform_localization_emails_sync()
- _webform_localization_webform_email_delete_form_submit in ./
webform_localization.module - Handle emails localization cleanup / sync on email deletion.
- _webform_localization_webform_email_edit_form_submit in ./
webform_localization.module - Handle emails sync on individual email change.
File
- includes/
webform_localization.sync.inc, line 76 - Webform Localization General Properties, Roles and Emails Sync Functions.
Code
function webform_localization_emails_sync($nid) {
$node_list = _webform_localization_translation_set_node_list($nid);
$origin = _webform_localization_emails_load($nid);
foreach ($node_list as $n) {
if ($n != $nid) {
$version = _webform_localization_emails_load($n);
if ($origin != $version) {
module_load_include('inc', 'webform', 'includes/webform.emails');
$original_eids = array_keys($version);
$current_eids = array_keys($origin);
$all_eids = array_unique(array_merge($original_eids, $current_eids));
$deleted_eids = array_diff($original_eids, $current_eids);
$inserted_eids = array_diff($current_eids, $original_eids);
foreach ($all_eids as $eid) {
if (in_array($eid, $inserted_eids)) {
$temp = $origin[$eid];
$temp['nid'] = $n;
webform_email_insert($temp);
}
elseif (in_array($eid, $deleted_eids)) {
$node = node_load($n);
webform_email_delete($node, $version[$eid]);
}
elseif ($origin[$eid] != $version[$eid]) {
$temp = $origin[$eid];
$temp['nid'] = $n;
webform_email_update($temp);
}
}
}
}
}
}