I made some modifications in nofitications_content.module - node revisions token values:
function notifications_content_nodeapi();
[code]
case 'insert':
// Notifications just for published nodes. If we don't have any option enabled for this content type, skip the event
if (!isset($done[$node->nid]) && $node->status && empty($node->notifications_content_disable) && notifications_content_type_enabled($node->type)) {
$done[$node->nid] = TRUE;
$event = array(
'module' => 'node',
'oid' => $node->nid,
'type' => 'node',
'action' => $op,
'node' => $node,
'params' => array('nid' => $node->nid, "vid" => $node->vid),
);
if ($op == 'update') {
// If the node has been published the 'update' will become a 'insert' (first post)
// In this case the event user will be the node author instead of the current user
if (!isset($node->old_status)) {
// We try to find out previous status with the cached node.
$oldnode = node_load($node->nid);
$node->old_status = $oldnode->status;
}
if (!$node->old_status) {
// The node has gone from unpublished to published, adjust event parameters
$event['uid'] = $node->uid;
$event['action'] = 'insert';
}
// If immediate sending is active, need to reset the node cache so we don't send old versions of the node
if (variable_get('notifications_send_immediate', 0)) {
node_load(0, NULL, TRUE);
}
}
notifications_event($event);
}
break;
[/code]
function notifications_content_notifications();
[code]
case 'event load': // $arg0 is event
$event = &$arg0;
$load = array();
if ($event->type == 'node') {
if (!empty($event->params['nid']) && empty($event->objects['node'])) {
if ($node = node_load($event->params['nid'])) {
$event->objects['node'] = $node;
$event->objects['revisions'] = node_load($event->params['nid'],$event->params['vid']);
}
else { // Node not available anymore, mark event for deletion
$event->delete = TRUE;
}
}
if (!empty($event->params['cid']) && empty($event->objects['comment'])) {
if ($comment = notifications_content_comment_load($event->params['cid'])) {
$event->objects['comment'] = $comment;
}
else { // Comment not available anymore, mark event for deletion
$event->delete = TRUE;
}
}
}
break;
[/code]
function notifications_content_token_list();
[code]
if ($type == 'node' || $type == 'all') {
$tokens['node']['node-teaser'] = t('The node teaser.');
$tokens['node']['node-body'] = t('The node body.');
//$tokens['node']['node-url'] = t('The node view url for read more links.');
$tokens['node']['node-teaser-raw'] = t('Unfiltered node teaser. WARNING - raw user input.');
$tokens['node']['node-body-raw'] = t('Unfiltered node body. WARNING - raw user input.');
$tokens['node']['revision-user'] = t('User of node revision');
$tokens['node']['revision-date'] = t('Date of node revision');
}
[/code]
function notifications_content_token_values();
[code]
case "revisions":
if ($revision = $object) {
$ruser = user_load($revision->revision_uid);
$values['revision-user'] = $ruser->name;
$values['revision-date'] = format_date($revision->revision_timestamp, 'small');
return $values;
}
break;
[/code]
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | notifications-revision_event_support.diff | 3.14 KB | stacysimpson |
Comments
Comment #1
LiuShaz commentedlol, please replace [code] & [/code] to <code> & </code> :)
Comment #2
LiuShaz commentedfunction notifications_content_nodeapi();
function notifications_content_notifications();
function notifications_content_token_list();
function notifications_content_token_values();
Comment #3
stacysimpson commentedWell, looks like your changes work fine when a user actually creates a new revision for node content; however, within our system, we allow certain users to optionally create new revisions. In this instance, the same data is displayed multiple times, depending on how many edits were performed without creating a new revision.
Your work inspired me to dig a little deeper; turns out the necessary information was already available in the 'notifications_event' table; we just needed to extract the information using tokens. I am re-posting a combined changeset.