Sorry for reopening #248938: Support for update and delete permissions in tac_lite - still getting used to the etiquette for issues. I don't have a suggestion for resolving the problem identified in #16, I'm afraid.
The idea of using a hook_form_alter to restrict the available terms to those that a user is allowed to update rather than those she can view is mentioned in that other thread, but no further clue is given as to how one might do that. As a relative newbie in Drupal module programming, I've now sat down and spent several hours working it out, and I've made it work.
Whilst I accept that the way the module currently works in this respect is intentional and not expected to change (which is why I've set the status as 'by design' - hope that's the right thing to do?), and this isn't a patch in the usual sense, i thought other users wishing to tweak this module wrt their own customised nodes might appreciate seeing the code I came up with. If this is the wrong place for submitting this, I apologise very much, and am happy for it to be deleted again.
This needs to be (part of) the implentation of hook_form_alter within the customised node (not in tac_lite.module!). And, because of the unresolved problem referred to above, this is only recommended for use on vocabularies where multiple=0, such as the forum_nav_vocabulary.
function MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
global $user;
switch ($form_id) {
// [... you might have other cases here...]
case 'MODULE_NAME_node_form' :
if ($user->uid != 1 && !user_access('administer_tac_lite', $user)) {
$update_obj = (object) 'update';
$grants = tac_lite_node_grants($user,$update_obj->scalar);
$tac_grants = $grants['tac_lite'];
$vocabs = array (
'forum_nav' => variable_get('forum_nav_vocabulary',0),
// insert additional values here to cover each of the vocabularies which apply
// to this node type
);
foreach ($vocabs as $vocab) {
$new_options = array();
$new_options[''] = $form['taxonomy'][$vocab]['#options'][''];
foreach ($tac_grants as $tac_grant) {
foreach ($form['taxonomy'][$vocab]['#options'] as $option) {
if (is_object($option)) {
if ($option->option[$tac_grant]) {
$new_option = new stdClass();
$new_option->option = array($tac_grant => $option->option[$tac_grant]);
$new_options[] = $new_option;
}
}
}
}
$form['taxonomy'][$vocab]['#options'] = $new_options;
}
}
break;
}
}