function taxonomy_access_fix_form_taxonomy_overview_vocabularies_alter in Taxonomy access fix 7.2
Same name and namespace in other branches
- 7 taxonomy_access_fix.module \taxonomy_access_fix_form_taxonomy_overview_vocabularies_alter()
Implements hook_form_FORM_ID_alter() for taxonomy_overview_vocabularies().
Form URI: 'admin/structure/taxonomy'.
See also
taxonomy_overview_vocabularies()
theme_taxonomy_overview_vocabularies()
File
- ./
taxonomy_access_fix.module, line 17 - This file contains all hooks and callbacks for extra/improved Taxonomy permissions.
Code
function taxonomy_access_fix_form_taxonomy_overview_vocabularies_alter(&$form, &$form_state) {
// Admin: don't fix anything.
if (user_access('administer taxonomy')) {
return TRUE;
}
// Others: remove some vocabularies.
foreach (element_children($form) as $vid) {
if (is_numeric($vid) && ($vocabulary = $form[$vid]['#vocabulary'])) {
// No access at all?
if (!taxonomy_access_fix_access('list terms', $vocabulary)) {
// Unfortunately, just setting #access isn't enough.
unset($form[$vid]);
continue;
}
// Remove weight form element.
unset($form[$vid]['weight']);
// Remove "edit vocabulary" link.
$form[$vid]['edit']['#access'] = FALSE;
// Maybe no "add terms" access.
if (!taxonomy_access_fix_access('add terms', $vocabulary)) {
$form[$vid]['add']['#access'] = FALSE;
}
}
}
// Remove "Save" button and prevent draggable table generation.
unset($form['actions']);
}