You are here

nofollowlist.install in Nofollow List 7

File

nofollowlist.install
View source
<?php

/**
 * Upgrade settings of input formats to Drupal 7 format.
 */
function nofollowlist_update_7000() {
  if (!db_table_exists('d6_upgrade_filter')) {
    return t('Setting of input formats from Drupal 6 are not available, no upgrade required.');
  }
  $existing = db_select('filter', 'f')
    ->fields('f', array(
    'format',
  ))
    ->condition('module', 'nofollowlist')
    ->condition('name', 'filter_nofollow')
    ->execute()
    ->fetchAllAssoc('format');
  $settings = serialize(array(
    'nofollowlist_option' => variable_get('nofollowlist_option', 'black'),
    'nofollowlist_hosts' => variable_get('nofollowlist_hosts', 'en.wikipedia.org'),
  ));
  $results = db_select('d6_upgrade_filter', 'd6')
    ->fields('d6')
    ->condition('module', 'nofollowlist')
    ->execute();
  foreach ($results as $filter) {
    if (!empty($existing[$filter->format])) {
      continue;
    }
    db_insert('filter')
      ->fields(array(
      'format' => $filter->format,
      'module' => 'nofollowlist',
      'name' => 'filter_nofollow',
      'weight' => $filter->weight,
      'settings' => $settings,
      'status' => 1,
    ))
      ->execute();
  }
  db_delete('d6_upgrade_filter')
    ->condition('module', 'nofollowlist')
    ->execute();
  variable_del('nofollowlist_option');
  variable_del('nofollowlist_hosts');
}
function nofollowlist_uninstall() {
  db_delete('filter')
    ->condition('module', 'nofollowlist')
    ->condition('name', 'filter_nofollow')
    ->execute();
  variable_del('nofollowlist_option');
  variable_del('nofollowlist_hosts');
}

Functions

Namesort descending Description
nofollowlist_uninstall
nofollowlist_update_7000 Upgrade settings of input formats to Drupal 7 format.