You are here

function fieldgroup_update_3 in Content Construction Kit (CCK) 6.2

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

converts group settings collapsible/collapsed => style

File

modules/fieldgroup/fieldgroup.install, line 146
Implementation of hook_install().

Code

function fieldgroup_update_3() {
  $ret = array();
  if (!db_table_exists('node_group')) {
    return $ret;
  }
  $result = db_query("SELECT * FROM {node_group}");
  while ($group = db_fetch_array($result)) {
    $group['settings'] = unserialize($group['settings']);
    if (!isset($group['settings']['form']['style'])) {
      foreach (array(
        'form',
        'display',
      ) as $context) {
        if (isset($group['settings'][$context]['collapsible']) && $group['settings'][$context]['collapsible']) {
          if (isset($group['settings'][$context]['collapsed']) && $group['settings'][$context]['collapsed']) {
            $group['settings'][$context]['style'] = 'fieldset_collapsed';
          }
          else {
            $group['settings'][$context]['style'] = 'fieldset_collapsible';
          }
        }
        else {
          $group['settings'][$context]['style'] = 'fieldset';
        }
      }
      $ret[] = update_sql("UPDATE {node_group} SET settings = '" . db_escape_string(serialize($group['settings'])) . "' WHERE group_name = '" . $group['group_name'] . "'");
    }
  }
  return $ret;
}