Commit b84b5c52 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Put the CSV file loading in a transaction for safety

parent 547d4209
......@@ -158,6 +158,7 @@ function uploadcsv_validate(Pieform $form, $values) {
function uploadcsv_submit(Pieform $form, $values) {
global $SESSION, $CSVDATA;
log_info('Inserting users from the CSV file');
db_begin();
foreach ($CSVDATA as $record) {
log_debug('adding user ' . $record[0]);
$user = new StdClass;
......@@ -175,6 +176,7 @@ function uploadcsv_submit(Pieform $form, $values) {
handle_event('createuser', $user);
}
db_commit();
log_info('Inserted ' . count($CSVDATA) . ' records');
$SESSION->add_ok_msg(get_string('uploadcsvusersaddedsuccessfully', 'admin'));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment