You are here

function content_taxonomy_update_6001 in Content Taxonomy 6.2

Same name and namespace in other branches
  1. 6 content_taxonomy.install \content_taxonomy_update_6001()

Implemenation of hook_update_N().

Renaming of the Parent setting

File

./content_taxonomy.install, line 145

Code

function content_taxonomy_update_6001() {
  drupal_load('module', 'content');
  $result = db_query("SELECT * FROM {" . content_field_tablename() . "} WHERE type = 'content_taxonomy'");
  while ($field = db_fetch_array($result)) {
    $field['global_settings'] = unserialize($field['global_settings']);
    if (!is_null($field['global_settings']['tid'])) {
      $field['global_settings']['parent'] = $field['global_settings']['tid'];
      unset($field['global_settings']['tid']);
    }

    // 'columns' is a reserved word in MySQL4, so our column is named 'db_columns'.
    $field['db_columns'] = $field['columns'];
    drupal_write_record(content_field_tablename(), $field, 'field_name');
  }
  $result = db_query("SELECT * FROM {" . content_instance_tablename() . "} WHERE widget_type = 'content_taxonomy_select'");
  while ($field = db_fetch_array($result)) {
    $field['widget_settings'] = unserialize($field['widget_settings']);
    $field['widget_settings']['group_parent'] = $field['widget_settings']['group_tid'];
    unset($field['widget_settings']['group_tid']);
    drupal_write_record(content_instance_tablename(), $field, array(
      'field_name',
      'type_name',
    ));
  }
  return array();
}