0

For certain node types I want to log/track each time the publish status changes from published to unpublised and from unpublished to published. I am aware I could do this with rules and write log entries into the standard log, but I don't think this is a good solution. I prefer to have a specific logtable for that, so that I can export it and that I can also show the history in a special tab of the node.

I was doing now some research, but could not find anything in this direction.

Is there a module I have not seen and which would be the solution?

If not, what would be the best approach? Thanks

0

The only module I can think of is Workbench Moderation. It may be much too large and complex for your needs, but within the node's "Moderate" tab, it provides a list of all editing actions including the change of the node's status.

Screenshot

0

Try the Event Log module. Install the event_log_node sub module and then you create a view of type 'Logged Events' and add relationships to the author and node, or visit admin/reports/events

It does not provide a publish/unpublish logging action because there is no such hook, so you should just replace the whole of the function event_log_node_update($node) function in the event_log_node.module with this one here which adds that functionality:

function event_log_node_update($node) {
  $log = array(
    'type' => 'node',
    'operation' => 'update',
    'description' => t('%type: %title', array(
      '%type' => $node->type,
      '%title' => $node->title
    )),
    'ref_numeric' => $node->nid,
    'info' => $node->original,
  );
  event_log_insert($log);

  if ($node->original->status == 0 && $node->status == 1) {
    //publish event
    $log = array(
      'type' => 'node',
      'operation' => 'publish',
      'description' => t('%type: %title', array(
        '%type' => $node->type,
        '%title' => $node->title
      )),
      'ref_numeric' => $node->nid,
      'info' => $node->original,
    );
    event_log_insert($log);
  }
  elseif ($node->original->status == 1 && $node->status == 0){
    // unpublish event
    $log = array(
      'type' => 'node',
      'operation' => 'unpublish',
      'description' => t('%type: %title', array(
        '%type' => $node->type,
        '%title' => $node->title
      )),
      'ref_numeric' => $node->nid,
      'info' => $node->original,
    );
    event_log_insert($log);
  }
}

You also might want to delete the function in that same file

function event_log_node_init() 

as it adds a log entry for every view and that will clutter up the log. If you do clear the cache.

  • Thanks, taht's great. I did not find this module and thanks for the code. I will try it. best regards – Beauregard Sep 15 '14 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.