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

wences_sz’s picture

Issue summary: View changes
wences_sz’s picture

Issue summary: View changes
joelpittet’s picture

This was fixed in the dev version 7.x-1.x.

 if ($node->nid && isset($allowed_types[$node->type]) && !empty($allowed_types[$node->type]) &&

Want to give that a try @wences_sz?

joelpittet’s picture

Oh 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...

samwilson’s picture

This seems to be fixed. Here's a patch for a test to check that it has been.

joelpittet’s picture

Version: 7.x-1.3 » 7.x-1.x-dev

Wonder why the testbot din't run. Swapping the version to see if it will kick in.

samwilson’s picture

I think the automated testing has to be turned on for this project. I guess it then attempts to test any attached file with a .patch extension?

joelpittet’s picture

Assigned: wences_sz » Unassigned
Status: Needs review » Needs work
joelpittet’s picture

Status: Needs work » Needs review
joelpittet’s picture

The last submitted patch, 5: nodeaccess-test_grant_tab_visibility-2347315-5.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: nodeaccess-test_grant_tab_visibility-2347315-5.patch, failed testing.

vlad.pavlovic’s picture

Status: Needs work » Needs review
StatusFileSize
new1.48 KB
vlad.pavlovic’s picture

Status: Needs review » Needs work

The last submitted patch, 13: nodeaccess-test_grant_tab_visibility-2347315-11.patch, failed testing.

vlad.pavlovic’s picture

Status: Needs work » Needs review
StatusFileSize
new2.09 KB

Messed up the previous patch, rerolled.

vlad.pavlovic’s picture

OK, good to go, committing to dev. Thank you both! We now have a starting point for automated testing (yay!).

vlad.pavlovic’s picture

Status: Needs review » Fixed

  • vlad.pavlovic committed ec3f215 on 7.x-1.x
    Issue #2347315 by vlad.pavlovic, joelpittet, samwilson: Bug with...
samwilson’s picture

Thanks! :)

Status: Fixed » Closed (fixed)

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

avpaderno’s picture

Issue tags: -nodeaccess, -#tabs