function node_privacy_byrole_rolereference_action in node privacy byrole 5
Same name and namespace in other branches
- 6 node_privacy_byrole.module \node_privacy_byrole_rolereference_action()
1 call to node_privacy_byrole_rolereference_action()
- action_node_privacy_byrole_actions_rolereference in ./
node_privacy_byrole.module - Implementation of hook_action().
File
- ./
node_privacy_byrole.module, line 483
Code
function node_privacy_byrole_rolereference_action($node, $context) {
/*
Mod $node here to have new permissions. It expects:
$node->node_privacy_byrole['roles'][$rid]['view']
$node->node_privacy_byrole['roles'][$rid]['edit']
$node->node_privacy_byrole['roles'][$rid]['delete']
Otherwise it will use defaults setup for the content type.
*/
if (isset($context['node_privacy_byrole']['roles'])) {
$node->node_privacy_byrole['roles'] = $context['node_privacy_byrole']['roles'];
}
$node->node_privacy_byrole['author'] = $context['node_author'];
foreach ($context['permissions'] as $key => $value) {
// The true $values are normally literally 'view', 'edit', 'delete' or 0 for false
// which is required for the #default_values when loading the configuration
// page for an existing action, but the node access table actually works on
// 0 or 1 in the access tables, so convert them here because that's easier
// than converting 1 to 'edit' for the #default_value on the form case.
$context['permissions'][$key] = empty($context['permissions'][$key]) ? 0 : 1;
}
foreach (_node_privacy_byrole_walk_role_fields($node->{$context}['field']) as $rid) {
$node->node_privacy_byrole['roles'][$rid] = $context['permissions'];
}
module_invoke('node_privacy_byrole', 'nodeapi', $node, 'update');
}