You are here

function addthis_update_6300 in AddThis 6.3

Convert 2.x configuration settings to 3.x equivalents.

File

./addthis.install, line 41
AddThis module installation/update hooks.

Code

function addthis_update_6300() {
  $ret = array();
  variable_set('addthis_widget_type', 'addthis_button');

  // Convert widget settings.
  $addthis_config = array();
  $addthis_config['services_compact'] = variable_get('addthis_options', '');
  $addthis_config['ui_cobrand'] = variable_get('addthis_brand', '');
  $ui_header_color = trim(variable_get('addthis_logo_color', ''));
  if (!empty($ui_header_color)) {
    $addthis_config['ui_header_color'] = '#' . $ui_header_color;
  }
  $ui_header_background = trim(variable_get('addthis_logo_background', ''));
  if (!empty($ui_header_background)) {
    $addthis_config['ui_header_background'] = '#' . $ui_header_background;
  }
  $addthis_config['ui_hover'] = variable_get('addthis_dropdown_disabled', 0);
  $addthis_config['ui_offset_left'] = variable_get('addthis_offset_left', '');
  $addthis_config['ui_offset_top'] = variable_get('addthis_offset_top', '');
  $addthis_config['ui_use_css'] = TRUE;
  $addthis_config['data_use_cookies'] = TRUE;
  $addthis_config['username'] = variable_get('addthis_username', '');
  variable_set('addthis_config', $addthis_config);

  // Convert node type visibility settings.
  $types = array_keys(node_get_types());
  $addthis_node_types = array();
  foreach ($types as $type) {
    $addthis_node_types[$type] = variable_get('addthis_nodetype_' . $type, 0) ? $type : 0;
    variable_del('addthis_nodetype_' . $type);
  }
  variable_set('addthis_node_types', $addthis_node_types);

  // Remove remaining obsolete 6.x-2.x variables.
  $remove = array(
    'addthis_brand',
    'addthis_disable_flash',
    'addthis_dropdown_disabled',
    'addthis_image',
    'addthis_image_attributes_alt',
    'addthis_image_attributes_class',
    'addthis_image_height',
    'addthis_image_secure',
    'addthis_image_width',
    'addthis_logo',
    'addthis_logo_background',
    'addthis_logo_color',
    'addthis_offset_left',
    'addthis_offset_top',
    'addthis_options',
    'addthis_username',
    'addthis_widget_version',
  );
  foreach ($remove as $variable) {
    variable_del($variable);
  }

  // Disable unsupported modules from the original 6.x-3.x-dev releases.
  module_disable(array(
    'at_cck_field',
    'at_content_type',
    'at_export',
    'at_taxonomy',
    'at_visibility',
  ));
  drupal_uninstall_module('at_cck_field');
  drupal_uninstall_module('at_content_type');
  drupal_uninstall_module('at_export');
  drupal_uninstall_module('at_taxonomy');
  drupal_uninstall_module('at_visibility');
  if (db_table_exists('at_visibility_nodelist')) {
    db_drop_table($ret, 'at_visibility_nodelist');
  }

  // Module weight must be greater than Google Analytics, which is 0.
  $ret[] = update_sql("UPDATE {system} SET weight=1 WHERE type='module' AND name='addthis'");
  return $ret;
}