diff --git a/workbench_moderation.module b/workbench_moderation.module index 26ea794..db98dca 100644 --- a/workbench_moderation.module +++ b/workbench_moderation.module @@ -448,6 +448,46 @@ function workbench_moderation_node_access($node, $op, $account) { } /** + * Implements hook_node_grants(). + */ +function workbench_moderation_node_grants($account, $op) { + // Pass along gid = 1 for any user with unpublished content access. + $grants['workbench_moderation_unpublished'] = array((int) user_access('view all unpublished content', $account)); + $grants['workbench_moderation_published'] = array((int) user_access('access content', $account)); + return $grants; +} + +/** + * Implements hook_node_access_records(). + */ +function workbench_moderation_node_access_records($node) { + $grants = array(); + if (!$node->status) { + // We implement an access record for unpublished content. + $grants[] = array( + 'realm' => 'workbench_moderation_unpublished', + 'gid' => 1, + 'grant_view' => 1, + 'grant_update' => 0, + 'grant_delete' => 0, + 'priority' => 0, + ); + } + else { + // We implement an access record for published content. + $grants[] = array( + 'realm' => 'workbench_moderation_published', + 'gid' => 1, + 'grant_view' => 1, + 'grant_update' => 0, + 'grant_delete' => 0, + 'priority' => 0, + ); + } + return $grants; +} + +/** * Custom access handler for node operations. * * @param $op