function node_convert_convert_action in Node Convert 6
Same name and namespace in other branches
- 7 node_convert.module \node_convert_convert_action()
1 string reference to 'node_convert_convert_action'
File
- ./
node_convert.module, line 536 - The node_convert module converts nodes from one type to another.
Code
function node_convert_convert_action(&$node, &$context = array()) {
if ($context['template'] === "0") {
drupal_set_message(t("Dummy template. No action is being performed."), 'warning', FALSE);
return FALSE;
}
$template = node_convert_load_template($context['template']);
$access = node_convert_check_template_permission_user(array(
'template' => $template,
));
if ($access == FALSE) {
drupal_set_message(t("You don't have permission to use this conversion template"), 'warning', FALSE);
return;
}
if ($node->type != $template['source_type']) {
drupal_set_message(t("Node %nid doesn't match the template source type. Discarded.", array(
'nid' => $node->nid,
)), 'warning');
}
else {
$result = node_convert_node_convert($node->nid, $template['destination_type'], $template['data']['fields']['source'], $template['data']['fields']['destination'], $template['data']['no_fields'], $template['data']['hook_options']);
// We display errors if any, or the default success message
node_convert_messages($result, array(
'nid' => $node->nid,
));
// This is node_load is necessary. It loads the new data from the DB, which gets passed down the action chain by reference, where it is saved.
$node = node_load($node->nid, NULL, TRUE);
}
}