You are here

function node_type_save in Drupal 6

Same name and namespace in other branches
  1. 5 modules/node/node.module \node_type_save()
  2. 7 modules/node/node.module \node_type_save()

Saves a node type to the database.

Parameters

$info: The node type to save, as an object.

Return value

Status flag indicating outcome of the operation.

4 calls to node_type_save()
default_profile_tasks in profiles/default/default.profile
Perform any final installation tasks for this profile.
node_types_rebuild in modules/node/node.module
Resets the database cache of node types, and saves all new or non-modified module-defined node types to the database.
node_type_form_submit in modules/node/content_types.inc
Implementation of hook_form_submit().
_book_install_type_create in modules/book/book.install

File

modules/node/node.module, line 490
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

function node_type_save($info) {
  $is_existing = FALSE;
  $existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
  $is_existing = db_result(db_query("SELECT COUNT(*) FROM {node_type} WHERE type = '%s'", $existing_type));
  if (!isset($info->help)) {
    $info->help = '';
  }
  if (!isset($info->min_word_count)) {
    $info->min_word_count = 0;
  }
  if (!isset($info->body_label)) {
    $info->body_label = '';
  }
  if ($is_existing) {
    db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', min_word_count = %d, custom = %d, modified = %d, locked = %d WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type);
    module_invoke_all('node_type', 'update', $info);
    return SAVED_UPDATED;
  }
  else {
    db_query("INSERT INTO {node_type} (type, name, module, has_title, title_label, has_body, body_label, description, help, min_word_count, custom, modified, locked, orig_type) VALUES ('%s', '%s', '%s', %d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, '%s')", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $info->orig_type);
    module_invoke_all('node_type', 'insert', $info);
    return SAVED_NEW;
  }
}