--- auto_nodetitle.module +++ (clipboard) @@ -57,14 +57,33 @@ } } + + /** - * Implementation of hook_nodeapi(). - */ -function auto_nodetitle_nodeapi(&$node, $op) { - if ($op == 'presave' && auto_nodetitle_is_needed($node)) { - auto_nodetitle_set_title($node); - } -} +* Implementation of hook_nodeapi(). +* Needed for newly saved nodes +*/ +function auto_nodetitle_nodeapi(&$node, $op, $teaser, $page) { + // First check if this nodetype is auto_nodetitle enabled + $setting = auto_nodetitle_get_setting($node->type); + if ($setting == AUTO_NODETITLE_ENABLED || ($setting == AUTO_NODETITLE_OPTIONAL && empty($form_state['values']['title']))) { + switch ($op) { + case 'update': + case 'presave': + case 'validate': + case 'insert': + auto_nodetitle_set_title($node); + if($op = 'insert'){ + db_query("UPDATE {node} SET title = '%s' WHERE nid = %d", $node->title, $node->nid); + db_query("UPDATE {node_revisions} SET title = '%s' WHERE nid = %d AND vid = %d", $node->title, $node->nid, $node->vid); + } + break; + default: + break; + } + } + } + /** * Returns whether the auto nodetitle has to be set.