Commit 58c43efe authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

The CSV uploading script now takes CSV files with the format described

on the first line, to prevent ambiguities that were causing it to be
broken before
parent 526a8e70
......@@ -161,6 +161,7 @@ function uploadcsv_submit(Pieform $form, $values) {
db_begin();
$mandatoryfields = ArtefactTypeProfile::get_mandatory_fields();
$mandatoryfieldkeys = array_keys($mandatoryfields);
log_debug($mandatoryfieldkeys);
foreach ($CSVDATA as $record) {
log_debug('adding user ' . $record[0]);
$user = new StdClass;
......@@ -174,13 +175,15 @@ function uploadcsv_submit(Pieform $form, $values) {
$id = insert_record('usr', $user, 'id', true);
// A bit of munging to move fields into the correct order
$record[4] = $record[5];
$record[5] = $record[6];
$record[6] = $user->email;
//$record[4] = $record[5];
//$record[5] = $record[6];
//$record[6] = $user->email;
log_debug($record);
$i = 2;
safe_require('artefact', 'internal');
foreach ($mandatoryfieldkeys as $field) {
log_debug("$id $field $i " . $record[$i]);
set_profile_field($id, $field, $record[$i++]);
}
......
Markdown is supported
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