You are here

function l10n_update_admin_settings_form_validate in Localization update 7.2

Same name and namespace in other branches
  1. 6 l10n_update.admin.inc \l10n_update_admin_settings_form_validate()
  2. 7 l10n_update.admin.inc \l10n_update_admin_settings_form_validate()

Validation handler for translation update settings.

File

./l10n_update.admin.inc, line 306
Admin settings and update page.

Code

function l10n_update_admin_settings_form_validate($form, &$form_state) {

  // Check for existing translations directory and create one if required.
  // When using local sources, only check if the directory exists.
  $directory = $form_state['values']['l10n_update_download_store'];
  $directory = rtrim($directory, '/\\');
  if ($form_state['values']['l10n_update_check_mode'] == L10N_UPDATE_USE_SOURCE_LOCAL && is_dir($directory)) {
    return;
  }
  if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
    form_set_error('l10n_update_download_store', t('The directory %directory does not exist or is not writable.', array(
      '%directory' => $directory,
    )));
    watchdog('file system', 'The directory %directory does not exist or is not writable.', array(
      '%directory' => $directory,
    ), WATCHDOG_ERROR);
  }
}