function node_privacy_byrole_rolereference_action in node privacy byrole 6
Same name and namespace in other branches
- 5 node_privacy_byrole.module \node_privacy_byrole_rolereference_action()
File
- ./
node_privacy_byrole.module, line 481 - Set node access permissions by role.
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'];
}
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 ($context['node_author'] as $key => $value) {
// Do for author what was just done for other permissions.
$context['node_author'][$key] = empty($context['node_author'][$key]) ? 0 : 1;
}
$node->node_privacy_byrole['author'] = $context['node_author'];
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');
}