You are here

function styleswitcher_update_7206 in Style Switcher 7.2

Update styles settings data model to have separate settings per theme.

File

./styleswitcher.install, line 175
Installation tasks.

Code

function styleswitcher_update_7206() {

  // Set a variable to know what theme was previously used as a host of styles
  // to switch - the default site theme. So when a user with a plain
  // styleswitcher cookie comes to the site we know what theme that style
  // belongs to and we can convert user's cookie to the new array format
  // preserving user's preference.
  $theme_default = variable_get('theme_default', 'bartik');
  variable_set('styleswitcher_7206_theme_default', $theme_default);
  if ($settings = variable_get('styleswitcher_styles_settings')) {

    // Save all existing styles settings as the default theme's styles settings.
    // Check that settings still have an old structure by analyzing its first
    // key: theme machine names can't contain a slash.
    if (strpos(key($settings), '/') !== FALSE) {
      variable_set('styleswitcher_styles_settings', array(
        $theme_default => $settings,
      ));
    }
  }
}