If you create a view of users and then try a simple action like "system action", tokenized values are not replace.

To recreate this, use the attached view (or any VBO view of users you want), click a couple of users, and choose "Display a message to the user". In the message put "[user:name]". You'll see the tokens not be expanded.

I've attached a sample view so you don't have to set one up.

CommentFileSizeAuthor
demo_user_view.txt7.19 KBrfay
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rfay’s picture

Hmm. Looks to me like this is broken in 6.x-1.x as well.

When executing the action (display tokenized message) I get

Notice: Undefined index: message in token_actions_message_action() (line 185 of /home/rfay/workspace/d6git/sites/all/modules/token/token_actions.module).
bojanz’s picture

Title: Token replacement not being done on user views » Token replacement for system actions not being done on user views
Version: 7.x-3.x-dev » 6.x-1.x-dev

Wow. The actions provided by system.module are retarded.
They can't know the entity type, so they expect an entity in $context, keyed by entity type. But then you have code like this:

function system_message_action(&$entity, $context = array()) {
  if (empty($context['node'])) {
    $context['node'] = $entity;
  }

So it provides a fallback for nodes, and node tokens work.
But note that the exact same code gets executed for all entity types, so for users you get both $context['node'] and $context['user'] pointing to the $user.
So as soon as you try a node token in an action run on users, the whole thing crashes. It really wasn't written to be used generically (outside of token module, outside of nodes).

I'm thinking of removing support for "system" actions in VBO because of this. VBO already has its own "entity" type that sane actions can use to work with any entity type.

For now I've committed a basic fix so that at least tokens for the current entity work:
http://drupalcode.org/project/views_bulk_operations.git/commitdiff/2a4bc...

Repurposing the issue for D6. Thought that might be a bug in the token_actions module.

kenorb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)