You are here

function content_type_delete in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 5 content_crud.inc \content_type_delete()
  2. 6.3 includes/content.crud.inc \content_type_delete()
  3. 6 includes/content.crud.inc \content_type_delete()

Make changes needed when a content type is deleted.

Parameters

$info: value supplied by hook_node_type()

TODO should we skip doing this entirely since core leaves the nodes in the database as orphans and wait until the nodes are deleted to respond?

1 call to content_type_delete()
content_node_type in ./content.module
Implementation of hook_node_type() React to change in node types

File

includes/content.crud.inc, line 673
Create/Read/Update/Delete functions for CCK-defined object types.

Code

function content_type_delete($info) {

  // Don't delete data for content-types defined by disabled modules.
  if (!empty($info->disabled)) {
    return;
  }

  // TODO : What about inactive fields ?
  // Currently, content_field_instance_delete doesn't work on those...
  $fields = content_field_instance_read(array(
    'type_name' => $info->type,
  ));
  foreach ($fields as $field) {
    content_field_instance_delete($field['field_name'], $info->type, FALSE);
  }
  $table = _content_tablename($info->type, CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
  if (db_table_exists($table)) {
    $ret = array();
    db_drop_table($ret, $table);
    watchdog('content', 'The content fields table %name has been deleted.', array(
      '%name' => $table,
    ));
  }

  // Menu needs to be rebuilt as well, but node types need to be rebuilt first.
  // node_type_form_submit() takes care of this.
  content_clear_type_cache(TRUE);
}