Posted by isaac.niebeling on April 28, 2008 at 4:35pm
| Project: | Token |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
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!
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| token_node_log.patch | 1.16 KB | Ignored: Check issue status. | None | None |
Comments
#1
Patch for 6.x-1.x-dev.
#2
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
#3
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]
#4
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
#5
What is this [node:title] syntax? I've only seen [node-title] syntax and in the patch there is no token labeled [node:log].
#6
Re #4, never mind... figured it out myself... revisions have to be on for the node type. Works like a charm now.
Thx, shawn
#7
Patch still works for 6.x-1.x-dev (2009-Apr-21).
#8
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.
#9
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>' : ''),#10
Use filter_xss instead of check_plain
#11
+1 this is very helpful - thanks! hope this patch makes it into the module.
#12
Subscribing
#13
Let's merge this with #383606: Would like additional tokens for (core) node revision information.
#14
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.
#15
Thanks greggles. Sometimes I forget to check that.
#16
Side note, these tokens are available if you have the Revisioning module.
#17
We'll need to provide this in D7 first and then backport since it's not provided by core in D7.
#18
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?
<?phpcase 'log':
$replacements[$original] = $sanitize ? filter_xss($node->log) : $node->log;
break;
?>
In the meantime the attached patch works for 6.x-1.12
#19
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.
#20
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.
#21
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.
#22
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...
#23
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. :/
#24
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
#25