You are here

function petreference_node_type in Previewable email templates 6

Implementation of hook_node_types.

File

modules/petreference/petreference.module, line 909
Defines a field type for referencing pet template to a node.

Code

function petreference_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'] == 'petreference' && 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;
  }
}