Releaseversion
This commit is contained in:
85
homepage/machs/lib/api.php
Normal file
85
homepage/machs/lib/api.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
function processPostData($db, $post, $redirectLocation = "."){
|
||||
if($post['action']){
|
||||
if($post['action']=="giveUserAnAchievement"){
|
||||
giveUserAnAchievement(
|
||||
$db,
|
||||
$post['userId'],
|
||||
$post['achievementId']
|
||||
);
|
||||
}
|
||||
if($post['action']=="addAchievement"){
|
||||
addAchievement(
|
||||
$db,
|
||||
$post['name'],
|
||||
$post['description']
|
||||
);
|
||||
}
|
||||
if($post['action']=="updateAchievement"){
|
||||
updateAchievement(
|
||||
$db,
|
||||
$post['achievementId'],
|
||||
$post['name'],
|
||||
$post['description'],
|
||||
$post['rootId'],
|
||||
$post['level']
|
||||
);
|
||||
}
|
||||
if($post['redirectLocation'])
|
||||
$redirectLocation = $post['redirectLocation'];
|
||||
header("Location: ".$redirectLocation);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function sendEmail($toEmail, $emailText, $emailSubject){
|
||||
try{
|
||||
$date=new DateTime();
|
||||
mail(
|
||||
$toEmail,
|
||||
$emailSubject,
|
||||
$emailText
|
||||
);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
function attendancesAssocArray2text($attendancesAssocArray){
|
||||
$ret = "";
|
||||
foreach($attendancesAssocArray as $date => $attendees){
|
||||
$ret .= $date."\n";
|
||||
foreach($attendees as $a){
|
||||
$ret .= "\n";
|
||||
$ret .= "Name: ".$a['name'].", ".$a['vorname']."\n";
|
||||
$ret .= "PLZ: ".$a['corona_PLZ']."\n";
|
||||
$ret .= "Tel.: ".$a['corona_telephon']."\n";
|
||||
$ret .= "eMail: ".$a['corona_eMail']."\n";
|
||||
}
|
||||
$ret .= "\n";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function attendancesAssocArray2mdList($attendancesAssocArray, $date=null){
|
||||
if($date == null)
|
||||
$date=new DateTime();
|
||||
$ret = "# Anwesenheitsliste zur Corona-Kontaktverfolgung der Abteilung Judo des CWSV vom ".$date->format("Y-m-d")."\n\n";
|
||||
foreach($attendancesAssocArray as $d => $attendees){
|
||||
$ret .= "## ".$d."\n";
|
||||
$i=0;
|
||||
foreach($attendees as $a){
|
||||
$i += 1;
|
||||
$ret .= "\n";
|
||||
$ret .= $i." ".$a['name'].", ".$a['vorname']."\n";
|
||||
$ret .= " - PLZ: ".$a['corona_PLZ']."\n";
|
||||
$ret .= " - Tel.: ".$a['corona_telephon']."\n";
|
||||
$ret .= " - eMail: ".$a['corona_eMail']."\n";
|
||||
}
|
||||
$ret .= "\n";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user