You are here

function clone_access_cloning in Node clone 7

Same name and namespace in other branches
  1. 5.2 clone.module \clone_access_cloning()
  2. 5 clone.module \clone_access_cloning()
  3. 6 clone.module \clone_access_cloning()
2 calls to clone_access_cloning()
clone_form_node_admin_content_alter in ./clone.module
Implements hook_form_FORM_ID_alter().
views_handler_field_node_link_clone::render_link in views/views_handler_field_node_link_clone.inc
Renders the link.
1 string reference to 'clone_access_cloning'
clone_menu in ./clone.module
Implementation of hook_menu().

File

./clone.module, line 94
Allow users to make a copy of an item of content (a node) and then edit that copy.

Code

function clone_access_cloning($node, $check_token = FALSE, $token = FALSE) {
  global $user;

  // Check CSRF token if needed.
  if ($check_token) {
    if (!$token || $token !== clone_get_token($node->nid)) {
      return FALSE;
    }
  }

  // Check basic permissions first.
  $access = clone_is_permitted($node->type) && (user_access('clone node') || $user->uid && $node->uid == $user->uid && user_access('clone own nodes'));

  // Make sure the user can view the original node content, and create a new one..
  $access = $access && node_access('view', $node) && node_access('create', $node->type);

  // Let other modules alter this.
  drupal_alter("clone_access", $access, $node);
  return $access;
}