// clear bulk selection if ($bulk) { $SESSION->bulk_users = array(); } // init csv import helper $cir->init(); $linenum = 1; //column header is first line // init upload progress tracker $upt = new uu_progress_tracker(); $upt->init(); // start table while ($line = $cir->next()) { $upt->flush(); $linenum++; $upt->track('line', $linenum); $user = new object(); // by default, use the local mnet id (this may be changed in the file) $user->mnethostid = $CFG->mnet_localhost_id; // add fields to user object foreach ($line as $key => $value) { if ($value !== '') { $key = $columns[$key]; // password is special field if ($key == 'password') { if ($value !== '') { $user->password = hash_internal_user_password($value); if (!empty($CFG->passwordpolicy) and !check_password_policy($value, $errmsg)) { $forcechangepassword++; } }
// clear bulk selection if ($bulk) { $SESSION->bulk_users = array(); } // init csv import helper $cir->init(); $linenum = 1; //column header is first line // init upload progress tracker $upt = new uu_progress_tracker(); $upt->start(); // start table while ($line = $cir->next()) { $upt->flush(); $linenum++; $upt->track('line', $linenum); $user = new stdClass(); // add fields to user object foreach ($line as $keynum => $value) { if (!isset($filecolumns[$keynum])) { // this should not happen continue; } $key = $filecolumns[$keynum]; if (strpos($key, 'profile_field_') === 0) { //NOTE: bloody mega hack alert!! if (isset($USER->{$key}) and is_array($USER->{$key})) { // this must be some hacky field that is abusing arrays to store content and format $user->{$key} = array(); $user->{$key}['text'] = $value; $user->{$key}['format'] = FORMAT_MOODLE;
// Clear bulk selection. if ($bulk) { $SESSION->bulk_users = array(); } // Init csv import helper. $cir->init(); $linenum = 1; // Column header is first line. // Init upload progress tracker. $upt = new uu_progress_tracker(); $upt->init(); // Start table. while ($line = $cir->next()) { $upt->flush(); $linenum++; $upt->track('line', $linenum); $forcechangepassword = false; $user = new stdClass(); // By default, use the local mnet id (this may be changed in the file). $user->mnethostid = $CFG->mnet_localhost_id; // Add fields to user object. foreach ($line as $key => $value) { if ($value !== '') { $key = $columns[$key]; $user->{$key} = $value; if (in_array($key, $upt->columns)) { $upt->track($key, $value); } } else { $user->{$columns[$key]} = ''; }