You are here

function custom_pub_update_7100 in Custom Publishing Options 7

Moves any existing custom publishing options over to Drupal 7.

File

./custom_pub.install, line 36
Install and update function for Custom Publishing Options.

Code

function custom_pub_update_7100() {
  $types = variable_get('custom_pub_types', array());
  $node_types = _node_types_build();
  $node_types = array_keys($node_types);
  $spec = array(
    'description' => 'Custom publishing option.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  );
  foreach ($types as $type) {
    foreach ($type['node_types'] as $n_type => $name) {
      if (!in_array($n_type, $node_types)) {
        unset($types[$type['type']]['node_types'][$n_type]);
      }
    }
    if (!db_field_exists('node', $type['type'])) {
      db_add_field('node', $type['type'], $spec);
    }
  }
  variable_set('custom_pub_types', $types);
}