Diff-to-email functionality
Ian Ward - January 31, 2007 - 19:20
| Project: | Diff |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I imagine this would be a separate module - the ability to send an admin the diff of the newest and previous revision for a node. Does anyone have ideas for starting points or another module that may already be on the way to doing this?
Ian

#1
yeah, thats a killer feature that we should offer in this module. i'm pretty sure the plumbing is there for this in diffEngine.php
#2
+1 for this feature.
#3
Might be nice to represent diff data in RSS as well ... for wikis?
#4
We also need a specification for whom the diffs should be sent to? Is this a hook for subscription module? Do folks sign up for this? How do folks see this working?
#5
I like the idea of subscriptions, so it could be one a node by node basis, along with a permission to be able to subscribe to diff via email, or this is just the same permission as the ability to see a diff.
Also, I recently heard the question "where can I go and subscribe to see all the changes that happened just on one book - or all the revisions?" which makes me think, it would be nice to be able to subscribe to diff-by-email on a per-book basis, as another idea or matter of scope for the subscription idea.
#6
A diff-RSS would be very nice. That could in itself be distributed by email through external "tools".
Should have a permission setting so that only desired roles such as CM or moderator could use this.
I can think of several situations that suggest having the possibility to limit this by role.
#7
Hmmm, more a subscriptions-module feature or the like, perhaps, but come to think of this:
It should be possible for each user to set how often such emails are received.
If so, then several diffs might happen inbetween the previous and current email...
Wouldn't that mean that the diff module needs to check which is the last one received, and make the diff from there?
Do we need a way to receive each revision diff, or only the comparison between the last one and the current one?
What if the user has visited and viewed some diffs online meanwhile, should that be tracked and taken into account?
#8
I am in need of this feature and am currently working on it. My implementation idea was to simply try to create a token with the latest diff. The token could then be put into Notifications/messages. I'm trying out calling the _diff_body_rows function directly, but haven't quite figured out how I am supposed to pass the parameters. Anyone else working on this or have more ideas?
#9
Can I suggest that making this diff module work with the 'token' module (http://drupal.org/node/307140) and/or the 'rules' module would do everything that is needed for most people.
For example, this would allow the diff of a page to be automatically emailed to an administrator when that page is modified.
Very useful.
#10
Thats a great idea, but token has performance issues and this would make it worse.
#11
Hey, so I have a module that I developed which uses the Diff module to create a diff-to-email functionality. It does this by creating a token, and then I use the token in my notifications. I haven't got CVS access yet, so for those who are still interested in this let me know and I can post it up somewhere for you. Obviously, it is still in development, but for now it does the trick quite nicely. Perhaps, moshe could better explain the reasons for not including this, I haven't noticed any performance issues, but I run a small site, but either way if it is a stand-alone or incorporated doesn't make too much difference.
#12
@anarchman - I agree token module is the most streamlined from the point of view of using with notifications module. I can see the potential performance issues - but there may be some way to resolve them (and the likely token API in Drupal 7 would also resolve them).
Could you perhaps post your code to this ticket? Ideally as a patch (see http://drupal.org/patch/create) but just a zip/tarball if that doesn't work. This is something I will likely be working on in the next week or so and it would be nice to have a starting point.
#13
+1, subcribing
#14
I will create a patch later, but this is using an older version so I need to update and see if it still works. The basic code itself is simple, just create a module with the code below and also add a line to your token.module under the switch ($type) statement in the function token_token_values where all the values are and add this:
$values['node-diff'] = difftoken_tokenize();That went on line 68 for me. (I know there is a better way to do this but dont have time for it just at this moment.
So then I created difftoken.module with the following code:
<?php
// $Id: difftoken.module,v 0.1 2008/10/15 12:00:00 kevin Exp $
function difftoken_tokenize() {
$it = 0;
$node_id = arg(1);
if (is_numeric($node_id)) {
$node = node_load($node_id);
$revision_list = node_revision_list($node);
foreach ($revision_list as $revision) {
if ($it == 0) {
$new_vid = $revision->vid;
}
if ($it == 1) {
$old_vid = $revision->vid;
}
if (++$it == 3) {
break;
}
}
$diff_token = diff_diffs_show(&$node, $old_vid, $new_vid);
return $diff_token;
}
}
Again, this is just a hack and not the proper way to do things, it needs some formatting on the HTML, I actually just convert it to plain text in my version I am using, but hopefully I can come back to this in a couple of weeks.
#15
Anarchman,
I'm quite new to Drupal, so maybe this is a stupid question: how do I create the difftoken module? Besides copying the code you give to difftoken.module, where should I put it? Should I create a new folder in the modules directory? How do I enable it?
Thanks, I'd really like to have this feature working on my site.
#16
Ok, I've gone through the custom module tutorial and I've created my difftoken.module. It works great, and everytime a page is modified I get an email notifying me about it. However, I only miss one thing now. In the generated mail, there is no link to the diff.css stylesheet, and thus, the difference table does not show any colors. How should I tell drupal to include the CSS file?
#17
I'd love to see this too.
#18
Hey,
A little late here, but you can use
drupal_add_css ('myfile.css');in your module and that should do it.
#19
I'm willing to code this up into a module, since I need to improve what I currently have going anyways.
The way I deliver the Diff is to
1) Put a user reference field on a node
2) Use actions to send an e-mail to the user selected in that field whenever the node is edited/updated.
3) The e-mail uses the 'diff token' to insert the diff between the latest revisions.
4) The layout of the e-mail is administered either through messaging or notifications or another platform.
There are problems with the format if you are in Drupal 5, I had to add in the the drupal_to_text functionality from D6, but the end question is, what format should the e-mail be sent in? Probably somewhere there should be a menu option to choose whether plain-text or MIME or HTML, etc.
The key question here is should this functionality go into the Diff module itself or go into a separate module?
#20
I was exploring doing this using the Notifications & Messaging framework which, given a token, might allow the one to create both a plain-text or MIME option in the messaging template.
This would be an awesome addition!
#21
+1
#22
So what I need is one of the maintainers to state whether or not this should go into Diff or should be its own module...