Attached is a patch to add a token for the log message attached to each node. Four lines added, and now I can include the log message in the email that workflow-ng sends to my users. Take a look.

(patch is against 1.10 since 1.11 just came out today and I haven't had a chance to update yet)

Thanks!

Comments

EmanueleQuinto’s picture

StatusFileSize
new1.18 KB

Patch for 6.x-1.x-dev.

merilainen’s picture

Should this show up in the "available tokens" list?
I'm trying to include the possible log-message in email using Messaging and Notifications modules.
For example:

A [type-name] was updated in group "[ogname]" with title "[title]"
Log message: "[log]"
View page [node-url].

This should print something like:
A Wikipage was updated in group "Development" with title "Problems"
Log message: "Changes in the listing order"
View page http://www.example.com/wiki/problems

EmanueleQuinto’s picture

In our site we use something like this (and it works):

[user:user] has edited the country page [node:title] and your action is required. 

Summary of changes: 
[node:log]
sdsheridan’s picture

Great little patch. Just one question, and sorry if this is the wrong place for it, but it appears that only user 1 on my site actually has the "log:" field displaying on nodes, and not the regular authenticated users. I've not figured out why yet, and wondering if anyone might know.

Drupal 5.16 is the version i'm using.

Thanks in advance, Shawn

merilainen’s picture

What is this [node:title] syntax? I've only seen [node-title] syntax and in the patch there is no token labeled [node:log].

sdsheridan’s picture

Re #4, never mind... figured it out myself... revisions have to be on for the node type. Works like a charm now.

Thx, shawn

EmanueleQuinto’s picture

Version: 5.x-1.10 » 6.x-1.x-dev

Patch still works for 6.x-1.x-dev (2009-Apr-21).

merilainen’s picture

I can confirm that the patch works nicely.
Now I just need to find a way to force users to write that log message, which is always forgotten.

greggles’s picture

Status: Needs review » Needs work

I think check_plain is too aggressive of a filtering function. Core uses filter_xss for this: http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/node/node.pages.in...

. (($revision->log != '') ? '<p class="revision-log">'. filter_xss($revision->log) .'</p>' : ''),
EmanueleQuinto’s picture

StatusFileSize
new1.17 KB

Use filter_xss instead of check_plain

tobias’s picture

+1 this is very helpful - thanks! hope this patch makes it into the module.

smithmb’s picture

Subscribing

dave reid’s picture

Status: Needs work » Closed (duplicate)
greggles’s picture

Title: Add token for node->log » Add tokens for node revision timestamp, author, and log message
Status: Closed (duplicate) » Needs work

But #383606: Would like additional tokens for (core) node revision information is newer and has no code. This at least has some code.

So, if you want to merge lets add revision author and revision timestamp as features in here.

dave reid’s picture

Thanks greggles. Sometimes I forget to check that.

dave reid’s picture

Side note, these tokens are available if you have the Revisioning module.

dave reid’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

We'll need to provide this in D7 first and then backport since it's not provided by core in D7.

EmanueleQuinto’s picture

Version: 7.x-1.x-dev » 6.x-1.12
StatusFileSize
new1.1 KB

Dear Dave, I understand the point, but I guess someone will use the d6 version for some time yet.

A backport would make sense once the drupal 7 will be out (and used in production site), while in the time being people will stay with d6 version of this module. I'll try to work on a d7 version but, as many others, I'm still working daily with d6.

Moreover is not clear to me one point: if part of token becomes part of the core and we need a new token, would this postponed to drupal 8 on the basis that new functionalities in core should be deferred to a new major version? We'll have to wait d8 to have log messages available as token? Four lines integrated in 2011 (to be optimistic)?

Did we need to add 4 lines below on node_tokens() function (modules/node/node.tokens.inc, line 96) to have a solution for d7. It's too late?

        case 'log':
          $replacements[$original] = $sanitize ? filter_xss($node->log) : $node->log;
          break;

In the meantime the attached patch works for 6.x-1.12

dave reid’s picture

Version: 6.x-1.12 » 7.x-1.x-dev

It would be added to token.module code here in the D7 version, not in D7 core. So it would not take long for someone just to make a patch here and I can commit it after review.

EmanueleQuinto’s picture

StatusFileSize
new963 bytes

This patch implements log token in D7 using the tokens hook in token.tokens.inc (at least I hope, looking in the code without much testing).

In drupal 8 this maybe will be included in node_tokens() function (modules/node/node.tokens.inc, line 96) but now is definitively too late.

dave reid’s picture

Thanks for working on this! :)

+++ token.tokens.inc	7 Jun 2010 16:02:43 -0000
@@ -46,6 +51,9 @@ function token_tokens($type, $tokens, ar
+          $replacements[$original] = $sanitize ? filter_xss($node->log);
+	  break;

You're missing the 'else' condition on your ternary. Plus I bet this should be using check_plain():

$sanitize ? check_plain($node->log) ? $node->log;

Tabs or space mis-match on the 'break'; line.

Powered by Dreditor.

EmanueleQuinto’s picture

Title: Add tokens for node revision timestamp, author, and log message » Add tokens for log message
StatusFileSize
new1.1 KB
new984 bytes
new983 bytes

Here we are...

Attached you'll find 3 patch:

1) d7 with filter_xss
2) d7 with check_plain
3) d6 with check_plain

Patch with filter_xss for d6 is on #18.

Initial patch (#1) uses check_plain but greggles pointed out at #9 that "check_plain is too aggressive of a filtering function. Core uses filter_xss for this". And d7 HEAD still uses filter_xss.

Melius abundare quam deficere, so both version for d6 and d7 are there...

Changed the title reflecting the patch...

dave reid’s picture

Ok I just double-checked how $node->log is filtered in core and it does use filter_xss so we'd go with that. I should have done that before, sorry. :/

dave reid’s picture

Great, committed an updated version of the patch with tests to CVS for all D7, D6, and D5:
http://drupal.org/cvs?commit=376874
http://drupal.org/cvs?commit=376880
http://drupal.org/cvs?commit=376900

dave reid’s picture

Title: Add tokens for log message » Add tokens for node revision timestamp, author, and log message
technikh’s picture

I don't see these tokens in 7.x-1.5 version