Index: nodereference.module
===================================================================
--- nodereference.module	(revision 194)
+++ nodereference.module	(working copy)
@@ -56,6 +56,12 @@
           $views[t('Default Views')][$view->name] = $view->name;
         }
         if (count($views) > 1) {
+          if (module_exists('token')) {
+            $tokens_help = theme('token_help', 'node', '[', ']');
+          }
+          else {
+            $tokens_help = t('You must install the token module to use tokens!');
+          }
           $form['advanced'] = array(
              '#type' => 'fieldset',
              '#title' => t('Advanced - Nodes that can be referenced (View)'),
@@ -74,7 +80,7 @@
             '#title' => t('View arguments'),
             '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
             '#required' => FALSE,
-            '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
+            '#description' => t('Provide a comma separated list of arguments to pass to the view. You may use the following tokens: '. $tokens_help),
           );
         }
       }
@@ -113,7 +119,7 @@
 function nodereference_field($op, &$node, $field, &$items, $teaser, $page) {
   switch ($op) {
     case 'validate':
-      $refs = _nodereference_potential_references($field, TRUE);
+      $refs = _nodereference_potential_references($field, TRUE, '', FALSE, $node);
       foreach ($items as $delta => $item) {
         $error_field = isset($item['error_field']) ? $item['error_field'] : '';
         unset($item['error_field']);
@@ -234,7 +240,7 @@
       case 'form':
         $form = array();
 
-        $options = _nodereference_potential_references($field, TRUE);
+        $options = _nodereference_potential_references($field, TRUE, '', FALSE, $node);
         foreach ($options as $key => $value) {
           $options[$key] = _nodereference_item($field, $value, FALSE);
         }
@@ -400,7 +406,7 @@
 /**
  * Fetch an array of all candidate referenced nodes, for use in presenting the selection form to the user.
  */
-function _nodereference_potential_references($field, $return_full_nodes = FALSE, $string = '', $exact_string = false) {
+function _nodereference_potential_references($field, $return_full_nodes = FALSE, $string = '', $exact_string = false, &$field_node = NULL) {
   if (module_exists('views') && isset($field['advanced_view']) && $field['advanced_view'] != '--' && ($view = views_get_view($field['advanced_view']))) {
     // advanced field : referenceable nodes defined by a view
     // let views.module build the query
@@ -408,8 +414,15 @@
     // arguments for the view
     $view_args = array();
     if (isset($field['advanced_view_args'])) {
-      // TODO: Support Tokens using token.module ?
-      $view_args = array_map(trim, explode(',', $field['advanced_view_args']));
+      if (module_exists('token')) {
+        if ($field_node) {
+          $view_args = token_replace($field['advanced_view_args'], $type = 'node', $object = $field_node, $leading = '[', $trailing = ']');
+        }
+        else {
+          $view_args = token_replace($field['advanced_view_args'], $type = 'global', $object = NULL, $leading = '[', $trailing = ']');
+        }
+      }
+      $view_args = array_map(trim, explode(',', $view_args));
     }
 
     if (isset($string)) {
