function nodeaccess_delete_user_reference in Nodeaccess 7
Delete all userreference user grants from a node.
Parameters
Object $node:
1 call to nodeaccess_delete_user_reference()
- nodeaccess_node_update in ./
nodeaccess.module - Implements hook_node_update().
File
- ./
nodeaccess.module, line 914 - Provide per node access control
Code
function nodeaccess_delete_user_reference($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 . '_user_reference', array());
foreach ($fields as $field_name => $field) {
$user_uids = field_get_items('node', $node, $field_name);
$user_references = user_load_multiple($user_uids);
foreach ($user_references as $user) {
unset($form_values['uid'][$user->uid]);
}
}
$form_values['nid'] = $node->nid;
$form_state = array(
'values' => $form_values,
);
_nodeaccess_grants_form_submit(NULL, $form_state);
}