Commit 52ba1e17 authored by Sven Berg Ryen's avatar Sven Berg Ryen Committed by Sven Berg Ryen
Browse files

Issue #2985438 by svenryen: When upgrading, newly introduced default settings...

Issue #2985438 by svenryen: When upgrading, newly introduced default settings are not set for translations
parent e30f8cf6
Loading
Loading
Loading
Loading
+78 −1
Changes for eu_cookie_compliance.install: 78 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -162,6 +162,44 @@ function _eu_cookie_compliance_get_popup_default_setting() {
    'withdraw_action_button_label' => 'Withdraw consent',
    'withdraw_tab_button_label' => 'Privacy settings',
    'withdraw_enabled' => 0,
    'accept_all_categories_button_label' => 'Accept all cookies',
    'better_support_for_screen_readers' => 0,
    'cookie_categories' => '',
    'cookie_name' => '',
    'disagree_button_label' => 'No, thanks',
    'disagree_do_not_show_popup' => 0,
    'domains_list' => '',
    'domains_option' => 1,
    'enable_save_preferences_button' => 1,
    'eu_only_js' => 0,
    'eu_only' => 0,
    'exclude_admin_pages' => 0,
    'exclude_paths' => '',
    'exclude_uid_1' => 0,
    'fix_first_cookie_category' => 1,
    'method' => 'default',
    'mobile_breakpoint' => 768,
    'mobile_popup_info' => array(
      'value' => '<h2>We use cookies on this site to enhance your user experience</h2><p>By tapping the Accept button, you agree to us doing so.</p>',
      'format' => $default_filter_format,
    ),
    'popup_agree_button_message' => 'OK, I agree',
    'popup_clicking_confirmation' => 1,
    'popup_disagree_button_message' => 'No, give me more info',
    'popup_find_more_button_message' => 'More info',
    'popup_hide_agreed' => 0,
    'popup_hide_button_message' => 'Hide',
    'popup_link_new_window' => 1,
    'popup_scrolling_confirmation' => 0,
    'reload_page' => 0,
    'save_preferences_button_label' => 'Save preferences',
    'script_scope' => 'footer',
    'select_all_categories_by_default' => 0,
    'show_disagree_button' => 1,
    'use_bare_css' => 0,
    'use_mobile_message' => 0,
    'whitelisted_cookies' => '',
    'withdraw_button_on_info_popup' => 0,
  );
}

@@ -440,7 +478,6 @@ function eu_cookie_compliance_update_7011() {
  }
}


/**
 * Add config variables for the "Opt-in with categories" feature.
 */
@@ -469,3 +506,43 @@ function eu_cookie_compliance_update_7012() {
  }
}

/**
 * Add any missing defaults to sites with i18n or domain settings enabled.
 */
function eu_cookie_compliance_update_7013() {
  // Get defaults.
  $default_settings = _eu_cookie_compliance_get_popup_default_setting();

  // Add any missing configuration defaults to the regular variable.
  $updated_settings = variable_get('eu_cookie_compliance', array()) + $default_settings;
  variable_set('eu_cookie_compliance', $updated_settings);

  // Set any missing configuration variables for all languages.
  if (module_exists('i18n_variable')) {
    $languages = language_list();
    foreach (array_keys($languages) as $langcode) {
      $settings = i18n_variable_get('eu_cookie_compliance', $langcode);
      if (!empty($settings)) {
        $updated_settings = $settings + $default_settings;
        i18n_variable_set('eu_cookie_compliance', $updated_settings, $langcode);
      }
    }
  }

  // Set any missing configuration variables for all domains.
  if (module_exists('domain_settings') && module_exists('domain_conf')) {
    $domains = domain_domains();
    foreach ($domains as $domain_data) {
      $domain_id = $domain_data['domain_id'];
      // We may have the old config variable where language code was appended.
      $settings = domain_conf_variable_get($domain_id, 'eu_cookie_compliance_' . language_default('language'));
      if (empty($settings)) {
        $settings = domain_conf_variable_get($domain_id, 'eu_cookie_compliance');
      }
      if (!empty($settings)) {
        $updated_settings = $settings + $default_settings;
        domain_conf_variable_save($domain_id, 'eu_cookie_compliance', $updated_settings);
      }
    }
  }
}