the checks in this function could probably be re-rodered for better efficiency. We want ot avoid the node_access() calls if at all possible.

function clone_access($node) {
  global $user;
  // Check basic permissions first.
  $access = (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.
  $access = $access && node_access('view', $node);
  // Check additional conditions
  $access = $access && (clone_is_permitted($node->type) && filter_access($node->format) && node_access('create', $node->type));
  // Let other modules alter this - for exmple to only allow some users
  // to clone specific nodes or types.
  foreach (module_implements('clone_access_alter') as $module) {
    $function = $module .'_clone_access_alter';
    $function($access, $node);
  }
  return $access;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

Status: Active » Needs review
FileSize
4.58 KB
pwolanin’s picture

for 5.x-2.x (untested)

pwolanin’s picture

review anyone?

pwolanin’s picture

Status: Needs review » Fixed

committed to 6.x-1.x and 5.x-2.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.