You are here

function admin_language_form_alter in Administration Language 7

Same name and namespace in other branches
  1. 6 admin_language.module \admin_language_form_alter()

Implements hook_form_alter().

File

./admin_language.module, line 177
Makes admin pages be displayed in the administrator's preferred language.

Code

function admin_language_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    if (module_exists('translation') && variable_get('admin_language_hide_node', 0)) {
      if (isset($form['language'])) {

        // Init #after_build if it doesn't exist.
        if (!isset($form['#after_build'])) {
          $form['#after_build'] = array();
        }

        // Add a callback for cleaning up the language select widget.
        $form['#after_build'][] = 'admin_language_modify_language_element';
      }
    }
  }
  if ('user_profile_form' == $form_id) {
    $language_hide_user = variable_get('admin_language_hide_user', 0);
    if (!$language_hide_user && 'account' == $form['#user_category'] && user_access('display admin pages in another language')) {
      _admin_language_user_form_add_language_select($form);
    }
    if ($language_hide_user && !user_access('administer site configuration')) {
      $form['#after_build'][] = '_admin_language_user_form_remove_admin_language';
    }
  }
  if ('user_register_form' == $form_id) {
    if (user_access('administer users')) {
      _admin_language_user_form_add_language_select($form);
    }
  }
}