API page: http://api.drupal.org/api/examples/node_access_example--node_access_exam...

it seems like a mistake that in the first grants array:

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

that 'gid' is "TRUE" -- although it works, shoudn't it be an integer, 1?

it's just a little confusing because a boolean value for an ID makes no sense. i know it works because TRUE=1, but still..

Comments

jhodgdon’s picture

Title: Documentation problem with node_access_example_node_access_records » node_access_example_node_access_records has problem with boolean vs. integer
Project: Drupal core » Examples for Developers
Version: 6.x-dev » 6.x-1.x-dev
Component: documentation » Node Access Example

Moving to Examples issue queue

makangus’s picture

StatusFileSize
new877 bytes

Here's a patch against 6.x-1.x

makangus’s picture

Status: Active » Needs review
rfay’s picture

Status: Needs review » Needs work

@makangus, thanks very much for this.

I would really appreciate if you could do 7.x-1.x first.

I do think it would be clearer to use an integer here. I actually think an integer other than 1 would be better, because it demonstrates the arbitrary nature of the identifier, if I'm not mistaken.

makangus’s picture

@rfay, I don't think the 7.x-1.x branch has the same problem.
The 7.x-1.x is using NODE_ACCESS_EXAMPLE_GRANT_ALL as the gid

$grants[] = array(
      'realm' => 'node_access_example_view',
      'gid' => NODE_ACCESS_EXAMPLE_GRANT_ALL,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 0,
    );

NODE_ACCESS_EXAMPLE_GRANT_ALL is defined to 23 which is exactly want you wanted, an arbitrary integer that's not 1

rfay’s picture

Why don't we do that one same thing then here, and use an integer that's sufficiently arbitrary to explain to people what it is...

Thanks so much for your work on this.

makangus’s picture

Status: Needs work » Needs review
StatusFileSize
new1.9 KB

How about this?

rfay’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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