You are here

function import_do_imports in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6

Same name and namespace in other branches
  1. 6.2 import/merci_import.php \import_do_imports()

Perform imports for one second or until finished.

Return value

An array indicating the status after doing imports. The first element is the overall percentage finished. The second element is a status message.

2 calls to import_do_imports()
import_do_import_page in import/merci_import.php
Perform imports for the JS version and return progress.
import_progress_page_nojs in import/merci_import.php
Perform imports for the non-JS version and return the status page.

File

import/merci_import.php, line 372
Administrative page for adding MERCI bucket/resource content types and items.

Code

function import_do_imports() {
  while (isset($_SESSION['import_remaining']) && ($import = reset($_SESSION['import_remaining']))) {
    $import_finished = import_data($import['module'], $import['version']);
    if ($import_finished == 1) {

      // Dequeue the completed import.
      unset($_SESSION['import_remaining'][key($_SESSION['import_remaining'])]);
      $import_finished = 0;

      // Make sure this step isn't counted double
    }
    if (timer_read('page') > 1000) {
      break;
    }
  }
  if ($_SESSION['import_total']) {
    $percentage = floor(($_SESSION['import_total'] - count($_SESSION['import_remaining']) + $import_finished) / $_SESSION['import_total'] * 100);
  }
  else {
    $percentage = 100;
  }

  // When no imports remain, clear the caches in case the data has been imported.
  if (!isset($import['module'])) {
    cache_clear_all('*', 'cache', TRUE);
    cache_clear_all('*', 'cache_page', TRUE);
    cache_clear_all('*', 'cache_menu', TRUE);
    cache_clear_all('*', 'cache_filter', TRUE);
    drupal_clear_css_cache();
  }
  return array(
    $percentage,
    isset($import['module']) ? 'Importing ' . $import['module'] . ' module' : 'Importing complete',
  );
}