You are here

function language_access_init in Language access 7

Same name and namespace in other branches
  1. 6 language_access.module \language_access_init()

Implementation of hook_init().

File

./language_access.module, line 6

Code

function language_access_init() {
  $path = current_path();

  // Allow user path to be accessed
  if ($path == 'user' || substr($path, 0, 5) == "user/") {
    return;
  }
  global $language;
  if (!user_access('access language ' . $language->language)) {
    $default_language = language_default();

    // We still want to allow access to default language
    if ($language->language != $default_language->language) {

      // Do not execute on drush
      if (php_sapi_name() != 'cli') {
        drupal_access_denied();
        exit;
      }
    }
  }
}