function i18n_access_form_alter in Translation Access 6
Same name and namespace in other branches
- 7 i18n_access.module \i18n_access_form_alter()
Implementation of hook_form_alter().
File
- ./
i18n_access.module, line 82 - file_description
Code
function i18n_access_form_alter(&$form, $form_state, $form_id) {
// Remove inaccessible languages from the select box
if (isset($form['#id']) && $form['#id'] == 'node-form' && isset($form['language']['#options'])) {
// don't do it form admininstrators
if (!user_access('administer nodes')) {
$perms = i18n_access_load_permissions();
foreach ($form['language']['#options'] as $key => $value) {
$perm_key = $key == '' ? I18N_ACCESS_LANGUAGE_NEUTRAL : $key;
if (empty($perms[$perm_key])) {
unset($form['language']['#options'][$key]);
}
}
}
}
//Configuring locale search form to limit it to domain language
if ($form['#id'] == 'locale-translate-seek-form' && !user_access('administer nodes') && user_access('translate interface')) {
$perms = i18n_access_load_permissions();
foreach ($form['search']['language']['#options'] as $key => $value) {
$perm_key = $key == '' ? I18N_ACCESS_LANGUAGE_NEUTRAL : $key;
if (!isset($perms[$perm_key])) {
unset($form['search']['language']['#options'][$key]);
}
}
}
//Configuring translation edit form to limit it to allowed language
if ($form['#id'] == 'locale-translate-edit-form' && !user_access('administer nodes') && user_access('translate interface')) {
$perms = i18n_access_load_permissions();
foreach ($form['translations'] as $language => $translation) {
if (!isset($perms[$language]) && $language != '#tree') {
unset($form['translations'][$language]);
}
}
}
}