You are here

function domain_locale_install in Domain Locale 6

Same name and namespace in other branches
  1. 7 domain_locale.install \domain_locale_install()

Implementation of hook_install().

File

./domain_locale.install, line 10
Provides domain specific locale settings

Code

function domain_locale_install() {

  // Create database tables
  drupal_install_schema('domain_locale');

  // Make all enabled languages available on all domains by default
  $enabled_languages = db_query('SELECT language, weight FROM {languages} WHERE enabled=1');
  module_load_include('module', 'domain');
  $existing_domains = domain_domains();
  while ($lang = db_fetch_object($enabled_languages)) {
    $current_language = $lang->language;
    $language_weight = $lang->weight;
    foreach ($existing_domains as $current_domain) {
      if ($current_domain['domain_id'] > 0) {
        db_query("INSERT INTO {domain_locale}(language, domain_id, weight) VALUES ('%s', %d, %d)", $current_language, $current_domain['domain_id'], $language_weight);
      }
    }
  }

  // Set domain_locale higher than i18n if it exists
  $result = db_result(db_query("SELECT weight FROM {system} WHERE name = 'i18n'"));
  if ($result) {
    $weight = $result + 1;
    $ret[] = update_sql("UPDATE {system} SET weight = " . $weight . " WHERE name = 'domain_locale'");
  }
}