function og_vocab_form_alter in OG Vocabulary 7
Same name and namespace in other branches
- 5 og_vocab.module \og_vocab_form_alter()
- 6 og_vocab.module \og_vocab_form_alter()
Implements hook_form_alter().
Using the hook_form_alter and not hook_form_FORM_ID_alter due to the invokes order of the hooks.
File
- ./
og_vocab.module, line 1218 - Give each group its own system controlled vocabularies.
Code
function og_vocab_form_alter(&$form, $form_state, $form_id) {
if (!in_array($form_id, array(
'taxonomy_form_vocabulary',
'taxonomy_overview_terms',
)) || !($context = og_vocab_is_group_admin_context())) {
return;
}
if ($form_id == 'taxonomy_overview_terms') {
// Alter the 'Add term' link that is displayed when no terms have yet been
// added.
$og_vocab = taxonomy_vocabulary_load($form['#vocabulary']->vid);
$relation = og_vocab_relation_get($og_vocab->vid);
if (og_user_access($relation->group_type, $relation->gid, 'administer taxonomy')) {
$path = "group/{$relation->group_type}/{$relation->gid}/admin/taxonomy/{$og_vocab->machine_name}/add";
$form['#empty_text'] = t('No terms available. <a href="@link">Add term</a>.', array(
'@link' => url($path),
));
}
}
$form['#submit'][] = 'og_vocab_redirect_to_group_vocabularies';
}