function auto_nodetitle_node_import_prepare in Node import 5
Implementation of hook_node_import_prepare().
File
- supported/
auto_nodetitle.inc, line 11 - Support for the auto_nodetitle module.
Code
function auto_nodetitle_node_import_prepare(&$node, $preview) {
$errors = array();
$setting = auto_nodetitle_get_setting($node->type);
if ($setting == AUTO_NODETITLE_ENABLED || $setting == AUTO_NODETITLE_OPTIONAL && $node->title == $node->auto_nodetitle) {
// Flush the tokens and create a new title.
token_get_values('node', $node, TRUE);
auto_nodetitle_set_title($node);
unset($node->auto_nodetitle);
}
// Since we provided a static random title value the test in
// supported/node.inc for unique titles does no longer work.
if ($setting == AUTO_NODETITLE_ENABLED || $setting == AUTO_NODETITLE_OPTIONAL) {
if ($node->node_import_node['unique_title']) {
$count = db_fetch_object(db_query("SELECT count(*) AS cnt FROM {node} WHERE title = '%s' AND type = '%s'", $node->title, $node->type));
if ($count->cnt > 0) {
$errors[] = t('The node title %title is not unique for this node type.', array(
'%title' => $node->title,
));
}
}
}
return $errors;
}