You are here

function l10n_update_project_refresh in Localization update 6

Same name and namespace in other branches
  1. 7 l10n_update.project.inc \l10n_update_project_refresh()

Refresh projects after enabling/disabling modules

When new projects are installed, set a batch for locale import / update

1 call to l10n_update_project_refresh()
l10n_update_system_modules_submit in ./l10n_update.module
Additional submit hander for System Modules form.

File

./l10n_update.project.inc, line 129
Library for querying Drupal projects

Code

function l10n_update_project_refresh() {

  // Get previous enabled/disabled projects
  $prev_enabled = l10n_update_get_projects();
  $prev_all = l10n_update_get_projects(FALSE, TRUE);

  // Get all current projects, also rebuild table data
  $current_projects = l10n_update_build_projects();
  $enabled = array_diff(array_keys($current_projects), array_keys($prev_enabled));
  $installed = array_diff(array_keys($current_projects), array_keys($prev_all));

  // If there are newly installed projects, create batch for projects x languages
  if ($installed) {
    module_load_include('check.inc', 'l10n_update');
    foreach ($installed as $name) {
      $projects[$name] = $current_projects[$name];
    }
    if ($available = l10n_update_check_projects($projects)) {
      $history = l10n_update_get_history();
      if ($updates = l10n_update_build_updates($history, $available)) {
        module_load_include('batch.inc', 'l10n_update');

        // Filter out updates in other languages. If no languages, all of them will be updated
        $updates = _l10n_update_prepare_updates($updates);
        $batch = l10n_update_batch_multiple($updates, variable_get('l10n_update_import_mode', LOCALE_IMPORT_KEEP));
        batch_set($batch);
      }
    }
  }
}