You are here

function admin_language_retrieve in Administration Language 7

Retrieves the admin language object for the supplied or current user.

Parameters

object $account: A user account to look up the admin language for. If FALSE, the current user will be used.

Return value

object A language object, which will be the account's admin language, the default admin language, or the site's current language, if the user does not have access to use the admin language.

1 call to admin_language_retrieve()
admin_language_menu_local_tasks_alter in ./admin_language.module
Implements hook_menu_local_tasks_alter().

File

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

Code

function admin_language_retrieve($account = FALSE) {
  if (!$account) {
    global $user;
    $account = $user;
  }
  if (user_access('display admin pages in another language', $account)) {
    global $_admin_language;

    // If admin_language is not set on the user, the account may have not have
    // been loaded with a user_load() call, so try to retrieve it manually.
    if (!isset($account->admin_language)) {
      $result = db_query('SELECT language FROM {admin_language} WHERE uid = :uid', array(
        ':uid' => $account->uid,
      ));
      if ($user_admin_language = $result
        ->fetchField()) {
        $account->admin_language = $user_admin_language;
      }
    }
    $language_list = language_list();
    if (isset($account->admin_language) && isset($language_list[$account->admin_language])) {
      return $language_list[$account->admin_language];
    }
    else {
      return $_admin_language;
    }
  }
  else {
    global $language;
    return $language;
  }
}