? destination.patch
Index: nodereference_url.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodereference_url/nodereference_url.module,v
retrieving revision 1.9
diff -u -p -r1.9 nodereference_url.module
--- nodereference_url.module	17 May 2009 00:57:38 -0000	1.9
+++ nodereference_url.module	30 May 2009 22:33:53 -0000
@@ -56,12 +56,23 @@ function nodereference_url_link($type, $
       foreach(_nodereference_url_field_instances($field_name) as $target_type => $instance) {
         if ($instance['widget']['type'] == 'nodereference_url' && !empty($instance['widget']['node_link']['enabled'])) {
           if (!empty($field['referenceable_types'][$object->type]) && user_access('create ' . $target_type . ' content')) {
-            $links[$target_type .'_'. $field_name] = array(
-              'title' => $instance['widget']['node_link']['title'],
-              'href' => 'node/add/'. str_replace('_', '-', $instance['type_name']) .'/'. $object->nid,
-            );
-            if (!empty($instance['widget']['node_link']['hover_title'])) {
-              $links[$target_type .'_'. $field_name]['attributes']['title'] = $instance['widget']['node_link']['hover_title'];
+            if ((!empty($instance['widget']['node_link']['teaser']) && $teaser == TRUE)
+                || (!empty($instance['widget']['node_link']['full']) && $teaser == FALSE)) {
+              $links[$target_type .'_'. $field_name] = array(
+                'title' => $instance['widget']['node_link']['title'],
+                'href' => 'node/add/'. str_replace('_', '-', $instance['type_name']) .'/'. $object->nid,
+              );
+              if (!empty($instance['widget']['node_link']['hover_title'])) {
+                $links[$target_type .'_'. $field_name]['attributes']['title'] = $instance['widget']['node_link']['hover_title'];
+              }
+              if (!empty($instance['widget']['node_link']['destination'])) {
+                if ($instance['widget']['node_link']['destination'] == 'source') {
+                  $links[$target_type .'_'. $field_name]['query'] = drupal_get_destination();
+                }
+                elseif ($instance['widget']['node_link']['destination'] == 'node') {
+                  $links[$target_type .'_'. $field_name]['query'] = 'destination='. urlencode(drupal_get_path_alias('node/'. $object->nid));
+                }
+              }
             }
           }
         }
@@ -154,6 +165,27 @@ function nodereference_url_widget_settin
           '#default_value' => isset($widget['node_link']['hover_title']) ? $widget['node_link']['hover_title'] : '',
           '#description' => t('Text shown while hovering over the link.'),
         );
+        $form['node_link']['teaser'] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Show on teaser'),
+          '#default_value' => isset($widget['node_link']['teaser']) ? $widget['node_link']['teaser'] : FALSE,
+        );
+        $form['node_link']['full'] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Show on full view'),
+          '#default_value' => isset($widget['node_link']['full']) ? $widget['node_link']['full'] : TRUE,
+        );
+        $form['node_link']['destination'] = array(
+          '#type' => 'select',
+          '#title' => t('Return path'),
+          '#default_value' => isset($widget['node_link']['destination']) ? $widget['node_link']['destination'] : 'default',
+          '#options' => array(
+            'default' => t('The default location'),
+            'node' => t('The node being referenced'),
+            'source' => t('The page the link was clicked on'),
+          ),
+          '#description' => t('The path to return to after creating the node.'),
+        );
       }
       return $form;
 
