function node_convert_node_convert in Node Convert 5
Same name and namespace in other branches
- 6 node_convert.module \node_convert_node_convert()
- 7 node_convert.util.inc \node_convert_node_convert()
Converts a node to another content type.
Parameters
$nid: The nid of the node to be converted.
$dest_node_type: A string containing the destination node type of the node.
$source_fields: An array containing the source field names.
$dest_fields: An array containing the destination field names.
$no_fields_flag: A boolean containing if there are source fields that have to be converted.
2 calls to node_convert_node_convert()
File
- ./
node_convert.module, line 342
Code
function node_convert_node_convert($nid, $dest_node_type, $source_fields, $dest_fields, $no_fields_flag) {
$node = node_load($nid);
$vid = $node->vid;
$source_node_type = $node->type;
db_query("UPDATE {node} SET type = '%s' WHERE nid = %d", $dest_node_type, $nid);
// Change the node type in the DB
db_query("INSERT INTO {%s} (nid, vid) VALUES (%d, %d)", "content_type_" . $dest_node_type, $nid, $vid);
// Add the current node to the chosen content type
if ($no_fields_flag == false) {
// If there are cck fields that can be converted
foreach ($source_fields as $key => $field) {
// Conversion process for each field
node_convert_field_convert($nid, $field, $dest_fields[$key]);
}
}
db_query("DELETE FROM {%s} WHERE nid = %d", "content_type_" . $source_node_type, $nid);
// We delete the source node_type info
db_query("DELETE FROM {cache_content} WHERE cid = '%s'", "content:" . $nid . ":" . $vid);
// We clear the cache
}