--- tac_lite.module 2009-05-21 23:10:28.000000000 +0400 +++ tac_lite.new.module 2009-05-21 23:09:55.000000000 +0400 @@ -117,6 +117,14 @@ function tac_lite_admin_settings() { '#required' => TRUE, ); + //checkbox, hide access terms if checked + $form['tac_lite_hide_terms'] = array( + '#type' => 'checkbox', + '#title' => t('Hide Access Terms'), + '#description' => t('Check this box if you want to stop vocabulary terms you use for access control from showing when nodes are viewed.'), + '#default_value' => variable_get('tac_lite_hide_terms', 0), + ); + $ret = system_settings_form($form); // Special handling is required when this form is submitted. $ret['#submit'][] = '_tac_lite_admin_settings_submit'; @@ -499,3 +507,41 @@ function tac_lite_db_rewrite_sql($query, } } } + + +/** + * Implementation of hook_nodeapi + * Unset access terms if needed + */ +function tac_lite_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { + switch ($op) { + case 'view' : + //check if we need to hide terms + $hide_terms = variable_get('tac_lite_hide_terms',0); + if ($hide_terms) { + _tac_lite_hide_access_terms($node); + } + break; + } +} + + +/** + * Hide access terms in node object before view. + * Node reference is given by hook_nodeapi. + */ +function _tac_lite_hide_access_terms(&$node) { + //get access vocabularies + $vids = variable_get('tac_lite_categories', array()); + if (count($vids) == 0) { + return ; + } + //unset terms for access vocabularies + foreach ($vids as $vid) { + $terms = taxonomy_node_get_terms_by_vocabulary($node,$vid); + foreach ($terms as $term) { + unset($node->taxonomy[$term->tid]); + } + } +} //function _tac_lite_hide_access_terms +