You are here

function fieldgroup_update_2 in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6.3 modules/fieldgroup/fieldgroup.install \fieldgroup_update_2()
  2. 6.2 modules/fieldgroup/fieldgroup.install \fieldgroup_update_2()

add display settings for the group

File

./fieldgroup.install, line 65

Code

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

  // set settings column to accept larger values
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql('ALTER TABLE {node_group} CHANGE settings settings mediumtext NOT NULL');
      break;
    case 'pgsql':
      db_change_column($ret, 'node_group', 'settings', 'settings', 'text', array(
        'not null' => TRUE,
      ));
      break;
  }

  // move description into the settings array, and add new settings
  $result = db_query("SELECT * FROM {node_group}");
  while ($group = db_fetch_array($result)) {
    $settings = array();
    $settings['form'] = unserialize($group['settings']);
    $settings['form']['description'] = $group['description'];
    $settings['display'] = array(
      'collapsible' => 0,
      'collapsed' => 0,
      'description' => '',
    );
    $ret[] = update_sql("UPDATE {node_group} SET settings = '" . db_escape_string(serialize($settings)) . "', description = '' WHERE group_name = '" . $group['group_name'] . "'");
  }

  // drop description column
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql('ALTER TABLE {node_group} DROP description');
      break;
    case 'pgsql':

      // Postgres only supports dropping of columns since 7.4
      break;
  }
  return $ret;
}