Look at this code:

#v+
$grants[] = array(
'realm' => 'example',
'gid' => TRUE,
'grant_view' => TRUE,
'grant_update' => FALSE,
'grant_delete' => FALSE,
'priority' => 0,
);
#v-

When I use "'gid' => TRUE" it works incorrect, it will add to node_access table lines like that ignoring all other realms for this node:

nid gid realm grant_view grant_update grant_delete
5 0 all 1 0 0

But when I use "'gid' => TRUE" it will work ok and add lines like that
nid gid realm grant_view grant_update grant_delete
5 0 example 1 0 0
5 0 example_other_realm 1 1 0

Please check and fix.

CommentFileSizeAuthor
#5 762260-5.patch422 bytessender

Comments

jhodgdon’s picture

Status: Active » Postponed (maintainer needs more info)

I can't understand what you are saying... It looks like you said it doesn't work for 'gid' => TRUE and then you said it does work for 'gid' => TRUE?

It does look to me as though the Drupal 6 function body example for hook_node_access_records should be using 'gid' => 1 in here:

 if ($node->private) {
    $grants = array();
    $grants[] = array(
      'realm' => 'example',
      'gid' => TRUE,
      'grant_view' => TRUE,
      'grant_update' => FALSE,
      'grant_delete' => FALSE,
      'priority' => 0,
    );

http://api.drupal.org/api/function/hook_node_access_records/6

because the corresponding hook_node_grants is:

  if (user_access('access private content', $account)) {
    $grants['example'] = array(1);
  }

http://api.drupal.org/api/function/hook_node_grants/6

Is that what you meant to say, that it should be 'gid' => 1?

dealancer’s picture

I'm sorry I did a copy-past error.

'gid' => 1

should be there, you are right.

jhodgdon’s picture

Status: Postponed (maintainer needs more info) » Active

OK, agreed, that hook example body should be updated to use 'gid' => 1.

It's correct in D7 by the way.

Thanks for reporting this!

jhodgdon’s picture

Issue tags: +Novice

Good project for a novice doc contributor

sender’s picture

Status: Active » Needs review
StatusFileSize
new422 bytes

Quick (haha) fix.

sender’s picture

Note that this is part of the contributions repository!

jhodgdon’s picture

Status: Needs review » Fixed

Committed to the contrib repository. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Novice

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