You are here

function nodeaccess_delete_userreference in Nodeaccess 6

Same name and namespace in other branches
  1. 6.2 nodeaccess.module \nodeaccess_delete_userreference()

Delete all userreference user grants from a node.

Parameters

$node: The node with userreference fields that need to be deleted from the user grants table.

1 call to nodeaccess_delete_userreference()
nodeaccess_nodeapi in ./nodeaccess.module
Implementation of hook_nodeapi().

File

./nodeaccess.module, line 883

Code

function nodeaccess_delete_userreference($node) {
  $form_values = _nodeaccess_get_grants($node);

  // Now, append or overwrite the uid with what was specified in the user
  // reference field.
  $fields = variable_get('nodeaccess_' . $node->type . '_userreference', array());
  foreach ($fields as $field_name => $field) {
    if (isset($node->{$field_name})) {
      foreach ($node->{$field_name} as $values) {

        // Add the settings for this UID
        $user = user_load($values['uid']);
        unset($form_values['uid'][$user->uid]);
      }
    }
  }
  $form_values['nid'] = $node->nid;
  $form_state = array(
    'values' => $form_values,
  );
  _nodeaccess_grants_form_submit(NULL, $form_state);
}