--- taxonomy_role.module 2008-07-06 18:42:40.000000000 +0200 +++ taxonomy_role.module.new 2009-02-23 14:13:35.000000000 +0100 @@ -12,7 +12,7 @@ function taxonomy_role_help($path, $arg) { switch ($path) { case 'admin/help#taxonomy_role': - $output = '

'. t('This module allows you to restrict access to vocabularies on node forms by role. Once it is installed, you will need to configure the permissions for new and existing vocabularies.'). '

'; + $output = '

'. t('This module allows you to restrict access to vocabularies on node forms by role and to show or hide terms of particular vocabulary on node views by role. Once it is installed, you will need to configure the permissions for new and existing vocabularies.'). '

'; return $output; } } @@ -75,6 +75,22 @@ function taxonomy_role_form_alter(&$form } /** + * Implementation of hook_view(). + */ +function taxonomy_role_view($node) { + if (isset($node->taxonomy)) { + $vocabularies = taxonomy_get_vocabularies($node->type); + foreach ($vocabularies as $vocabulary) { + foreach($node->taxonomy as $tid=>$term) { + if(($term->vid == $vocabulary->vid) && (!user_access('view '. check_plain($vocabulary->name) .' vocabulary'))) { + unset($node->taxonomy[$tid]); + } + } + } + } +} + +/** * Implementation of hook_perm(). */ function taxonomy_role_perm() { @@ -82,6 +98,7 @@ function taxonomy_role_perm() { $perms = array(); foreach ($vocabularies as $vocabulary) { $perms[] = 'access '. check_plain($vocabulary->name) .' vocabulary'; + $perms[] = 'view '. check_plain($vocabulary->name) .' vocabulary'; } return $perms; } @@ -114,5 +131,4 @@ function taxonomy_role_admin_settings_fo } } return system_settings_form($form); -} - +} \ No newline at end of file