You are here

function node_entity_revision_operation_access in Revision scheduler 7

Implements hook_entity_revision_operation_access() on behalf of node.module.

File

./revision_scheduler.module, line 879

Code

function node_entity_revision_operation_access($operation, $entity_type, $entity, $account) {
  if ($entity_type == 'node') {
    switch ($operation['operation']) {
      case 'delete':
      case 'revert':
        if (empty($entity->nid)) {

          // Cannot schedule reversion or deletion of new nodes.
          return FALSE;
        }
        else {

          // node_revision_delete() will fail if this revision is the node's
          // current revision.
          // Also does not make sense to revert to the node's current revision.
          $node = node_load($entity->nid);
          if ($entity->vid == $node->vid) {
            return FALSE;
          }
        }
        break;
    }
  }
}