You are here

function hook_content_lock_skip_locking in Content locking (anti-concurrent editing) 7.2

Same name and namespace in other branches
  1. 6.2 content_lock.api.inc \hook_content_lock_skip_locking()
  2. 7.3 content_lock.api.php \hook_content_lock_skip_locking()
  3. 7 content_lock.api.inc \hook_content_lock_skip_locking()

Determine if locking should be disabled for a given node.

This hook is called from content_lock_form_alter() before it determines that it is altering a node modification form. Thus, some of this hook's parameters are the same parameters that would be passed to hook_form_alter().

An implementation of this hook can be used to make the ability to lock a node conditional on an arbitrary aspect of the node.

Parameters

object $node: The node for which a lock might be created. This parameter may be NULL in the case that the form is for something other than a node.

string $form_id: The form_id for the node's edit form.

object $form: The form for the node's edit form.

object $form_state: The form_state for the node's edit form.

Return value

bool FALSE to indicate that locking is allowed or TRUE to prevent this node from being locked.

Related topics

1 function implements hook_content_lock_skip_locking()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

content_lock_content_lock_skip_locking in ./content_lock.module
Implements our own skip_locking api to implement our logic to skip locks.
1 invocation of hook_content_lock_skip_locking()
content_lock_form_alter in ./content_lock.module
Implements hook_form_alter().

File

./content_lock.api.php, line 78
Document content_lock hooks.

Code

function hook_content_lock_skip_locking($node, $form_id, $form, $form_state) {

  /* Avoid creating warning when $node is NULL */
  if (empty($node)) {
    return FALSE;
  }

  // Prevent locking from happening on unpublished nodes since few
  // people can access such nodes anyway.
  if (!empty($node->status)) {
    return TRUE;
  }

  // By default allow locking.
  return FALSE;
}