phpstan level 0 error free - fixes for kyu subpage - move mams into participo framework - remove legacy `lib/db.php` usage - add attributer admin function - add newsposter - fixing apiKey creation
166 lines
5.1 KiB
PHP
166 lines
5.1 KiB
PHP
<?php
|
|
|
|
require_once "participoLib/participo.php";
|
|
require_once "participoLib/dbConnector.php";
|
|
require_once "participoLib/apiKey.php";
|
|
require_once "participoLib/shiai.php";
|
|
require_once "participoLib/event.php";
|
|
require_once "participoLib/starter.php";
|
|
|
|
class eventPlaner
|
|
{
|
|
// db table column names
|
|
private static $dbTable = [
|
|
"events" => "wkParticipo_Events",
|
|
"starts" => "wkParticipo_Starter",
|
|
"user" => "wkParticipo_Users",
|
|
"shiaiCal" => "wettkampfkalender",
|
|
"wardship" => "vormundschaft",
|
|
];
|
|
|
|
// request coming starts from the db
|
|
private static function getComingStarts($sinceDate = null, $userId = null)
|
|
{
|
|
$userId = $userId ?? participo::getSessionUserId();
|
|
$sinceDate = $sinceDate ?? new DateTime();
|
|
|
|
$params = [
|
|
":userId" => ["value" => $userId, "data_type" => PDO::PARAM_INT],
|
|
":sinceDate" => [
|
|
"value" => $sinceDate->format("Y-m-d"),
|
|
"data_type" => PDO::PARAM_STR,
|
|
],
|
|
];
|
|
|
|
// shorter variable names for better readability
|
|
$starts = self::$dbTable["starts"];
|
|
$user = self::$dbTable["user"];
|
|
$events = self::$dbTable["events"];
|
|
$shiaiCal = self::$dbTable["shiaiCal"];
|
|
$wardship = self::$dbTable["wardship"];
|
|
|
|
$query =
|
|
"SELECT " .
|
|
"`" .
|
|
$events .
|
|
"`.`id` as eventId, " .
|
|
"`" .
|
|
$events .
|
|
"`.`date` as eventDate, " .
|
|
"`" .
|
|
$events .
|
|
"`.`meldefrist` as deadline, " .
|
|
"`" .
|
|
$starts .
|
|
"`.`id` as starterId, " .
|
|
"`" .
|
|
$user .
|
|
"`.`id` as userId, " .
|
|
"`" .
|
|
$user .
|
|
"`.`name` as userName, " .
|
|
"`" .
|
|
$user .
|
|
"`.`vorname` as userFirstname, " .
|
|
"`" .
|
|
$shiaiCal .
|
|
"`.`veranstaltung` as eventName " .
|
|
"FROM `" .
|
|
$starts .
|
|
"` " .
|
|
"LEFT JOIN `" .
|
|
$user .
|
|
"` ON `" .
|
|
$starts .
|
|
"`.`userId` = `" .
|
|
$user .
|
|
"`.`id` " .
|
|
"LEFT JOIN `" .
|
|
$events .
|
|
"` ON `" .
|
|
$starts .
|
|
"`.`eventId` = `" .
|
|
$events .
|
|
"`.`id` " .
|
|
"LEFT JOIN `" .
|
|
$shiaiCal .
|
|
"` ON `" .
|
|
$events .
|
|
"`.`wkId` = `" .
|
|
$shiaiCal .
|
|
"`.`lfdeNr` " .
|
|
"LEFT JOIN `" .
|
|
$wardship .
|
|
"` ON `" .
|
|
$user .
|
|
"`.`id` = `" .
|
|
$wardship .
|
|
"`.`kidId` " .
|
|
"WHERE `" .
|
|
$events .
|
|
"`.`date` >= :sinceDate AND ( `" .
|
|
$wardship .
|
|
"`.`userId` = :userId OR `" .
|
|
$starts .
|
|
"`.`userId` = :userId ) " .
|
|
"ORDER BY `" .
|
|
$events .
|
|
"`.`date` DESC;";
|
|
|
|
$comingStarts = dbConnector::query($query, $params);
|
|
|
|
return $comingStarts;
|
|
}
|
|
|
|
public static function getComingWkEvents($someOptions = [])
|
|
{
|
|
// wir befinden uns in der Übergangsphase:
|
|
// - als Standard wird das derzeitige Verhalten definiert (ISO-8859-1
|
|
// und die Konvertierung erfolgt ausserhalb)
|
|
// - wenn einmal alle mbConvertEncoding weg sind, kann der Standard auf
|
|
// das gewünschte Verhalten umgestellt werden
|
|
$dbCharset = $someOptions["dbCharset"] ?? "ISO-8859-1";
|
|
// dbCharset = $someOptions['outCharset'] ?? "UTF-8";// das spätere, gewünschte Verhalten
|
|
$outCharset = $someOptions["outCharset"] ?? "ISO-8859-1";
|
|
|
|
$query =
|
|
"SELECT " .
|
|
"wkParticipo_Events.id, " .
|
|
"wkParticipo_Events.date, " .
|
|
"wkParticipo_Events.wkId, " .
|
|
"wkParticipo_Events.meldefrist, " .
|
|
"wkParticipo_Events.bemerkungen, " .
|
|
"wkParticipo_Events.kvOptions, " .
|
|
"wettkampfkalender.Datum, " .
|
|
"wettkampfkalender.Veranstaltung, " .
|
|
"wettkampfkalender.Altersklassen, " .
|
|
"wettkampfkalender.Ort, " .
|
|
"wettkampfkalender.Ausschreibung, " .
|
|
"wettkampfkalender.Routenplaner " .
|
|
"FROM wkParticipo_Events " .
|
|
"LEFT JOIN wettkampfkalender " .
|
|
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId " .
|
|
"WHERE wkParticipo_Events.date >= CURDATE() " .
|
|
"ORDER BY wkParticipo_Events.date;";
|
|
$ret = dbConnector::query($query);
|
|
$events = [];
|
|
foreach ($ret as $event) {
|
|
array_push($events, Event::fromDbArray($event));
|
|
}
|
|
return $events;
|
|
}
|
|
|
|
public static function getHtmlEventTable($eventList)
|
|
{
|
|
$ret = "<table>";
|
|
foreach ($eventList as $event) {
|
|
$ret .= $event->htmlTableRow();
|
|
}
|
|
$ret .= "</table>";
|
|
foreach ($eventList as $event) {
|
|
$ret .= $event->htmlModal();
|
|
}
|
|
return $ret;
|
|
}
|
|
}
|