function taxonomy_access_nodeapi in Taxonomy Access Control 5
Same name and namespace in other branches
- 5.2 taxonomy_access.module \taxonomy_access_nodeapi()
- 6 taxonomy_access.module \taxonomy_access_nodeapi()
Implementation of hook_nodeapi().
File
- ./
taxonomy_access.module, line 398 - Allows administrators to specify how each category (in the taxonomy) can be used by various roles.
Code
function taxonomy_access_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case 'submit':
// When TAC grants 'update' access to edit node,
// Changing $node->uid back to original creator (changed by node_submit)
if ($node->nid && !user_access('administer nodes') && node_access('update', $node)) {
// Populate the "authored by" field.
$old_node = node_load($node->nid);
if ($account = user_load(array(
'name' => $old_node->name,
))) {
$node->uid = $account->uid;
}
else {
$node->uid = 0;
}
}
break;
case 'update':
// restore terms that the user shouldn't have access to delete
taxonomy_access_restore_terms($node->nid, $node->tac_protected_terms);
break;
}
}