removed auth usage, php-cs-fixer

This commit is contained in:
marko
2022-06-26 19:24:14 +02:00
parent c5a6699caf
commit 269c680fe0
6 changed files with 400 additions and 387 deletions

View File

@@ -1,41 +1,42 @@
<?php
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
require_once("config/participo.php");
require_once("./local/dbConf.php");
require_once("./local/cwsvJudo.php");
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
require_once 'config/participo.php';
require_once("./lib/db.php");
require_once("./lib/api.php");
require_once("./lib/participoLib/participo.php");
require_once './local/dbConf.php';
require_once './local/cwsvJudo.php';
require_once("./auth.php");
require_once './lib/db.php';
require_once './lib/api.php';
require_once './lib/participoLib/participo.php';
require_once($config['basePath']."/config/cwsvJudo.config.php");
require_once($config['basePath']."/config/phpcount.config.php");
require_once $config['basePath'] . '/config/cwsvJudo.config.php';
require_once $config['basePath'] . '/config/phpcount.config.php';
dbConnector::connect(
$cwsvJudoConfig["db"]["host"],
$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
$cwsvJudoConfig['db']['host'],
$cwsvJudoConfig['db']['name'],
$cwsvJudoConfig['db']['user'],
$cwsvJudoConfig['db']['password']
);
participo::authentificate();
$userData = getUserData(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
$usersKids = getUsersKids(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
abstract class AttendanceType {
abstract class AttendanceType
{
const __default = null;
const Training = 1;
const Excused = 2;
const Ill = 3;
const Training = 1;
const Excused = 2;
const Ill = 3;
const SpecialTraining = 4;
const Competition = 5;
const Competition = 5;
}
abstract class UserAttribute {
abstract class UserAttribute
{
const __default = null;
const IsAdmin = 1;
@@ -43,79 +44,86 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
const Passive = 3;
const InTraining = 4;
}
/**
* Datastructure and interface for an user
*/
class User{
class User
{
private $id = null;
private $familyName = null;
private $givenName = null;
private $attributes = null;
function __construct($id, $familyName, $givenName){
public function __construct($id, $familyName, $givenName)
{
$this->id = (int)$id;
$this->familyName = $familyName;
$this->givenName = $givenName;
}
static function fromArray($member){
public static function fromArray($member)
{
$id = $member['id'];
$familyName = $member['familyName'];
$givenName = $member['givenName'];
return new User($id, $familyName, $givenName);
}
static function getUsers($db, $options = []){
$attributeId = $options["attributeId"] ?? null;
public static function getUsers($db, $options = [])
{
$attributeId = $options['attributeId'] ?? null;
$params = [];
$query = "SELECT ".
"`cwsvjudo`.`wkParticipo_Users`.`id` AS `id`".
", `cwsvjudo`.`wkParticipo_Users`.`vorname` AS `givenName`".
", `cwsvjudo`.`wkParticipo_Users`.`name` AS `familyName`".
", `cwsvjudo`.`wkParticipo_userAttributes`.`name` AS `attributeName`".
"FROM `cwsvjudo`.`wkParticipo_Users` ".
"JOIN `cwsvjudo`.`wkParticipo_user<=>userAttributes` ".
"ON `cwsvjudo`.`wkParticipo_Users`.`id` = `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`userId`".
"JOIN `cwsvjudo`.`wkParticipo_userAttributes` ".
"ON `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`attributeId` = `cwsvjudo`.`wkParticipo_userAttributes`.`id`";
if($attributeId != null){
$query .= " WHERE `cwsvjudo`.`wkParticipo_userAttributes`.`id` = :attributeId";
$params['attributeId'] = ['value'=>$attributeId, 'data_type'=>PDO::PARAM_INT];
$query = 'SELECT ' .
'`cwsvjudo`.`wkParticipo_Users`.`id` AS `id`' .
', `cwsvjudo`.`wkParticipo_Users`.`vorname` AS `givenName`' .
', `cwsvjudo`.`wkParticipo_Users`.`name` AS `familyName`' .
', `cwsvjudo`.`wkParticipo_userAttributes`.`name` AS `attributeName`' .
'FROM `cwsvjudo`.`wkParticipo_Users` ' .
'JOIN `cwsvjudo`.`wkParticipo_user<=>userAttributes` ' .
'ON `cwsvjudo`.`wkParticipo_Users`.`id` = `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`userId`' .
'JOIN `cwsvjudo`.`wkParticipo_userAttributes` ' .
'ON `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`attributeId` = `cwsvjudo`.`wkParticipo_userAttributes`.`id`';
if ($attributeId != null) {
$query .= ' WHERE `cwsvjudo`.`wkParticipo_userAttributes`.`id` = :attributeId';
$params['attributeId'] = ['value' => $attributeId, 'data_type' => PDO::PARAM_INT];
}
$query .= ";";
$query .= ';';
$response = dbQuery($db, $query, $params);
$users = [];
foreach( $response as $r){
foreach ($response as $r) {
$users[] = User::fromArray($r);
}
return $users;
}
static function htmlTable($users){
echo("<table><tr><th>Id<th>Name</th><th>Vorname</th></tr>");
foreach( $users as $u){
echo("<tr><td>".$u->id."</td><td>".$u->familyName."</td><td>".$u->givenName."</td></tr>");
public static function htmlTable($users)
{
echo('<table><tr><th>Id<th>Name</th><th>Vorname</th></tr>');
foreach ($users as $u) {
echo('<tr><td>' . $u->id . '</td><td>' . $u->familyName . '</td><td>' . $u->givenName . '</td></tr>');
}
echo("</table>");
echo('</table>');
}
}
/**
* Datastructure and interface for attendances
*/
class Attendance{
class Attendance
{
private $id = null; //< id in the db
private $userId = null; //< user of the attendance
private $date = null; //< date of the attendance
private $type = null; //< type of attendance
static private $Types = [
AttendanceType::Training => "Training"
, AttendanceType::Excused => "Entschuldigt"
, AttendanceType::Ill => "Krank"
, AttendanceType::SpecialTraining => "SonderTraining"
, AttendanceType::Competition => "Wettkampf"
private $type = null; //< type of attendance
private static $Types = [
AttendanceType::Training => 'Training', AttendanceType::Excused => 'Entschuldigt', AttendanceType::Ill => 'Krank', AttendanceType::SpecialTraining => 'SonderTraining', AttendanceType::Competition => 'Wettkampf'
];
static private $NameOfMonth = [1=>"Januar", 2=>"Februar", 3=>"März", 4=>"April", 4=>"Mai", 6=>"Juni", 7=>"Juli", 8=>"August", 9=>"September", 10=>"Oktober", 11=>"November", 12=>"Dezember"];
private static $NameOfMonth = [1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 4 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember'];
/**
* constructor
*
@@ -123,20 +131,24 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
* @param string/int $userId user of the attendance
* @param string $date date of the attendance
*/
function __construct($id, $userId, $date){
public function __construct($id, $userId, $date)
{
$this->id = (int)$id;
$this->userId = (int)$userId;
$this->date = DateTime::createFromFormat("Y-m-d", $date);
$this->date = DateTime::createFromFormat('Y-m-d', $date);
}
/**
* create an Attendance from an assoziative array
*
* @param array $member
* @return Attendance
*/
static function constructFromArray($member){
public static function constructFromArray($member)
{
return new Attendance($member['id'], $member['userId'], $member['date']);
}
/**
* request a users attendances from the database
*
@@ -144,16 +156,18 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
* @param int/string $userId
* @return array with attendances
*/
static function getUsersAttendance($db, $userId){
public static function getUsersAttendance($db, $userId)
{
$userId = (int)$userId;
$query = "SELECT `id`, `date` FROM `cwsvjudo`.`anwesenheit` WHERE `userId` = :userId";
$response = dbQuery($db, $query, [':userId'=>['value'=>$userId, 'data_type'=>PDO::PARAM_INT]]);
$query = 'SELECT `id`, `date` FROM `cwsvjudo`.`anwesenheit` WHERE `userId` = :userId';
$response = dbQuery($db, $query, [':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT]]);
$attendances = [];
foreach($response as $r){
foreach ($response as $r) {
$attendances[] = new Attendance($r['id'], $userId, $r['date']);
}
return $attendances;
}
/**
* html table with users attendances
*
@@ -161,56 +175,61 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
* @param string/int $userId
* @return string with html code of the attendance table
*/
static function userAttendanceHtmlTable($db, $userId){
$htmlTableString = "";
$htmlTableString .= "<ul>";
$userAttendances = Attendance::groupAttendances(
Attendance::getUsersAttendance($db, $userId)
public static function userAttendanceHtmlTable($db, $userId)
{
$htmlTableString = '';
$htmlTableString .= '<ul>';
$userAttendances = Attendance::groupAttendances(
Attendance::getUsersAttendance($db, $userId)
);
krsort($userAttendances);
foreach( $userAttendances as $year=>$months ){
$htmlTableString .= "<li>".$year."<dl>";
foreach ($userAttendances as $year => $months) {
$htmlTableString .= '<li>' . $year . '<dl>';
// Counting the attendances per half year
$attendanceCountH1 = 0;
$attendanceCountH2 = 0;
foreach($months as $month=>$days){
if(1<=$month and $month<=6){
foreach ($months as $month => $days) {
if (1 <= $month and $month <= 6) {
$attendanceCountH1 += count($days);
}
if(7<=$month and $month <= 12){
if (7 <= $month and $month <= 12) {
$attendanceCountH2 += count($days);
}
}
$htmlTableString .= "<dt>Gesamt erstes Halbjahr:</dt><dd>".$attendanceCountH1."</dd>";
$htmlTableString .= "<dt>Gesamt zweites Halbjahr:</dt><dd>".$attendanceCountH2."</dd>";
$htmlTableString .= '<dt>Gesamt erstes Halbjahr:</dt><dd>' . $attendanceCountH1 . '</dd>';
$htmlTableString .= '<dt>Gesamt zweites Halbjahr:</dt><dd>' . $attendanceCountH2 . '</dd>';
krsort($months);
foreach($months as $month=>$days){
$htmlTableString .= "<dt>".Attendance::$NameOfMonth[$month]."</dt>";
$htmlTableString .= "<dd>".join(", ", $days)."</dd>";
foreach ($months as $month => $days) {
$htmlTableString .= '<dt>' . Attendance::$NameOfMonth[$month] . '</dt>';
$htmlTableString .= '<dd>' . join(', ', $days) . '</dd>';
}
$htmlTableString .= "</dl></li>";
$htmlTableString .= '</dl></li>';
}
$htmlTableString .= "</ul>";
$htmlTableString .= '</ul>';
return $htmlTableString;
}
/**
* group the attendances by year and month.
*
* @param list $attendances list of attendances
* @return array[int][int](list of int) array with a list of days for every month in every year
*/
static function groupAttendances($attendances){
* @return array[int][int](list of int) array with a list of days for every month in every year
*/
public static function groupAttendances($attendances)
{
$groupedAttendances = [];
foreach($attendances as $a){
$year =(int) $a->date->format("Y");
if(!array_key_exists($year, $groupedAttendances))
foreach ($attendances as $a) {
$year = (int) $a->date->format('Y');
if (!array_key_exists($year, $groupedAttendances)) {
$groupedAttendances[$year] = [];
$month = (int) $a->date->format("m");
if(!array_key_exists($month, $groupedAttendances[$year]))
}
$month = (int) $a->date->format('m');
if (!array_key_exists($month, $groupedAttendances[$year])) {
$groupedAttendances[$year][$month] = [];
$day = (int) $a->date->format("d");
$groupedAttendances[$year][$month][]=$day;
}
$day = (int) $a->date->format('d');
$groupedAttendances[$year][$month][] = $day;
}
return $groupedAttendances;
}
@@ -223,7 +242,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php readfile("./shared/imports.php");?>
<?php readfile('./shared/imports.php'); ?>
<!-- inits for the materializeCss -->
<script>
@@ -254,50 +273,53 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
<img alt="cwsvJudoApps" style="max-width:100%;height:12vh;" class="responsive-img" src="http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png" />
</a>
</li>
<?php require_once("sidenav/loginStatus.php");?><!-- brings its own li -->
<?php require_once 'sidenav/loginStatus.php'; ?><!-- brings its own li -->
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#attendance-<?php echo($userData['id']);?>">Selber</a>
<a class="waves-effect waves-teal right-align" href="#attendance-<?php echo($userData['id']); ?>">Selber</a>
</li>
<?php
foreach($usersKids as $k){
if($userData['id']==$k['id']) continue;
?>
foreach ($usersKids as $k) {
if ($userData['id'] == $k['id']) {
continue;
} ?>
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#attendance-<?php echo($k['kidId']); ?>"><?php echo($k['vorname']." ".$k['name']);?></a>
<a class="waves-effect waves-teal right-align" href="#attendance-<?php echo($k['kidId']); ?>"><?php echo($k['vorname'] . ' ' . $k['name']); ?></a>
</li>
<?php }?>
<?php
}?>
</ul>
</header>
<?php
if($_SESSION['login']){
?>
if ($_SESSION['login']) {
?>
<main>
<?php //User::htmlTable( User::getUsers(dbConnector::getDbConnection(), ['attributeId' => UserAttribute::InTraining]));?>
<?php // show own ...
$ownAttendances = Attendance::getUsersAttendance(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
if (!empty($ownAttendances)){
echo(
"<h2 id=\"attendance-".$userData['id']."\">Eigene Anwesenheiten</h2>".
if (!empty($ownAttendances)) {
echo(
'<h2 id="attendance-' . $userData['id'] . '">Eigene Anwesenheiten</h2>' .
Attendance::userAttendanceHtmlTable(dbConnector::getDbConnection(), $userData['id'])
); require_once("./lib/participoLib/participo.php");
);
require_once './lib/participoLib/participo.php';
}
// ... and kids attendances
if (!empty($usersKids)) {
echo('<h2>Anwesenheit der Kinder</h2>');
foreach ($usersKids as $k) {
if ($userData['id'] == $k['kidId']) {
continue;
}
// ... and kids attendances
if (!empty($usersKids)){
echo("<h2>Anwesenheit der Kinder</h2>");
foreach($usersKids as $k){
if($userData['id']==$k['kidId']) continue;
echo(
"<h3 id=\"attendance-".$k['kidId']."\">".$k['vorname']." ".$k['name']."</h3>".
echo(
'<h3 id="attendance-' . $k['kidId'] . '">' . $k['vorname'] . ' ' . $k['name'] . '</h3>' .
Attendance::userAttendanceHtmlTable(dbConnector::getDbConnection(), $k['kidId'])
);
}
}
?>
}
} ?>
</main>
<?php
}
}
?>
</body>
</html>

View File

@@ -1,16 +0,0 @@
<?php
session_start();
// Falls der serverseitige LoginCookie nicht gesetzt ist,
// leite zur loginSeite weiter
if (empty($_SESSION['login'])) {
header("Location: login?returnTo=".urlencode($_SERVER['REQUEST_URI']), TRUE, 301);
exit;
} else {
$login_status =
"<div style=\"border: 1px solid black\">".
"Datum: ".date("Y-m-d")."<br />".
"Angemeldet als <strong>".htmlspecialchars($_SESSION['user']['username'])."</strong>.<br />".
"<a href=\"logout.php\">Sitzung beenden</a>".
"</div>";
}
?>

View File

@@ -1,21 +1,20 @@
<?php
require_once("config/participo.php");
require_once 'config/participo.php';
require_once("./local/cwsvJudo.php");
require_once("./lib/db.php");// should be replaced
require_once("./lib/api.php");// should be replaced
require_once("participoLib/participo.php");
require_once("participoLib/planer.php");
require_once './local/cwsvJudo.php';
require_once './lib/db.php'; // should be replaced
require_once './lib/api.php'; // should be replaced
require_once 'participoLib/participo.php';
require_once 'participoLib/planer.php';
dbConnector::connect(
$cwsvJudoConfig["db"]["host"],
$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
$cwsvJudoConfig['db']['host'],
$cwsvJudoConfig['db']['name'],
$cwsvJudoConfig['db']['user'],
$cwsvJudoConfig['db']['password']
);
eventPlaner::setDbConnection( dbConnector::getDbConnection() );
eventPlaner::setDbConnection(dbConnector::getDbConnection());
participo::authentificate();
$userData = getUserData(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
@@ -26,7 +25,7 @@ require_once("config/participo.php");
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php readfile("./shared/imports.php");?>
<?php readfile('./shared/imports.php'); ?>
<!-- inits for the materializeCss -->
<script>
@@ -61,7 +60,7 @@ require_once("config/participo.php");
<img alt="cwsvJudoApps" style="max-width:100%;height:12vh;" class="responsive-img" src="http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png" />
</a>
</li>
<?php require_once("sidenav/loginStatus.php");?><!-- brings its own li -->
<?php require_once 'sidenav/loginStatus.php'; ?><!-- brings its own li -->
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#mitmachApps">Mitmachen<i class="material-icons">accessibility</i></a>
</li>
@@ -74,7 +73,7 @@ require_once("config/participo.php");
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#configApps">Einstellen<i class="material-icons">settings</i></a>
</li>
<?php if( participo::isUserAdmin( $userData['id']) ){?>
<?php if (participo::isUserAdmin($userData['id'])) {?>
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#admiStuff">adminStuff</a>
</li>
@@ -83,30 +82,30 @@ require_once("config/participo.php");
</header>
<?php
if($_SESSION['login']){
?>
if ($_SESSION['login']) {
?>
<main>
<!-- List of Mitmach-Apps -->
<h2>Zum Mitmachen</h2>
<div class="row" id="mitmachApps">
<?php
<?php
echo(
AppCard::fromArray([
'link' => "/machs",
'title' => "<em>M</em>ein <em>Ach</em>ievement <em>S</em>ystem",
'description'=> "Ein kleines Achievementsystem für die tägliche Herausforderung",
'imgUrl' => "images/mountain-climber.svg",
'actions' => [
AppCardAction::fromArray(['caption'=>"MAchS", 'link'=>"/machs"]),
'link' => '/machs',
'title' => '<em>M</em>ein <em>Ach</em>ievement <em>S</em>ystem',
'description' => 'Ein kleines Achievementsystem für die tägliche Herausforderung',
'imgUrl' => 'images/mountain-climber.svg',
'actions' => [
AppCardAction::fromArray(['caption' => 'MAchS', 'link' => '/machs']),
],
])->htmlCode().
])->htmlCode() .
AppCard::fromArray([
'link' => "/pages/desktop/wkParticipo",
'title' => "Event-Planer",
'description'=> "Organisieren der Teilnahmen (und nicht-Teilnahmen) an Wettkämpfen, Sondertrainingseinheiten, Feiern etc.</p>".eventPlaner::getHtmlEventTable(eventPlaner::getCommingWkEvents())."<p>",
'imgUrl' => "/ressourcen/graphiken/icons/terminKalender.svg",
'actions' => [
AppCardAction::fromArray(['caption'=>"Planer", 'link'=>"/pages/desktop/wkParticipo"]),
'link' => '/pages/desktop/wkParticipo',
'title' => 'Event-Planer',
'description' => 'Organisieren der Teilnahmen (und nicht-Teilnahmen) an Wettkämpfen, Sondertrainingseinheiten, Feiern etc.</p>' . eventPlaner::getHtmlEventTable(eventPlaner::getCommingWkEvents()) . '<p>',
'imgUrl' => '/ressourcen/graphiken/icons/terminKalender.svg',
'actions' => [
AppCardAction::fromArray(['caption' => 'Planer', 'link' => '/pages/desktop/wkParticipo']),
],
])->htmlCode()
)
@@ -118,26 +117,25 @@ echo(
<?php
echo(
AppCard::fromArray([
'link' => "infoZettel",
'title' => "Infozettel",
'description'=> "Online-Variante der Infozettel und Newsletter",
'imgUrl' => "images/info.svg",
'actions' => [
AppCardAction::fromArray(['caption'=>"Info", 'link'=>"infoZettel"]),
'link' => 'infoZettel',
'title' => 'Infozettel',
'description' => 'Online-Variante der Infozettel und Newsletter',
'imgUrl' => 'images/info.svg',
'actions' => [
AppCardAction::fromArray(['caption' => 'Info', 'link' => 'infoZettel']),
],
])->htmlCode().
])->htmlCode() .
AppCard::fromArray([
'link' => "attendance",
'title' => "Teilnahme",
'description'=> "Eine kleine Übersicht, wie wie oft man beim Training war",
'imgUrl' => "http://cwsvjudo.bplaced.net/ressourcen/graphiken/icons/calendarIcon.svg",
'actions' => [
AppCardAction::fromArray(['caption'=>"Anwesenheit", 'link'=>"attendance"]),
'link' => 'attendance',
'title' => 'Teilnahme',
'description' => 'Eine kleine Übersicht, wie wie oft man beim Training war',
'imgUrl' => 'http://cwsvjudo.bplaced.net/ressourcen/graphiken/icons/calendarIcon.svg',
'actions' => [
AppCardAction::fromArray(['caption' => 'Anwesenheit', 'link' => 'attendance']),
],
])->htmlCode()
);
// @todo attendanceApp
?>
// @todo attendanceApp?>
</div> <!-- infoApps -->
<h2>Zum Nachschlagen</h2>
@@ -145,26 +143,25 @@ echo(
<?php
echo(
AppCard::fromArray([
'link' => "kyu",
'title' => "Kyu",
'description'=> "Die Prüfungsprogamme der einzelnen Gürtelstufen in Bild, Ton und Text",
'imgUrl' => "images/obi.svg",
'actions' => [
AppCardAction::fromArray(['caption'=>"Kyu-Programme", 'link'=>"kyu"]),
'link' => 'kyu',
'title' => 'Kyu',
'description' => 'Die Prüfungsprogamme der einzelnen Gürtelstufen in Bild, Ton und Text',
'imgUrl' => 'images/obi.svg',
'actions' => [
AppCardAction::fromArray(['caption' => 'Kyu-Programme', 'link' => 'kyu']),
],
])->htmlCode().
])->htmlCode() .
AppCard::fromArray([
'link' => "/JudoWiki",
'title' => "JudoWiki",
'description'=> "Ein Wiki zum Thema Judo",
'imgUrl' => "http://cwsvjudo.bplaced.net/ressourcen/graphiken/icons/wikipediaW.svg",
'actions' => [
AppCardAction::fromArray(['caption'=>"JudoWiki", 'link'=>"/JudoWiki"]),
'link' => '/JudoWiki',
'title' => 'JudoWiki',
'description' => 'Ein Wiki zum Thema Judo',
'imgUrl' => 'http://cwsvjudo.bplaced.net/ressourcen/graphiken/icons/wikipediaW.svg',
'actions' => [
AppCardAction::fromArray(['caption' => 'JudoWiki', 'link' => '/JudoWiki']),
],
])->htmlCode()
);
// @todo horstWolf
?>
// @todo horstWolf?>
</div><!-- lexiApps -->
<!-- List of ConfigStuff -->
@@ -173,31 +170,29 @@ echo(
<?php
echo(
AppCard::fromArray([
'link' => "user",
'title' => "User-Config",
'description' => "Einstellungen zum aktuellen Benutzer dessen Kindern",
'imgUrl' => "images/account.svg",
'link' => 'user',
'title' => 'User-Config',
'description' => 'Einstellungen zum aktuellen Benutzer dessen Kindern',
'imgUrl' => 'images/account.svg',
'actions' => [
AppCardAction::fromArray(['caption'=>"Config", 'link'=>"user"]),
AppCardAction::fromArray(['caption' => 'Config', 'link' => 'user']),
],
])->htmlCode()
);
?>
); ?>
</div> <!-- configApps -->
<?php
// AdminStuff, thats only visible for Admins
if( participo::isUserAdmin( $userData['id'] ) ){
if (participo::isUserAdmin($userData['id'])) {
echo(
"<h2>AdminStuff</h2>".
"<div id=\"admiStuff\" class=\"row\">".
'<h2>AdminStuff</h2>' .
'<div id="admiStuff" class="row">' .
AppCard::fromArray([
'title' =>"lastLogins",
'description' => "</p>".lastLoginTable()."</p>"
])->htmlCode().
"</div>"
'title' => 'lastLogins',
'description' => '</p>' . lastLoginTable() . '</p>'
])->htmlCode() .
'</div>'
);
}
?>
} ?>
</main>
<?php
}

View File

@@ -1,31 +1,30 @@
<?php
require_once("config/participo.php");
require_once 'config/participo.php';
require_once("participoLib/participo.php");
require_once("./local/dbConf.php");
require_once("./local/cwsvJudo.php");
require_once 'participoLib/participo.php';
require_once("./lib/db.php");
require_once("./lib/api.php");
require_once("./auth.php");
require_once './local/dbConf.php';
require_once './local/cwsvJudo.php';
require_once './lib/db.php';
require_once './lib/api.php';
$basePath = $config['basePath'];
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/ressourcen/phpLib/parsedown/Parsedown.php");
require_once($basePath."/ressourcen/phpLib/Spyc/Spyc.php");
require_once $basePath . '/config/cwsvJudo.config.php';
require_once $basePath . '/ressourcen/phpLib/parsedown/Parsedown.php';
require_once $basePath . '/ressourcen/phpLib/Spyc/Spyc.php';
participo::authentificate();
// get a list of all infoZettel
$fileList = glob($basePath."/infoZettel/*.md");
$fileList = glob($basePath . '/infoZettel/*.md');
rsort($fileList);
$years = [];
foreach($fileList as $file){
foreach ($fileList as $file) {
$years[] = (int)substr(basename($file), 0, 4);
}
$years = array_unique($years);
?>
<!DOCTYPE html>
<html>
@@ -33,7 +32,7 @@ $years = array_unique($years);
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php readfile("./shared/imports.php");?>
<?php readfile('./shared/imports.php'); ?>
<!-- adjustments to parsedowncards (smaller headings) -->
<link rel="stylesheet" href="css/parsedownCard.css">
@@ -66,14 +65,14 @@ $years = array_unique($years);
<img style="max-width:100%;height:12vh;" class="responsive-img" src="http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png" />
</a>
</li>
<li><?php require_once("sidenav/loginStatus.php");?></li>
<li><?php require_once 'sidenav/loginStatus.php'; ?></li>
<li class="bold">
<a class="waves-effect waves-teal left-align" href="/participo">zurück</a>
</li>
<?php
foreach($years as $year){?>
foreach ($years as $year) {?>
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#infoZettel-<?php echo($year);?>"><?php echo($year);?></a>
<a class="waves-effect waves-teal right-align" href="#infoZettel-<?php echo($year); ?>"><?php echo($year); ?></a>
</li>
<?php
}
@@ -84,37 +83,36 @@ foreach($years as $year){?>
<main>
<!-- List of Infos -->
<div class="row" id="infoList">
<?php
<?php
$currentYear = (int)substr(basename($fileList[0]), 0, 4);
echo("<h2 id=\"infoZettel-".$currentYear."\">".$currentYear."</h2>");
echo('<h2 id="infoZettel-' . $currentYear . '">' . $currentYear . '</h2>');
foreach($fileList as $file){
foreach ($fileList as $file) {
$thisYear = (int)substr(basename($file), 0, 4);
if($thisYear != $currentYear){
$currentYear=$thisYear;
echo("<h2 id=\"infoZettel-".$currentYear."\">".$currentYear."</h2>");
if ($thisYear != $currentYear) {
$currentYear = $thisYear;
echo('<h2 id="infoZettel-' . $currentYear . '">' . $currentYear . '</h2>');
}
// get a list of all infoZettel
$fileList = glob($basePath."/infoZettel/*.md");
rsort($fileList);
// get a list of all infoZettel
$fileList = glob($basePath . '/infoZettel/*.md');
rsort($fileList);
foreach($fileList as $file){
$thisYear = (int)substr(basename($file), 0, 4);
if($thisYear != $currentYear){
$currentYear=$thisYear;
echo("<h2 id=\"infoZettel-".$currentYear."\">".$currentYear."</h2>");
}
foreach ($fileList as $file) {
$thisYear = (int)substr(basename($file), 0, 4);
if ($thisYear != $currentYear) {
$currentYear = $thisYear;
echo('<h2 id="infoZettel-' . $currentYear . '">' . $currentYear . '</h2>');
}
$infoZettel = loadMarkdownFile($file);
echo(
$infoZettel = loadMarkdownFile($file);
echo(
AppCard::fromArray([
'title' => $infoZettel['yaml']['title'],
'description'=> Parsedown::instance()->text( $infoZettel['mdText'] ),
])->htmlCode(['extraClass'=>"parsedownCard"])
'title' => $infoZettel['yaml']['title'],
'description' => Parsedown::instance()->text($infoZettel['mdText']),
])->htmlCode(['extraClass' => 'parsedownCard'])
);
}
?>
} ?>
</div><!-- End of Infos -->
</main>
<?php

View File

@@ -1,7 +1,7 @@
<?php
class shiai{
class shiai
{
private $id = null; //< unique id
private $date = null; //< date of the shiai
private $name = null; //< name of the shiai as string
@@ -12,10 +12,11 @@ class shiai{
private $galleryUrl = null; //< url of the gallery to a gallery of the shiai
private $promoImgUrl = null; //< promotional image for the shiai (as url)
function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl, $promoImgUrl){
public function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl, $promoImgUrl)
{
//! @todo input validation and sanitation
$this->id = (int) $id;
$this->date = DateTime::createFromFormat("Y-m-d", $date);
$this->date = DateTime::createFromFormat('Y-m-d', $date);
$this->name = $name;
$this->ageclasses = $ageclasses;
$this->place = $place;
@@ -25,23 +26,29 @@ class shiai{
$this->promoImgUrl = $promoImgUrl;
}
public function getName(){
public function getName()
{
return $this->name;
}
public function getAgeClasses(){
return $this->ageclasses ? $this->ageclasses : "-";
public function getAgeClasses()
{
return $this->ageclasses ? $this->ageclasses : '-';
}
public function getId(){
public function getId()
{
return $this->id;
}
static public function fromArray($member){
public static function fromArray($member)
{
return new shiai(
$member['lfdeNr'] ?? null,
$member['Datum'] ?? null,
$member['Veranstaltung'] ?? "<fehlender Name>",
$member['Veranstaltung'] ?? '<fehlender Name>',
$member['Altersklassen'] ?? null,
$member['Ort'] ?? "<fehlender Ort>",
$member['Ort'] ?? '<fehlender Ort>',
$member['Ausschreibung'] ?? null,
$member['Routenplaner'] ?? null,
$member['galleryLink'] ?? null,
@@ -50,7 +57,8 @@ class shiai{
}
} // end class shiai
class event{
class event
{
private $id = null; //< unique id of the event in the db
private $date = null; //< date for the event (@todo ranges?)
private $shiaiId = null; //< unique id of the shiai in the db (if appropriate)
@@ -59,54 +67,61 @@ class event{
private $shiai = null;
function __construct($id, $date, $shiaiId, $deadline, $remarks, $shiai){
public function __construct($id, $date, $shiaiId, $deadline, $remarks, $shiai)
{
//! @todo InputValidation
$this->id = (int) $id;
$this->date = DateTime::createFromFormat("Y-m-d", $date);
$this->shiaiId = (($shiaiId!=null)?((int)$shiaiId):(null));
$this->deadline = DateTime::createFromFormat("Y-m-d", $deadline);
$this->date = DateTime::createFromFormat('Y-m-d', $date);
$this->shiaiId = (($shiaiId != null) ? ((int)$shiaiId) : (null));
$this->deadline = DateTime::createFromFormat('Y-m-d', $deadline);
$this->remarks = $remarks;
$this->shiai = $shiai;
}
function asHtmlCard(){
return
"<div class=\"card blue-grey darken-1\">".
"<div class=\"card-content white-text\">".
"<span class=\"card-title\">".$this->shiai->getName()."</span>".
"<dl>".
"<dt>Datum</dt>".
"<dd>".$this->date->format("Y-m-d")."</dd>".
"<dt>Meldefrist</dt>".
"<dd>".$this->deadline->format("Y-m-d")."</dd>".
"<dt>Altersklassen</dt>".
"<dd>".$this->shiai->getAgeClasses()."</dd>".
"</div>".
"</div>";
}
public function htmlTableRow(){
return
"<tr>".
"<td>Datum ".$this->date->format("Y-m-d")."</td>".
"<td><a href=\"/pages/desktop/wkParticipo/showWkEvent.php?eventId=".$this->id."\" >".$this->shiai->getName()."</a></td>".
"<td><a class=\"waves-effect waves-light btn-floating modal-trigger\" href=\"#event-modal-".$this->id."\"><i class=\"material-icons\">add</i></a></td>".
"</tr>";
}
public function htmlModal(){
return
"<div id=\"event-modal-".$this->id."\" class=\"modal\">".
"<div class=\"modal-content\">".
"<h4>".$this->shiai->getName()."</h4>".
"<p>A bunch of text</p>".
"</div>". // end modal-content
"<div class=\"modal-footer\">".
"<a href=\"#!\" class=\"modal-close waves-effect waves-green btn-flat\">Agree</a>".
"</div>".
"</div>";
public function asHtmlCard()
{
return
'<div class="card blue-grey darken-1">' .
'<div class="card-content white-text">' .
'<span class="card-title">' . $this->shiai->getName() . '</span>' .
'<dl>' .
'<dt>Datum</dt>' .
'<dd>' . $this->date->format('Y-m-d') . '</dd>' .
'<dt>Meldefrist</dt>' .
'<dd>' . $this->deadline->format('Y-m-d') . '</dd>' .
'<dt>Altersklassen</dt>' .
'<dd>' . $this->shiai->getAgeClasses() . '</dd>' .
'</div>' .
'</div>';
}
static public function fromArray($member){
public function htmlTableRow()
{
return
'<tr>' .
'<td>' . $this->date->format('Y-m-d') . '</td>' .
'<td><a href="/pages/desktop/wkParticipo/showWkEvent.php?eventId=' . $this->id . '" >' . $this->shiai->getName() . '</a></td>' .
'<td><a class="waves-effect waves-light btn-floating modal-trigger" href="#event-modal-' . $this->id . '"><i class="material-icons">add</i></a></td>' .
'</tr>';
}
public function htmlModal()
{
return
'<div id="event-modal-' . $this->id . '" class="modal">' .
'<div class="modal-content">' .
'<h4>' . $this->shiai->getName() . '</h4>' .
'<p>A bunch of text</p>' .
'</div>' . // end modal-content
'<div class="modal-footer">' .
'<a href="#!" class="modal-close waves-effect waves-green btn-flat">Agree</a>' .
'</div>' .
'</div>';
}
public static function fromArray($member)
{
$shiai = json_decode($member['bemerkungen'], true);
return new event(
@@ -115,72 +130,75 @@ class event{
$member['wkId'] ?? null,
$member['meldefrist'] ?? null,
$member['bemerkungen'] ?? null,
shiai::fromArray( ($shiai != null) ? $shiai : $member )
shiai::fromArray(($shiai != null) ? $shiai : $member)
);
}
} // end class event
class eventPlaner{
static private $db = null;
class eventPlaner
{
private static $db = null;
// set the dbConnection (just setting, no establishing)
public static function setDbConnection($dbConnection){
if($dbConnection instanceof PDO)
public static function setDbConnection($dbConnection)
{
if ($dbConnection instanceof PDO) {
self::$db = $dbConnection;
else
} else {
self::$db = null;
return;
}
return;
}
static public function getCommingWkEvents($someOptions=array() ){
public static function getCommingWkEvents($someOptions = [])
{
// wir befinden uns in der Übergangsphase:
// - als Standard wird das derzeitige Verhalten definiert (ISO-8859-1
// - 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
// - wenn einmal alle mbConvertEncoding weg sind, kann der Standard auf
// das gewünschte Verhalten umgestellt werden
$dbCharset = $someOptions['dbCharset'] ?? "ISO-8859-1";
$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;";
$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 = dbQuery(self::$db, $query);
$events = array();
foreach($ret as $event){
array_push( $events, event::fromArray( $event ) );
$events = [];
foreach ($ret as $event) {
array_push($events, event::fromArray($event));
}
return $events;
}
static public function getHtmlEventTable($eventList){
$ret = "<table>";
$ret .= "<!-- And now the table -->";
foreach($eventList as $event){
public static function getHtmlEventTable($eventList)
{
$ret = '<table>';
$ret .= '<!-- And now the table -->';
foreach ($eventList as $event) {
$ret .= $event->htmlTableRow();
}
$ret .= "</table>";
foreach($eventList as $event){
$ret .= '</table>';
foreach ($eventList as $event) {
$ret .= $event->htmlModal();
}
return $ret;
}
}
?>

View File

@@ -1,26 +1,26 @@
<?php
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
require_once("config/participo.php");
require_once("./local/dbConf.php");
require_once("./local/cwsvJudo.php");
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
require_once 'config/participo.php';
require_once("./lib/participoLib/participo.php");
require_once("./lib/db.php");
require_once("./lib/api.php");
require_once './local/dbConf.php';
require_once './local/cwsvJudo.php';
require_once("./auth.php");
require_once './lib/participoLib/participo.php';
require_once './lib/db.php';
require_once './lib/api.php';
require_once $config['basePath'] . '/config/cwsvJudo.config.php';
require_once $config['basePath'] . '/config/phpcount.config.php';
require_once($config['basePath']."/config/cwsvJudo.config.php");
require_once($config['basePath']."/config/phpcount.config.php");
dbConnector::connect(
$cwsvJudoConfig["db"]["host"],
$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
$cwsvJudoConfig['db']['host'],
$cwsvJudoConfig['db']['name'],
$cwsvJudoConfig['db']['user'],
$cwsvJudoConfig['db']['password']
);
participo::authentificate();
$userData = getUserData(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
$usersKids = getUsersKids(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
@@ -33,7 +33,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php readfile("./shared/imports.php");?>
<?php readfile('./shared/imports.php'); ?>
<!-- inits for the materializeCss -->
<script>
document.addEventListener('DOMContentLoaded', function() {
@@ -63,7 +63,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
<img style="max-width:100%;height:12vh;" class="responsive-img" src="http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png" />
</a>
</li>
<li><?php require_once("sidenav/loginStatus.php");?></li>
<li><?php require_once 'sidenav/loginStatus.php'; ?></li>
<li class="bold">
<a class="waves-effect waves-teal" href="/participo">zurück</a>
</li>
@@ -77,20 +77,19 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
</header>
<?php
if($_SESSION['login']){
?>
if ($_SESSION['login']) {
?>
<main>
<h1>Benutzer-Einstellungen</h1>
<p>
<?php
if( array_key_exists('changePasswordSuccess', $_GET) ){
if($_GET['changePasswordSuccess'] == "true"){
echo("<div>Password geändert</div>");
}else{
echo("<div>Fehler während setzens des Passwortes.</div>");
if (array_key_exists('changePasswordSuccess', $_GET)) {
if ($_GET['changePasswordSuccess'] == 'true') {
echo('<div>Password geändert</div>');
} else {
echo('<div>Fehler während setzens des Passwortes.</div>');
}
}
?>
} ?>
</p>
<h2>Benutzer-Info</h2>
<p>Informationen zum eigenen Benutzerkonto</p>
@@ -99,7 +98,7 @@ if($_SESSION['login']){
<div style="padding:1%;" class="col s12 m6">
<div style="margin:1%;" class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title"><?php echo($userData['name']);?>, <?php echo($userData['vorname']); ?></span>
<span class="card-title"><?php echo($userData['name']); ?>, <?php echo($userData['vorname']); ?></span>
<img style="max-height:10vh;" class="responsive-img" src="images/account.svg" />
<dl>
<dt>Name</dt><dd><?php echo($userData['name']); ?></dd>
@@ -159,11 +158,11 @@ if($_SESSION['login']){
<p>Liste der User, für die man meldeberechtigt ist (bzw. Änderungen vornehmen darf). In der Regel ist das das eigene Kind (bei Eltern) oder man selber (bei Volljährigen).</p>
<div class="row" id="kidsList">
<?php
foreach($usersKids as $kid){ ?>
foreach ($usersKids as $kid) { ?>
<div style="padding:1%;" class="col s12 m6">
<div style="margin:1%;" class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title"><?php echo($kid['name']);?>, <?php echo($kid['vorname']); ?></span>
<span class="card-title"><?php echo($kid['name']); ?>, <?php echo($kid['vorname']); ?></span>
<img style="max-height:10vh;" class="responsive-img" src="images/account.svg" />
<dl>
<dt>Name</dt><dd><?php echo($kid['name']); ?></dd>
@@ -176,12 +175,10 @@ if($_SESSION['login']){
<p>Im folgenden Formular kann das Passwort des Kindes gesetzt werden. Das eigene Passwort muss dabei noch einmal zur Kontrolle eingegeben werden. Das neue Passwort muss zweimal blind eingegeben.</p>
<p>
<?php
if( ($kid['pwHash'] == "") || ($kid['pwHash']) == NULL ){
echo("<p>Derzeit ist kein Passwort gesetzt!</p>");
}
else{
echo("<p>Es ist derzeit ein Passwort gesetzt!</p>");
?>
if (($kid['pwHash'] == '') || ($kid['pwHash']) == null) {
echo('<p>Derzeit ist kein Passwort gesetzt!</p>');
} else {
echo('<p>Es ist derzeit ein Passwort gesetzt!</p>'); ?>
<p>Es besteht auch die Möglickeit, das Passwort ganz zu entfernen. Man kann sich dann nicht mehr mit diesem Konto einloggen. Das eigene Passwort muss dabei noch einmal zur Kontrolle eingegeben werden.</p>
<form action="./user" method="post">
<input name="action" type="hidden" value="changePassword" />
@@ -237,8 +234,7 @@ if($_SESSION['login']){
</div>
</div>
<?php
}
?>
} ?>
</main>
<?php
}