/** * Add the users to the system. */ function bulkimport_submit(Pieform $form, $values) { global $SESSION, $LEAP2AFILES; require_once 'file.php'; require_once get_config('docroot') . 'import/lib.php'; safe_require('import', 'leap'); $key = 0; $total = count($LEAP2AFILES); log_info('Attempting to import ' . $total . ' users from Leap2A files'); foreach ($LEAP2AFILES as $username => $filename) { if (!($key % 10)) { set_progress_info('bulkimport', $key, $total, get_string('importing', 'admin')); } $key++; import_next_user($filename, $username, $values['authinstance']); } finish_import(); }
if (empty($ADDEDUSERS)) { $ADDEDUSERS = array(); } $FAILEDUSERS = $SESSION->get('bulkimport_failedusers'); if (empty($FAILEDUSERS)) { $FAILEDUSERS = array(); } $LEAP2AFILES = $SESSION->get('bulkimport_leap2afiles'); if (empty($LEAP2AFILES)) { $LEAP2AFILES = array(); } $AUTHINSTANCE = $SESSION->get('bulkimport_authinstance'); $EMAILUSERS = $SESSION->get('bulkimport_emailusers'); // Import in progress if (!empty($LEAP2AFILES)) { import_next_user(); } elseif (!empty($ADDEDUSERS) or !empty($FAILEDUSERS)) { finish_import(); } $authinstances = auth_get_auth_instances(); if (count($authinstances) > 0) { $options = array(); foreach ($authinstances as $authinstance) { $options[$authinstance->id] = $authinstance->displayname . ': ' . $authinstance->instancename; } $default = key($options); $authinstanceelement = array('type' => 'select', 'title' => get_string('institution'), 'description' => get_string('uploadcsvinstitution', 'admin'), 'options' => $options, 'defaultvalue' => $default); } $form = array('name' => 'bulkimport', 'elements' => array('authinstance' => $authinstanceelement, 'file' => array('type' => 'text', 'title' => get_string('importfile', 'admin'), 'size' => 40, 'description' => get_string('bulkleap2aimportfiledescription', 'admin'), 'rules' => array('required' => true)), 'emailusers' => array('type' => 'checkbox', 'title' => get_string('emailusersaboutnewaccount', 'admin'), 'description' => get_string('emailusersaboutnewaccountdescription', 'admin'), 'defaultvalue' => true), 'submit' => array('type' => 'submit', 'value' => get_string('Import', 'admin')))); /** * Work-around the redirection limit of Firefox (http://kb.mozillazine.org/Network.http.redirection-limit)