#920614: clarify the status of unpublished node in hook_node_access_records().

From: Damien Tournoud <damien@commerceguys.com>


---
 node/node.api.php |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git modules/node/node.api.php modules/node/node.api.php
index b99d72b..ad7ae0e 100644
--- modules/node/node.api.php
+++ modules/node/node.api.php
@@ -169,6 +169,24 @@ function hook_node_grants($account, $op) {
  * interested, it must respond with an array of permissions arrays for that
  * node.
  *
+ * When an implementation is interested in a node but want to deny access to
+ * everyone, it must return a "deny all" grant:
+ *
+ * @code
+ * $grants[] = array(
+ *   'realm' => 'all',
+ *   'gid' => 0,
+ *   'grant_view' => 0,
+ *   'grant_update' => 0,
+ *   'grant_delete' => 0,
+ * );
+ * @endcode
+ *
+ * Node access grants apply regardless of the published or unpublished status
+ * of the node. Implementations must make sure not to grant access to
+ * unpublished nodes if they don't want to change the standard access control
+ * behavior.
+ *
  * Note that the grant values in the return value from your hook must be
  * integers and not boolean TRUE and FALSE.
  *
@@ -201,7 +219,7 @@ function hook_node_access_records($node) {
     $grants[] = array(
       'realm' => 'example',
       'gid' => 1,
-      'grant_view' => 1,
+      'grant_view' => $node->status,
       'grant_update' => 0,
       'grant_delete' => 0,
       'priority' => 0,
@@ -212,11 +230,12 @@ function hook_node_access_records($node) {
     $grants[] = array(
       'realm' => 'example_author',
       'gid' => $node->uid,
-      'grant_view' => 1,
-      'grant_update' => 1,
-      'grant_delete' => 1,
+      'grant_view' => $node->status,
+      'grant_update' => $node->status,
+      'grant_delete' => $node->status,
       'priority' => 0,
     );
+
     return $grants;
   }
 }
