$sub_arr[] = $old_exptype_name_to_id[trim($sub)]; } } $n['subscriptions'] = id_array_to_db_string($sub_arr); $n['pending_profile_update_request'] = 'n'; $n['last_enrolment'] = 0; $n['last_profile_update'] = $o['creation_time']; $n['last_activity'] = max($n['last_enrolment'], $n['last_profile_update']); $n['status_id'] = $participant_status_mapping[$o['deleted']][$o['excluded']]; if ($o['deleted'] == 'y') { $n['deletion_time'] = time(); } else { $n['deletion_time'] = 0; } if ($replace_tokens == 'y') { $n['participant_id_crypt'] = make_p_token(get_entropy($n)); } foreach ($pform_mapping as $oldf => $newf) { if ($newf && isset($o[$oldf])) { $n[$newf] = $o[$oldf]; } } $n = convert_array_to_UTF8($n); if ($do_insert) { $done = orsee_db_save_array($n, "participants", $n['participant_id'], "participant_id"); } } } if ($import_sessions) { echo "Importing sessions from " . table('sessions') . "\n"; $dquery = "DELETE FROM " . $new_db_name . "." . table('sessions') . "";
function participant__create_participant_id($pdata = array()) { $exists = true; while ($exists) { $participant_id = mt_rand(0, 1000000000); $participant_id_crypt = make_p_token(get_entropy($pdata)); $pars = array(':participant_id' => $participant_id, ':participant_id_crypt' => $participant_id_crypt); $query = "SELECT participant_id FROM " . table('participants') . "\n WHERE participant_id= :participant_id OR participant_id_crypt= :participant_id_crypt"; $line = orsee_query($query, $pars); if (isset($line['participant_id'])) { $exists = true; } else { $exists = false; } } return array('participant_id' => $participant_id, 'participant_id_crypt' => $participant_id_crypt); }