You are here

function webform_localization_get_config in Webform Localization 7

Same name and namespace in other branches
  1. 7.4 webform_localization.module \webform_localization_get_config()

Gets webform localization options that match a node ID.

@staticvar array $webform_localization_options An array of webform localization options group by nid.

Parameters

$nid: A node Id.

bool $clear_cache: A flag to force a database reading in case that properties are cached.

Return value

array Webform localization options that match the nid.

14 calls to webform_localization_get_config()
webform_localization_field_attach_prepare_translation_alter in ./webform_localization.module
Implements hook_field_attach_prepare_translation_alter().
webform_localization_form_webform_client_form_alter in ./webform_localization.module
Implements hook_form_webform_client_form_alter().
webform_localization_form_webform_component_edit_form_alter in ./webform_localization.module
Implements hook_form_FORM_ID_alter().
webform_localization_form_webform_configure_form_alter in ./webform_localization.module
Implements hook_form_FORM_ID_alter().
webform_localization_node_load in ./webform_localization.module
Implements hook_node_load().

... See full list

File

./webform_localization.module, line 653
Webform localization module.

Code

function webform_localization_get_config($nid, $clear_cache = FALSE) {
  static $webform_localization_options = array();
  if ($clear_cache || !isset($webform_localization_options[$nid])) {
    $defaults = array_keys(webform_node_defaults());
    $webform_properties = array();
    foreach ($defaults as $key) {
      $webform_properties[$key] = $key;
    }
    unset($webform_properties['components']);
    unset($webform_properties['roles']);
    unset($webform_properties['emails']);
    unset($webform_properties['record_exists']);

    // Select webform localization options that match this node ID.
    $options = db_select('webform_localization')
      ->fields('webform_localization')
      ->condition('nid', $nid, '=')
      ->execute()
      ->fetchAllAssoc('nid', PDO::FETCH_ASSOC);
    if (count($options) == 0) {
      $webform_localization_options[$nid] = array(
        'nid' => $nid,
        'expose_strings' => 0,
        'single_webform' => 0,
        'sync_components' => 0,
        'sync_roles' => 0,
        'sync_emails' => 0,
        'webform_properties' => array(),
        'webform_properties_structure' => $webform_properties,
        'no_persistent' => TRUE,
      );
    }
    else {
      $options[$nid]['webform_properties_structure'] = $webform_properties;
      if (empty($options[$nid]['webform_properties'])) {
        $options[$nid]['webform_properties'] = array();
      }
      else {
        $options[$nid]['webform_properties'] = unserialize($options[$nid]['webform_properties']);
      }
      $webform_localization_options[$nid] = $options[$nid];
    }
  }
  return $webform_localization_options[$nid];
}