UPDATE: made into a full module, available at http://drupal.org/project/enforce_revlog

If you have several editors for your website's content, it's probable you'll want to be able to easily track the modifications made by each one on the pages.

When enabling node revisions, you can have access to every previous version of a node. But having to dig into former revisions to know what has been done, or to revert to a given point in the past, is not that practical. Enter log messages. Each time someone updates a node where revisions are enabled, one can leave a comment on what has been done. The problem with log messages is that there is no way to make them mandatory, and you'll soon notice that users often forget or disregard what is only optional.

This issue was posted on a forum thread and below is copied the way to make mandatory to write a revision log message. Please note that it applies for all roles, and all nodes having revisions enabled. It would need some refinement for it to be able to be limited to some roles and content types.

Save this as enforce_revlog.info below sites/all/modules/enforce_revlog/ (or where ever you like to place your modules):

name = Enforce revlog
description = Enforce log messages for every revision
core = 6.x
package = "Other"

Save this as enforce_revlog.module in the same directory:

<?php
function enforce_revlog_nodeapi(&$node, $op, $arg = 0){
 
  switch($op)
  {
    case 'validate':
      // if revision is checked and log message is empty, complain.
      // add "&& $node->nid" below to ignore empty log for new content.
      if ( $node->revision && empty($node->log) ) {
        if ( user_access('administer nodes')) 
          form_set_error('log', t('Please enter a revision log message or uncheck the revision checkbox.'));
        else
          form_set_error('log', t('Please enter a revision log message.'));
      }
    }
}
?>

Then enable the "Enforce revlog" module and you are done.

Comments