Comment tokens in tokenized e-mail actions

rkdesantos - December 1, 2008 - 16:17
Project:Actions token email
Version:5.x-1.0
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

I'd like to be able to use comment tokens in a tokenized e-mail action for use when comments are added or updated. However, the comment tokens do not seem to be available when creating the action.

Is there an easy patch or fix I can do that would add those to the available tokens in this case? Or perhaps make all tokens available for these actions? Thanks for the help.

#1

rkdesantos - February 16, 2009 - 02:23

Is any further work being done on this module? For either v5 or v6?

#2

hakcayurek - March 9, 2009 - 05:01

I had the same problem. Looks like actions_token_email defaults to node. For example, in tokens list,
it specically calls node related tokens (look at
'#value' => theme('token_help', 'node', '%', ''),
line 43. It should look at the token list based on the context. However, more improtantly, the message is setup using only node context, regardless of the type.
Line:134
$message = token_replace($context['message'], 'node', $node, '%', '');

My quick and dirty fix is to replace the above line with:
if($context['hook']=="comment") {
$message = token_replace($context['message'], 'comment', $comment, '%', '');
}else
$message = token_replace($context['message'], 'node', $node, '%', '');

I'm not familiar with other modules (such as user etc.), so I don't want to change the source, but ideally, two variables must set inside the case statement.
1. active context,
2. string-respresenting that context,
and message must be set by using those variables. same goes for token_help hook.

#3

rkdesantos - March 10, 2009 - 01:29

Thanks, I have done a modificatoin based on your post and we will see how it works.

I also changed the earlier line to be 'all' instead of 'node'. Not optimal but it does make the full token list available in the drop down and from an admin standpoint that is good enough at the moment.

My only concern is if we change the context that we don't lose access to tokens such as %author-uid or %title. But that's niggling since this should get me 80% of the way there.

#4

hakcayurek - March 11, 2009 - 03:06

Glad that was helpful. I also have the same problem with loosing some other tokens (e.g., nid), Those tokens are still reachable at subject, so I send the url to the node where the comment attached in the title :)

 
 

Drupal is a registered trademark of Dries Buytaert.