You are here

function nodereference_node_type in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 modules/nodereference/nodereference.module \nodereference_node_type()

Implementation of hook_node_types.

File

modules/nodereference/nodereference.module, line 997
Defines a field type for referencing one node from another.

Code

function nodereference_node_type($op, $info) {
  switch ($op) {
    case 'update':

      // Reflect type name changes to the 'referenceable types' settings.
      if (!empty($info->old_type) && $info->old_type != $info->type) {

        // content.module's implementaion of hook_node_type() has already
        // refreshed _content_type_info().
        $fields = content_fields();
        $rebuild = FALSE;
        foreach ($fields as $field_name => $field) {
          if ($field['type'] == 'nodereference' && isset($field['referenceable_types'][$info->old_type])) {
            $field['referenceable_types'][$info->type] = empty($field['referenceable_types'][$info->old_type]) ? 0 : $info->type;
            unset($field['referenceable_types'][$info->old_type]);
            content_field_instance_update($field, FALSE);
            $rebuild = TRUE;
          }
        }

        // Clear caches and rebuild menu only if any field has been updated.
        if ($rebuild) {
          content_clear_type_cache(TRUE);
          menu_rebuild();
        }
      }
      break;
  }
}