You are here

function webform_localization_roles_sync in Webform Localization 7.4

Same name and namespace in other branches
  1. 7 includes/webform_localization.sync.inc \webform_localization_roles_sync()

Sync webform roles with its translated versions.

Parameters

int $nid: A node Id.

1 call to webform_localization_roles_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 54
Webform Localization General Properties, Roles and Emails Sync Functions.

Code

function webform_localization_roles_sync($nid) {
  $node_list = _webform_localization_translation_set_node_list($nid);
  $roles = db_select('webform_roles')
    ->fields('webform_roles', array(
    'rid',
  ))
    ->condition('nid', $nid)
    ->execute()
    ->fetchCol();
  foreach ($node_list as $n) {
    if ($n != $nid) {
      db_delete('webform_roles')
        ->condition('nid', $n)
        ->execute();
      foreach ($roles as $rid) {
        db_insert('webform_roles')
          ->fields(array(
          'nid' => $n,
          'rid' => $rid,
        ))
          ->execute();
      }
    }
  }
}