You are here

function content_lock_content_lock_skip_locking in Content locking (anti-concurrent editing) 7

Same name and namespace in other branches
  1. 6.2 content_lock.module \content_lock_content_lock_skip_locking()
  2. 6 content_lock.module \content_lock_content_lock_skip_locking()
  3. 7.3 content_lock.module \content_lock_content_lock_skip_locking()
  4. 7.2 content_lock.module \content_lock_content_lock_skip_locking()

File

./content_lock.module, line 274
Allows users to lock documents for modification.

Code

function content_lock_content_lock_skip_locking($node, $form_id, $form, $form_state) {
  global $user;
  $nid = empty($form['nid']['#value']) ? NULL : $form['nid']['#value'];

  /* support the node revision form by not requiring the form to have an 'nid' key */
  if (empty($nid) && $form_id == 'node_revision_revert_confirm' && !empty($form['#node_revision'])) {
    $nid = $node->nid;
  }

  // Locked node types. Dont mix this up with the content_types you can chose on the admin form of content lock
  // this types are forced due to disfunctionality
  $node_type_blacklist = array(
    'user' => TRUE,
  );

  // Form ids listed here will not be locked
  $form_id_blacklist = array(
    'comment_form' => TRUE,
  );
  if ($node != NULL) {
    $form_id_blacklist['node_type_form'] = TRUE;

    // add the node-type administration
  }

  // Let other modules modify our blacklist
  drupal_alter('content_lock_form_id_blacklist', $form_id_blacklist, $node);
  if ($node == NULL || empty($nid) || !empty($node_type_blacklist[$node->type]) || !empty($form_id_blacklist[$form_id]) || $user->uid <= 0 || !user_access('check out documents') || $form_id != $node->type . '_node_form' && $form_id != 'node_revision_revert_confirm') {

    // Preconditions failed, skip the lock
    return TRUE;
  }

  // Check if the current node type and format type is configured to be locked
  // $node->content_lock_old_format has been set in content_lock_form_alter().
  if (!_content_lock_is_lockable_node($node)) {

    // It should not be locked, so skip the lock
    return TRUE;
  }

  // we have no veto, so lock the node
  return FALSE;
}