You are here

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

Same name and namespace in other branches
  1. 7.3 content_lock.module \content_lock_is_path_protected()

Check if an internal Drupal path should be protected with a token.

Adds requirements that certain path be accessed only through tokenized URIs which are enforced by this module. This prevents people from being CSRFed into locking nodes that they can access without meaning to lock them.

Return value

bool Returns TRUE if the path is protected or FALSE if not protected.

2 calls to content_lock_is_path_protected()
content_lock_form_alter in ./content_lock.module
Implements hook_form_alter().
content_lock_preprocess_link in ./content_lock.module
Implements hook_preprocess_link().

File

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

Code

function content_lock_is_path_protected($path) {
  $cache =& drupal_static(__FUNCTION__, array());

  // Check cache.
  if (isset($cache[$path])) {
    return $cache[$path];
  }

  // Invoke hook and collect grants/denies for protected paths.
  $protected = array();
  foreach (module_implements('content_lock_path_protected') as $module) {
    $protected = array_merge($protected, array(
      $module => module_invoke($module, 'content_lock_path_protected', $path),
    ));
  }

  // Allow other modules to alter the returned grants/denies.
  drupal_alter('content_lock_path_protected', $protected, $path);

  // If TRUE is returned, path is protected.
  $cache[$path] = in_array(TRUE, $protected);
  return $cache[$path];
}