Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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;
}
Comment | File | Size | Author |
---|---|---|---|
#2 | reorder-checks-362370-2-D5.patch | 1.3 KB | pwolanin |
#1 | reorder-checks-362370-1.patch | 4.58 KB | pwolanin |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedComment #2
pwolanin CreditAttribution: pwolanin commentedfor 5.x-2.x (untested)
Comment #3
pwolanin CreditAttribution: pwolanin commentedreview anyone?
Comment #4
pwolanin CreditAttribution: pwolanin commentedcommitted to 6.x-1.x and 5.x-2.x