You are here

function nodeaccess_save_grant in Nodeaccess 7

Save the grant settings/options for the node.

Parameters

$node: node object the grant is being applied to.

array $grant: array( 'gid' => (int) gid for realm, 'realm' => (string) what realm the access grant belongs to (ex: nodeaccess_rid). 'grant_view' => (int) view access being granted, 'grant_update' => (int) update access being granted, 'grant_delete' => (int) delete access being granted, )

1 call to nodeaccess_save_grant()
nodeaccess_set_grants in ./nodeaccess.module
Set all grants for a node to nodeaccess table and acquire them.

File

./nodeaccess.module, line 1056
Provide per node access control

Code

function nodeaccess_save_grant($node, $grant) {

  // Save role and user grants to our own table.
  try {
    db_insert('nodeaccess')
      ->fields(array(
      'nid' => $node->nid,
      'gid' => $grant['gid'],
      'realm' => $grant['realm'],
      'grant_view' => (int) $grant['grant_view'],
      'grant_update' => (int) $grant['grant_update'],
      'grant_delete' => (int) $grant['grant_delete'],
    ))
      ->execute();
  } catch (Exception $e) {
    drupal_set_message(t("Database error has occurred while saving to nodeaccess table."), 'error');
    watchdog('nodeaccess', 'Database error: @message.', array(
      '@message' => $e
        ->getMessage(),
    ), WATCHDOG_ERROR);
  }
}