You are here

function paging_update_6000 in Paging 6

Drupal 5 -> Drupal 6 upgrade path.

File

./paging.install, line 56
Installation code for Paging module.

Code

function paging_update_6000() {
  $ret = array();

  // Get rid of phantom <!--page_filter--> tags by weighting Paging after
  // HTML corrector.
  $result = db_query('SELECT format FROM {filter_formats}');
  while ($format = db_fetch_object($result)) {
    $filters = filter_list_format($format->format);

    // filter/3 = HTML corrector; paging/0 = Paging.
    if (isset($filters['filter/3']) && isset($filters['paging/0'])) {
      $html_corrector = $filters['filter/3'];
      $weight = $html_corrector->weight + 1;
      $ret[] = update_sql("UPDATE {filters} SET weight = {$weight} WHERE format = {$format->format} AND module = 'paging' AND delta = 0");
    }
  }

  // Move variables to their new format.
  $variables = array(
    'paging_separator' => variable_get('paging_separator', NULL),
    'paging_read_more_enabled' => variable_get('paging_read_more_enabled', NULL),
    'paging_pager_widget_position' => variable_get('paging_pager_widget_position', NULL),
    'paging_automatic_chars' => variable_get('paging_automatic_chars', NULL),
    'paging_automatic_words' => variable_get('paging_automatic_words', NULL),
  );
  $enabled_types = variable_get('paging_node_types_enabled', array());
  foreach ($enabled_types as $type => $enabled) {
    if ($enabled) {
      variable_set("paging_enabled_{$type}", TRUE);
      foreach ($variables as $name => $value) {
        if (!is_null($value)) {
          variable_set($name . '_' . $type, $value);
        }
      }
    }
  }
  variable_del('paging_node_types_enabled');
  foreach ($variables as $name => $value) {
    variable_del($name);
  }
  return $ret;
}