? .DS_Store
? attach_token.patch
? views_attach_optional_token.patch
Index: views_attach.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_attach/views_attach.info,v
retrieving revision 1.1.2.1.2.1
diff -u -p -r1.1.2.1.2.1 views_attach.info
--- views_attach.info	3 Jun 2009 22:25:34 -0000	1.1.2.1.2.1
+++ views_attach.info	24 Jun 2009 02:16:20 -0000
@@ -3,5 +3,5 @@ name = Views attach
 description = Provides new Views display types that can be attached to nodes or users.
 core = 6.x
 dependencies[] = views
-dependencies[] = token
+suggests[] = token
 package = Views
Index: views_attach.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_attach/views_attach.module,v
retrieving revision 1.1.2.9.2.5
diff -u -p -r1.1.2.9.2.5 views_attach.module
--- views_attach.module	15 Jun 2009 19:12:34 -0000	1.1.2.9.2.5
+++ views_attach.module	24 Jun 2009 02:16:21 -0000
@@ -50,7 +50,9 @@ function views_attach_user($op, &$edit, 
       foreach ($views as $info) {
         $view = views_get_view($info['name']);
         $view->set_display($info['display']);
-        $result = $view->execute_display($info['display'], $account->uid);
+        
+        $view->current_account = $account;
+        $result = $view->execute_display($info['display']);
         if (!empty($result)) {
           $account->content[$view->name . '_' . $info['display']] = array(
             '#type' => 'user_profile_category',
@@ -90,7 +92,9 @@ function views_attach_nodeapi(&$node, $o
       foreach ($views as $info) {
         $view = views_get_view($info['name']);
         $view->set_display($info['display']);
-        $result = $view->execute_display($info['display'], array($node->nid));
+        
+        $view->current_node = $node;
+        $result = $view->execute_display($info['display']);
         if (!empty($result)) {
           $node->content[$view->name . '_' . $info['display']] = array(
             '#weight' => module_exists('content') ? content_extra_field_weight($node->type, $view->name . '_' . $info['display']) : 10,
Index: views_attach_plugin_display_node_content.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_attach/views_attach_plugin_display_node_content.inc,v
retrieving revision 1.1.2.7.2.3
diff -u -p -r1.1.2.7.2.3 views_attach_plugin_display_node_content.inc
--- views_attach_plugin_display_node_content.inc	15 Jun 2009 19:12:34 -0000	1.1.2.7.2.3
+++ views_attach_plugin_display_node_content.inc	24 Jun 2009 02:16:21 -0000
@@ -10,6 +10,7 @@ class views_attach_plugin_display_node_c
 
     $options['types'] = array('default' => array());
     $options['modes'] = array('default' => array('full'));
+    $options['argument_mode'] = array('default' => 'token');
     $options['default_argument'] = array('default' => '');
     $options['show_title'] = 0;
 
@@ -57,12 +58,11 @@ class views_attach_plugin_display_node_c
       $weight = 10;
     }
 
-    //TODO: rename "argument" to "arguments string"?
-    $default_argument = $this->get_option('default_argument');
-    $options['default_argument'] = array(
+    $argument_mode = $this->get_option('argument_mode');
+    $options['arguments'] = array(
       'category' => 'node_content',
-      'title' => t('Default argument'),
-      'value' => empty($default_argument) ? t('None') : check_plain($default_argument),
+      'title' => t('Arguments'),
+      'value' => empty($argument_mode) ? t('None') : check_plain($argument_mode),
     );
 
     $options['show_title'] = array(
@@ -102,16 +102,36 @@ class views_attach_plugin_display_node_c
          );
          break;
 
-      case 'default_argument':
-        $form['#title'] .= t('Default argument');
-        $form['default_argument'] = array(
-          '#type' => 'textfield',
-          '#default_value' => $this->get_option('default_argument'),
-          '#description' => t('Separate arguments with "/".'),
+      case 'arguments':
+        $form['#title'] .= t('Arguments');
+        
+        $default = $this->get_option('argument_mode');
+        $options = array(
+          'none' => t('None'),
+          'nid' =>  t('Current node ID'),
         );
-        // Add the token help to the form.
-        $form['help'] = array(
-          '#value' => t('You may use token replacement to provide arguments based on the node. Token replacements require that NID is the first argument of the URL for the view.') . theme('token_help', 'node'),
+
+        // Add the extra option for Tokens if the module is enabled.
+        // If it isn't, ensure that we dont' default to 'token'.
+        if (module_exists('token')) {
+          $options['token'] = t('Dynamic tokens');
+          $form['default_argument'] = array(
+            '#type' => 'textfield',
+            '#default_value' => $this->get_option('default_argument'),
+            '#description' => t('You may use token replacement to provide arguments based on the current node. Separate arguments with "/".') . theme('token_help', 'node'),
+            '#process' => array('views_process_dependency'),
+            '#dependency' => array('radio:argument_mode' => array('token')),
+          );
+        }
+        elseif ($default == 'token') {
+          $default = 'none';
+        }
+        
+        $form['argument_mode'] = array(
+          '#type' => 'radios',
+          '#options' => $options,
+          '#default_value' => $default,
+          '#weight' => -1,
         );
         break;
 
@@ -137,43 +157,52 @@ class views_attach_plugin_display_node_c
       case 'modes':
         $this->set_option('modes', array_values(array_filter($form_state['values']['modes'])));
         break;
-      case 'default_argument':
-        $this->set_option('default_argument', $form_state['values']['default_argument']);
+      case 'arguments':
+        $this->set_option('argument_mode', $form_state['values']['argument_mode']);
+        if ($form_state['values']['argument_mode'] == 'token') {
+          $this->set_option('default_argument', $form_state['values']['default_argument']);
+        }
+        else {
+          $this->set_option('default_argument', NULL);          
+        }
         break;
       case 'show_title':
         $this->set_option('show_title', $form_state['values']['show_title']);
         break;
     }
   }
+
   /**
    * We have to run token replacement before the arguments are used.
    */
-   function pre_execute() {
-     // Call the parent setup function so we do not lose data.
-     parent::pre_execute();
-     $args = $this->view->args;
-     $token_string = $this->view->display_handler->get_option('default_argument');
-     if (empty($args) || empty($token_string)) {
-       return;
-     }
-     $node_types = $this->view->display_handler->get_option('types');
-
-     $node = node_load($args[0]);
-
-     if (!in_array($node->type, $node_types)) {
-       return;
-     }
-
-     // Now do the token replacement.
-     $token_values = views_attach_get_arguments_from_token_string($token_string, 'node', $node);
-     $new_args = array();
-     // We have to be careful to only replace arguments that have tokens.
-     foreach ($token_values as $key => $value) {
-       $new_args[$key] = $value;
-     }
-
-     $this->view->args = $new_args;
-   }
+  function pre_execute() {
+    // Call the parent setup function so we do not lose data.
+    parent::pre_execute();
+
+    $node = $this->view->current_node;
+    $node_types = $this->view->display_handler->get_option('types');
+    if (!in_array($node->type, $node_types)) {
+      return;
+    }
+
+    $arg_mode = $this->view->display_handler->get_option('argument_mode');
+    if (module_exists('token') && $arg_mode == 'token') {
+      if ($token_string = $this->view->display_handler->get_option('default_argument')) {
+        // Now do the token replacement.
+        $token_values = views_attach_get_arguments_from_token_string($token_string, 'node', $node);
+        $new_args = array();
+        // We have to be careful to only replace arguments that have tokens.
+        foreach ($token_values as $key => $value) {
+          $new_args[$key] = $value;
+        }
+    
+        $this->view->args = $new_args;
+      }
+    }
+    elseif ($arg_mode == 'nid') {
+      $this->view->args = array($node->nid);
+    }
+  }
 
   /**
    * The display block handler returns the structure necessary for a block.
Index: views_attach_plugin_display_profile.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_attach/views_attach_plugin_display_profile.inc,v
retrieving revision 1.1.2.1.2.4
diff -u -p -r1.1.2.1.2.4 views_attach_plugin_display_profile.inc
--- views_attach_plugin_display_profile.inc	15 Jun 2009 19:12:34 -0000	1.1.2.1.2.4
+++ views_attach_plugin_display_profile.inc	24 Jun 2009 02:16:21 -0000
@@ -10,6 +10,7 @@ class views_attach_plugin_display_profil
 
     $options['weight'] = array('default' => 10);
     $options['category'] = array('default' => NULL);
+    $options['argument_mode'] = array('default' => 'token');
     $options['default_argument'] = array('default' => '');
 
     return $options;
@@ -49,12 +50,12 @@ class views_attach_plugin_display_profil
       'title' => t('Weight'),
       'value' => $weight,
     );
-
-    $default_argument = $this->get_option('default_argument');
-    $options['default_argument'] = array(
+    
+    $argument_mode = $this->get_option('argument_mode');
+    $options['arguments'] = array(
       'category' => 'profile',
-      'title' => t('Default argument'),
-      'value' => empty($default_argument) ? t('None') : check_plain($default_argument),
+      'title' => t('Arguments'),
+      'value' => empty($argument_mode) ? t('None') : check_plain($argument_mode),
     );
   }
 
@@ -82,16 +83,36 @@ class views_attach_plugin_display_profil
           '#default_value' => $this->get_option('category'),
         );
         break;
-      case 'default_argument':
-        $form['#title'] .= t('Default argument');
-        $form['default_argument'] = array(
-          '#type' => 'textfield',
-          '#default_value' => $this->get_option('default_argument'),
-          '#description' => t('Separate arguments with "/".'),
+      case 'arguments':
+        $form['#title'] .= t('Arguments');
+        
+        $default = $this->get_option('argument_mode');
+        $options = array(
+          'none' => t('None'),
+          'uid' =>  t('Profile user ID'),
         );
-        // Add the token help to the form.
-        $form['help'] = array(
-          '#value' => '<p>'. t('You may use token replacement to provide arguments based on the user. Token replacements require that UID is the first argument of the URL for the view.') .'</p>'. theme('token_help', 'user'),
+
+        // Add the extra option for Tokens if the module is enabled.
+        // If it isn't, ensure that we dont' default to 'token'.
+        if (module_exists('token')) {
+          $options['token'] = t('Dynamic tokens');
+          $form['default_argument'] = array(
+            '#type' => 'textfield',
+            '#default_value' => $this->get_option('default_argument'),
+            '#description' => t('You may use token replacement to provide arguments based on the current user profile. Separate arguments with "/".') . theme('token_help', 'user'),
+            '#process' => array('views_process_dependency'),
+            '#dependency' => array('radio:argument_mode' => array('token')),
+          );
+        }
+        elseif ($default == 'token') {
+          $default = 'none';
+        }
+        
+        $form['argument_mode'] = array(
+          '#type' => 'radios',
+          '#options' => $options,
+          '#default_value' => $default,
+          '#weight' => -1,
         );
         break;
     }
@@ -107,8 +128,14 @@ class views_attach_plugin_display_profil
       case 'category':
         $this->set_option('category', $form_state['values']['category']);
         break;
-      case 'default_argument':
-        $this->set_option('default_argument', $form_state['values']['default_argument']);
+      case 'arguments':
+        $this->set_option('argument_mode', $form_state['values']['argument_mode']);
+        if ($form_state['values']['argument_mode'] == 'token') {
+          $this->set_option('default_argument', $form_state['values']['default_argument']);
+        }
+        else {
+          $this->set_option('default_argument', NULL);          
+        }
         break;
     }
   }
@@ -116,27 +143,28 @@ class views_attach_plugin_display_profil
   /**
    * We have to run token replacement before the arguments are used.
    */
-   function pre_execute() {
-     // Call the parent setup function so we do not lose data.
-     parent::pre_execute();
-     $args = $this->view->args;
-     $token_string = $this->view->display_handler->get_option('default_argument');
-     if (empty($args) || empty($token_string)) {
-       return;
-     }
-
-     $user = user_load($args[0]);
-
-      // Now do the token replacement.
-     $token_values = views_attach_get_arguments_from_token_string($token_string, 'user', $user);
-     $new_args = array();
-     // We have to be careful to only replace arguments that have tokens.
-     foreach ($token_values as $key => $value) {
-       $new_args[$key] = $value;
-     }
-
-     $this->view->args = $new_args;
-   }
+  function pre_execute() {
+    // Call the parent setup function so we do not lose data.
+    parent::pre_execute();
+    $account = $this->view->current_account;
+    $arg_mode = $this->view->display_handler->get_option('argument_mode');
+    if (module_exists('token') && $arg_mode == 'token') {
+      if ($token_string = $this->view->display_handler->get_option('default_argument')) {
+        // Now do the token replacement.
+        $token_values = views_attach_get_arguments_from_token_string($token_string, 'user', $account);
+        $new_args = array();
+        // We have to be careful to only replace arguments that have tokens.
+        foreach ($token_values as $key => $value) {
+          $new_args[$key] = $value;
+        }
+    
+        $this->view->args = $new_args;
+      }
+    }
+    elseif ($arg_mode == 'uid') {
+      $this->view->args = array($account->uid);
+    }
+  }
 
   /**
    * The display block handler returns the structure necessary for a block.
