function node_type_save in Drupal 5
Same name and namespace in other branches
- 6 modules/node/node.module \node_type_save()
- 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_final 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().
- system_update_1005 in modules/
system/ system.install
File
- modules/
node/ node.module, line 331 - 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_num_rows(db_query("SELECT * FROM {node_type} WHERE type = '%s'", $existing_type));
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;
}
}