If you want to show grant tab only for some selected content types, you can choose the content types and the form will be save correctly, but then, when you see a node form, you going to see the grant tab anyway , that is because the node access module is checked incorrectly the node access-types variable:
This is the problem:
nodeaccess.module
$allowed_types = variable_get('nodeaccess-types', array());
if ($op == 'grant') {
if ($node->nid && isset($allowed_types[$node->type]) &&
(user_access('grant node permissions', $account) ||
(user_access('grant editable node permissions', $account) && node_access('update', $node, $account)) ||
(user_access('grant deletable node permissions', $account) && node_access('delete', $node, $account)) ||
(user_access('grant own node permissions', $account) && ($account->uid == $node->uid)))) {
return TRUE;
}
}
return FALSE;
the code ask if exists the array $allowed_types but is not checking if the type is true or false, so allways will be true.
Solution:
$allowed_types = variable_get('nodeaccess-types', array());
if ($op == 'grant') {
if ($node->nid && isset($allowed_types[$node->type]) && $allowed_types[$node->type] &&
(user_access('grant node permissions', $account) ||
(user_access('grant editable node permissions', $account) && node_access('update', $node, $account)) ||
(user_access('grant deletable node permissions', $account) && node_access('delete', $node, $account)) ||
(user_access('grant own node permissions', $account) && ($account->uid == $node->uid)))) {
return TRUE;
}
}
return FALSE;
Comments
Comment #1
wences_sz commentedComment #2
wences_sz commentedComment #3
joelpittetThis was fixed in the dev version 7.x-1.x.
Want to give that a try @wences_sz?
Comment #4
joelpittetOh shameless plug: https://www.drupal.org/node/2334565#comment-9251159
Check out that UI change if you have a sec, maybe it's helpful too? kinda related...
Comment #5
samwilson commentedThis seems to be fixed. Here's a patch for a test to check that it has been.
Comment #6
joelpittetWonder why the testbot din't run. Swapping the version to see if it will kick in.
Comment #7
samwilson commentedI think the automated testing has to be turned on for this project. I guess it then attempts to test any attached file with a
.patchextension?Comment #8
joelpittetComment #9
joelpittetComment #10
joelpittetComment #13
vlad.pavlovic commentedComment #14
vlad.pavlovic commentedComment #16
vlad.pavlovic commentedMessed up the previous patch, rerolled.
Comment #17
vlad.pavlovic commentedOK, good to go, committing to dev. Thank you both! We now have a starting point for automated testing (yay!).
Comment #18
vlad.pavlovic commentedComment #20
samwilson commentedThanks! :)
Comment #22
avpaderno