-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaedml Benutzer.svelte
65 lines (65 loc) · 2.38 KB
/
paedml Benutzer.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!--
Für diese Einstellung der Importfunktion in /var/lib/ucs-school-import/configs/user_import.json
Siehe auch https://docs.software-univention.de/ucsschool-import-handbuch-4.4.html
{
"csv": {
"mapping": {
"ID": "record_uid",
"Vornamen": "firstname",
"Nachname": "lastname",
"Klasse": "school_classes",
"Geburtstag": "birthday",
"Passwort": "password"
}
},
"scheme": {
"username": {
"student": "<record_uid>",
"teacher": "<record_uid><:lower>"
},
"email": "<username><maildomain>"
},
"maildomain": "@die_domain",
"school": "schule",
"password_length": 8
}
-->
<script>
import Hashids from "hashids";
import { updater } from './helfer'
const mysql = R("mysql");
export let knexConfig, privat
let regel = [], foerder = [], schueler = [], error;
if (!privat.paedml_salt) throw "Kein Salt";
if (!privat.domain) throw "Keine Domain";
const hashids = new Hashids( privat.paedml_salt, 8, "abcdefghkmnpqrstuvwxyz23456789");
const h = (id) => hashids.encode(id);
const mysql_connection = mysql.createConnection(knexConfig.connection);
knexConfig.connection.database="schild_kbk"
const mysql_connection2 = mysql.createConnection(knexConfig.connection);
mysql_connection.connect();
mysql_connection2.connect();
// const hasNonAsciiCharacters = (str) => /[^\u0000-\u007f]/.test(str);
const query = `SELECT s.ID, Name, Vorname, Klasse, Geburtsdatum, GU_ID
FROM schueler s
WHERE s.Status = 2 AND s.Geloescht = "-" AND s.Gesperrt = "-"
ORDER BY Klasse, Name ASC`
mysql_connection.query(query, async (e,res)=> e ? console.log(e, "reg"): (regel = res))
mysql_connection2.query(query, async (e,res)=> e ? console.log(e, "förder"): (foerder = res))
$: {
try {
if (regel.length && foerder.length)
schueler = updater(regel.concat(foerder));
console.log('Datensätze verarbeitet: ', schueler.length + '/' + (regel.length+foerder.length))
} catch (e) {
error = e.message;
}
};
</script>
{#if schueler.length}
<pre>ID,Nachname,Vornamen,Klasse,Passwort,Geburtstag,Email
{#each schueler as s}{s.username},{s.Name},{s.Vorname},{s.Klasse},{h(s.hash)},{s.Geburtsdatum},{s.username}@{privat.domain}<br>{/each}</pre>
{/if}
{#if error}
{@html error}
{/if}