function taxonomy_access_fix_form_taxonomy_overview_vocabularies_alter in Taxonomy access fix 7
Same name and namespace in other branches
- 7.2 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
theme_taxonomy_overview_vocabularies()
File
- ./
taxonomy_access_fix.module, line 16 - 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;
}
// Empty text for unauthorized functions.
$empty = array(
'#type' => 'markup',
'#markup' => ' ',
);
// 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.
$form[$vid]['#access'] = FALSE;
unset($form[$vid]);
continue;
}
// Definitely no "edit vocabulary" access.
$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.
$form['actions']['#access'] = FALSE;
}