You are here

function l10n_update_install in Localization update 7.2

Same name and namespace in other branches
  1. 6 l10n_update.install \l10n_update_install()
  2. 7 l10n_update.install \l10n_update_install()

Implements hook_install().

File

./l10n_update.install, line 150
Install file for l10n remote updates.

Code

function l10n_update_install() {
  db_add_field('locales_target', 'l10n_status', array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
  variable_set('l10n_update_rebuild_projects', 1);

  // Create the translation directory. We try different alternative paths as the
  // default may not always be writable.
  $directories = array(
    variable_get('l10n_update_download_store', L10N_UPDATE_DEFAULT_TRANSLATION_PATH),
    variable_get('file_public_path', conf_path() . '/files') . '/translations',
    'sites/default/files/translations',
  );
  foreach ($directories as $directory) {
    if (file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
      variable_set('l10n_update_download_store', $directory);
      l10n_update_ensure_htaccess($directory);
      return;
    }
  }
  watchdog('l10n_update', 'The directory %directory does not exist or is not writable.', array(
    '%directory' => $directories[0],
  ), WATCHDOG_ERROR);
  drupal_set_message(t('The directory %directory does not exist or is not writable.', array(
    '%directory' => $directories[0],
  )), 'error');
}