You are here

function nodewords_update_6100 in Nodewords: D6 Meta Tags 6.2

Same name and namespace in other branches
  1. 6 nodewords.install \nodewords_update_6100()

Implements hook_update_N().

File

./nodewords.install, line 126
Install, update and uninstall functions for the Nodewords module.

Code

function nodewords_update_6100() {
  $tags = array(
    'abstract' => 'abstract',
    'copyright' => 'copyright',
    'description' => 'description',
    'geourl' => 'location',
    'keywords' => 'keywords',
    'Revisit-After' => 'revisit-after',
    'robots' => 'robots',
  );
  $ret = array();
  db_change_field($ret, 'nodewords', 'content', 'content', array(
    'type' => 'text',
    'size' => 'big',
    'not null' => TRUE,
  ));
  $settings = variable_get('nodewords', array());

  // Create the new Drupal variables used for the settings.
  if (isset($settings['global'])) {
    variable_set('nodewords_global', $settings['global']);
  }
  if (!empty($settings['use_teaser'])) {
    variable_set('nodewords_basic_use_teaser', $settings['use_teaser']);
  }
  if (isset($settings['taxonomy']['keyword_vids'])) {
    variable_set('nodewords_keyword_vids', $settings['taxonomy']['keyword_vids']);
  }
  if (isset($settings['edit'])) {
    $new_tags = array();
    foreach ($tags as $old_tag => $new_tag) {
      if (!empty($settings['edit'][$old_tag])) {
        $new_tags[$new_tag] = $new_tag;
      }
    }
    variable_set('nodewords_edit', $new_tags);
  }
  if (isset($settings['head'])) {
    $new_tags = array();
    foreach ($tags as $old_tag => $new_tag) {
      if (!empty($settings['head'][$old_tag])) {
        $new_tags[$new_tag] = $new_tag;
      }
    }
    variable_set('nodewords_head', $new_tags);
  }
  if (!empty($settings['advanced']['enable_user_metatags'])) {
    variable_set('nodewords_enable_user_metatags', $settings['advanced']['enable_user_metatags']);
  }
  if (!empty($settings['advanced']['repeat'])) {
    variable_set('nodewords_list_repeat', $settings['advanced']['repeat']);
  }
  if (!empty($settings['advanced']['use_front_page_tags'])) {
    variable_set('nodewords_use_frontpage_tags', $settings['advanced']['use_front_page_tags']);
  }
  if (!empty($settings['advanced']['max_size'])) {
    variable_set('nodewords_max_size', $settings['advanced']['max_size']);
  }
  if (!empty($settings['advanced']['use_alt_tags'])) {
    variable_set('nodewords_use_alt_attribute', $settings['advanced']['use_alt_tags']);
  }

  // Delete the old Drupal variable used.
  $ret[] = array(
    'success' => TRUE,
    'query' => 'Created new setting variables',
  );
  return $ret;
}