You are here

function fieldgroup_update_3 in Content Construction Kit (CCK) 5

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

converts group settings collapsible/collapsed => style

File

./fieldgroup.install, line 109

Code

function fieldgroup_update_3() {
  $ret = array();
  $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;
}