You are here

function uif_batch_import_users_process in User Import Framework 6

Same name and namespace in other branches
  1. 7 uif.admin.inc \uif_batch_import_users_process()

User import batch processing.

1 string reference to 'uif_batch_import_users_process'
uif_batch_import_users in ./uif.admin.inc
Batch import all users.

File

./uif.admin.inc, line 376
Simple, extensible user import from a CSV file.

Code

function uif_batch_import_users_process($form_state, &$context) {

  // Initialize
  if (empty($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($form_state['storage']['data']['user']);
    $context['results']['created'] = 0;
    $context['results']['updated'] = 0;
  }

  // Process max 20 users at a time
  $processed = 0;
  $notify = $form_state['storage']['notify'];
  while ($context['sandbox']['progress'] < $context['sandbox']['max'] && $processed < 20) {
    $index = $context['sandbox']['progress'];
    uif_import_user($form_state['storage']['data']['user'][$index], $notify, $context['results'], $form_state);
    $context['sandbox']['progress']++;
    $processed++;
  }

  // Finished yet?
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}