### Eclipse Workspace Patch 1.0 #P NodeGotoCVS Index: nodegoto.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/nodegoto/nodegoto.module,v retrieving revision 1.2 diff -u -r1.2 nodegoto.module --- nodegoto.module 26 Dec 2007 02:31:15 -0000 1.2 +++ nodegoto.module 28 Dec 2008 22:47:10 -0000 @@ -23,6 +23,19 @@

It also has the option to send the target page a variable informing from where it came.

", array('@token' => 'http://www.drupal.org/project/token')); } } + +/** + * Implementation of hook_nodeapi(). + */ +function notegoto_nodeapi(&$node, $op, $teaser, $page){ + + //save node on insert if it is a node type that has a redirection set + if($op === 'insert' && strlen(variable_get('notegoto_insert_'. $node->type,'')) > 0){ + //storing only the nid is not sufficient, node_load cannot retrieve node from cache for insert + $_SESSION['notegoto_node'] = $node; + } +} + /** * Implementation of hook_form_alter(). */ @@ -40,10 +53,17 @@ function nodegoto_node_form_submit($form_id, $form_values) { //insert if (empty($form_values['nid'])) { + //retrieve node from session so that the token module works with [nid] + if(isset($_SESSION['nodegoto_node'])){ + $node = $_SESSION['nodegoto_node']; + unset($_SESSION['nodegoto_node']); + } $nodeto = module_exists('token') ? token_replace(variable_get('nodegoto_insert_'. $form_values['type'], ''), 'node', $node) : variable_get('nodegoto_insert_'. $form_values['type'], ''); } //update else { + //instantiate $node so that the token module can replace CCK field values + $node = node_load($form_values['nid'], NULL, FALSE); $nodeto = module_exists('token') ? token_replace(variable_get('nodegoto_update_'. $form_values['type'], ''), 'node', $node) : variable_get('nodegoto_update_'. $form_values['type'], ''); } if (variable_get('nodegoto_camefrom', 0) == 1) {