Merge branch 'master' into infoZettel

This commit is contained in:
marko
2022-10-24 19:09:25 +02:00
15 changed files with 654 additions and 473 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

@@ -5,4 +5,8 @@ $config['basePath'] = "/users/cwsvjudo/www";
$config['baseUrl'] = "http://cwsvjudo.bplaced.net";
$config['ressourceUrl'] = "http://cwsvjudo.bplaced.net/ressourcen";
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
set_include_path(get_include_path() . PATH_SEPARATOR . "./lib/");
set_include_path(get_include_path() . PATH_SEPARATOR . $config['basePath']."/ressourcen/");
?>

View File

@@ -6,7 +6,7 @@ require_once("participoLib/participo.php");
require_once("participoLib/planer.php");
require_once("config/participo.php");
require_once("./local/dbConf.php");
require_once("./local/cwsvJudo.php");
@@ -16,15 +16,15 @@ require_once("config/participo.php");
require_once($config['basePath']."/config/cwsvJudo.config.php");
dbConnector::connect(
$cwsvJudoConfig["db"]["host"],
$cwsvJudoConfig["db"]["name"],
$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']);
$meta = array(

View File

@@ -13,30 +13,45 @@ include_once("events.inc.php");
<!-- inits for the materializeCss -->
<script>
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems, {
// specify options here
function initSidenav() {
var sidenavElements = document.querySelectorAll('.sidenav');
var sidenavInstances = M.Sidenav.init(sidenavElements, {
});
});
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.modal');
var instances = M.Modal.init(elems, {
// specify options here
};
function initModals() {
var modalElements = document.querySelectorAll('.modal');
var modalInstances = M.Modal.init(modalElements, {
});
});
};
function openEventModal(eventId){
openModal(`#event-modal-${eventId}`);
}
function openModal(modalId){
var modalElement = document.querySelector(modalId);
if( modalElement === null ){
console.log(`No modalElement by name ${modalId} found. Won't open!`);
return;
}
var modalInstance = M.Modal.getInstance(modalElement);
console.log("before opening: ", modalInstance);
modalInstance.open();
console.log("after opening: ", modalInstance);
}
// Open the given modal
document.addEventListener('DOMContentLoaded', function () {
// So far we assume the first given fragment (the stuff behind the #) is the modalId
var eventId = window.location.hash.substr(1);
var Modalelem = document.querySelector('#event-modal-'+eventId);
var instance = M.Modal.init(Modalelem);
instance.open();
// What to do when the document is loaded.
document.addEventListener('DOMContentLoaded', function() {
// init materialize elements
initModals();
initSidenav();
// opening event modal if given
var eventId = parseInt( window.location.hash.substr(1) );
if( !isNaN(eventId) ){
openEventModal(eventId);
}
});
</script>
<title><?php echo($meta['title']);?></title>
<meta name="description" content="<?php echo($meta['description']);?>" />
@@ -47,37 +62,8 @@ include_once("events.inc.php");
<body>
<header>
<!-- cwsvJudoApps SideNav -->
<div>
<nav class="indigo darken-4">
<div class="nav-wrapper">
<div class="col s12">
<a href="http://cwsvjudo.bplaced.net/" class="breadcrumb">cwsvJudo-Apps</a>
<a href="http://cwsvjudo.bplaced.net/participo/events" class="breadcrumb"><?php echo($meta['title']);?></a>
</div>
</div>
<a class="right top-nav sidenav-trigger waves-effect waves-light hide-on-large-only" href="#" data-target="nav-mobile">
<i class="material-icons">menu</i>
</a>
</nav>
<ul class="sidenav sidenav-fixed sidenav-close" id="nav-mobile">
<li class="logo">
<a style="height:auto;" class="brand-logo" id="logo-container" href="/participo/">
<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 -->
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#eventList">Liste anstehender Events<i class="material-icons">format_list_bulleted</i></a>
</li>
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#detailedEventList">Details anstehender Events<i class="material-icons">view_list</i></a>
</li>
</ul>
</div>
<!-- The sidenav -->
<?php require("./events.sidenav.inc.php");?>
</header>
<?php if($_SESSION['login']){ ?>

View File

@@ -0,0 +1,31 @@
<!-- cwsvJudoApps SideNav -->
<div>
<nav class="indigo darken-4">
<div class="nav-wrapper">
<div class="col s12">
<a href="http://cwsvjudo.bplaced.net/" class="breadcrumb">cwsvJudo-Apps</a>
<a href="http://cwsvjudo.bplaced.net/participo/events" class="breadcrumb"><?php echo($meta['title']);?></a>
</div>
</div>
<a class="right top-nav sidenav-trigger waves-effect waves-light hide-on-large-only" href="#" data-target="nav-mobile">
<i class="material-icons">menu</i>
</a>
</nav>
<ul class="sidenav sidenav-fixed sidenav-close" id="nav-mobile">
<li class="logo">
<a style="height:auto;" class="brand-logo" id="logo-container" href="/participo/">
<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 -->
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#eventList">Liste anstehender Events<i class="material-icons">format_list_bulleted</i></a>
</li>
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#detailedEventList">Details anstehender Events<i class="material-icons">view_list</i></a>
</li>
</ul>
</div><!-- cwsvJudoApps SideNav -->

View File

@@ -1,29 +1,22 @@
<?php
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
require_once("config/participo.php");
require_once 'config/participo.php';
require_once("./local/dbConf.php");
require_once("./local/cwsvJudo.php");
require_once './local/cwsvJudo.php';
require_once("./lib/db.php");
require_once("./lib/api.php");
require_once("./lib/participoLib/participo.php");
require_once("./lib/participoLib/planer.php");
require_once("./auth.php");
require_once($config['basePath']."/config/cwsvJudo.config.php");
require_once($config['basePath']."/config/phpcount.config.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());
participo::authentificate();
$userData = getUserData(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
eventPlaner::setDbConnection( dbConnector::getDbConnection() );
?>
<!DOCTYPE html>
@@ -32,15 +25,26 @@ 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() {
var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems, {
// specify options here
function initSidenav() {
var sidenavElements = document.querySelectorAll('.sidenav');
var sidenavInstances = M.Sidenav.init(sidenavElements, {
});
};
function initModals() {
var modalElements = document.querySelectorAll('.modal');
var modalInstances = M.Modal.init(modalElements, {
});
};
// What to do when the document is loaded.
document.addEventListener('DOMContentLoaded', function() {
// init materialize elements
initModals();
initSidenav();
});
</script>
@@ -67,7 +71,7 @@ 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="#mitmachApps">Mitmachen<i class="material-icons">accessibility</i></a>
</li>
@@ -80,7 +84,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#configApps">Einstellen<i class="material-icons">settings</i></a>
</li>
<?php if( isUserAdmin(dbConnector::getDbConnection(), $userData['id']) ){?>
<?php if (participo::isUserAdmin($userData['id'])) {?>
<li class="bold">
<a class="waves-effect waves-teal right-align" href="#admiStuff">adminStuff</a>
</li>
@@ -89,30 +93,30 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
</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' => 'events',
'title' => 'Event-Planer',
'description' => 'Organisieren der Teilnahmen (und nicht-Teilnahmen) an Wettkämpfen, Sondertrainingseinheiten, Feiern etc.' . eventPlaner::getHtmlEventTable(eventPlaner::getCommingWkEvents()),
'imgUrl' => '/ressourcen/graphiken/icons/terminKalender.svg',
'actions' => [
AppCardAction::fromArray(['caption' => 'Planer', 'link' => 'events']),
],
])->htmlCode()
)
@@ -124,26 +128,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>
@@ -151,26 +154,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 -->
@@ -179,31 +181,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( isUserAdmin(dbConnector::getDbConnection(), $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,33 +1,30 @@
<?php
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
set_include_path(get_include_path() . PATH_SEPARATOR . "./lib/");
require_once("participoLib/participo.php");
require_once 'config/participo.php';
require_once("config/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>
@@ -35,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">
@@ -68,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
}
@@ -86,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,9 +1,8 @@
<?php
require_once("./config/participo.php");
//require_once("./auth.php");
require($config['basePath']."/ressourcen/parsedown/Parsedown.php");
require($config['basePath']."/ressourcen/spyc/Spyc.php");
require_once($config['basePath'] . "/ressourcen/parsedown/Parsedown.php");
require_once($config['basePath'] . "/ressourcen/spyc/Spyc.php");
$mdRoot = "markdown/".(array_key_exists('kyu', $_GET)?$_GET['kyu']:"8")."terKyu";

View File

@@ -1,4 +1,5 @@
<?php
// require_once("spyc/Spyc.php");
class participo{
private static $db = null;
@@ -62,14 +63,17 @@ class participo{
return false;
}
// query all users with the entered name
// query *all* users with the entered name
// @todo check for e.g., len(user)=1
// @todo getUser?
$user = dbConnector::query(
"SELECT `id`, `loginName`, `pwHash`, `config` FROM `wkParticipo_Users` WHERE `loginName` = :loginName",
['loginName' => ['value'=>$loginName, 'data_type'=>PDO::PARAM_STR]]
);
$user = $user[0];
// If there is no such user OR the password isn't valid the login fails
if( empty($user || !password_verify( $password, $user['pwHash']) )){
if( empty($user) || !password_verify( $password, $user['pwHash'])){
sleep(5); // discourage brute force attacks
self::addMessage('error', "<div>Falsches Passwort oder LoginName</div>");
return false;
@@ -80,9 +84,9 @@ class participo{
$_SESSION = array(
'login' => true,
'user' => array(
'username' => $row['loginName'],
'userId' => $row['id'],
'userConfig' => json_decode($row['config'], true)
'username' => $user['loginName'],
'userId' => $user['id'],
'userConfig' => json_decode($user['config'], true)
)
);
@@ -92,6 +96,44 @@ class participo{
self::addMessage('success', "<div>Anmeldung erfolgreich</div>");
return true;
}
/**
* Checks, if a user is an admin
*
* @param [type] $userId id of the user to check
* @retval true user with id $userId has attribute "isAdmin"
* @retval false otherwise
*/
static function isUserAdmin($userId){
return self::hasUserAttribute( $userId, "isAdmin");
}
/**
* Checks, if a user as a certain attribute
*
* @param [type] $userId id of the user to check
* @param [type] $attributeName string name of the attribute to check
* @return boolean
*/
static public function hasUserAttribute($userId, $attributeName){
// sqlQuery: Select the user if it has the given attribute
$query = <<<SQL
SELECT `wkParticipo_user<=>userAttributes`.userId, `wkParticipo_userAttributes`.name
FROM `wkParticipo_user<=>userAttributes` LEFT JOIN `wkParticipo_userAttributes`
ON `wkParticipo_user<=>userAttributes`.`attributeId` = `wkParticipo_userAttributes`.`id`
WHERE `wkParticipo_userAttributes`.name = :attributeName AND userId=:userId;
SQL;
$params = array(
':userId' => array('value'=>$userId, 'data_type'=>PDO::PARAM_INT),
':attributeName' => array('value'=>$attributeName, 'data_type'=>PDO::PARAM_STR)
);
$attributedUsers = dbConnector::query($query, $params);
// Since the id should be unique, there should only be one result this is just for dealing with empty arrays
foreach($attributedUsers as $u)
if($u['userId']==$userId)
return true;
return false;
}
}
/**
@@ -172,11 +214,11 @@ class AppCard{
return
"<div style=\"padding:1%;\" class=\"col s12 m6 ".$extraClass."\">".
"<div style=\"margin:1%;\" class=\"card blue-grey darken-1\">".
(($this->link!=null)?("<a href=\"".$this->link."\">"):(""))."<div class=\"card-content white-text\">".
"<span class=\"card-title\">".$this->title."</span>".
"<div class=\"card-content white-text\">".
(($this->link!=null)?("<a href=\"".$this->link."\">"):(""))."<span class=\"card-title\">".$this->title."</span>".(($this->link!=null)?("</a>"):("")).
(($this->imgUrl!=null)?("<img alt=\"".$this->title."\" style=\"display:block;margin-left:auto;margin-right:auto;max-height:10vh;\" class=\"responsive-img\" src=\"".$this->imgUrl."\" />"):("")).
"<p>".$this->description."</p>".
"</div>".(($this->link!=null)?("</a>"):("")).
"</div>".
"<div class=\"card-action\">".$actionListCode."</div>".
"</div>".
"</div>";
@@ -310,6 +352,9 @@ function loadMarkdownFile($fileName){
function logLoginsToJsonFile($userName, $fileName="lastLogins.json"){
try{
$lastLogins = json_decode(file_get_contents($fileName), true);
if ($lastLogins == NULL){
return;
}
if(!array_key_exists($userName, $lastLogins))
$lastLogins[$userName] = [];
if(!array_key_exists('lastLogins', $lastLogins[$userName]))
@@ -340,7 +385,7 @@ class dbConnector{
/// ':userId' => array('value'=>$anUserId, 'data_type'=>PDO::PARAM_INT),
/// ':attributeId'=> array('value'=>$anAttributeId, 'data_type'=>PDO::PARAM_INT) )
/// @param $someOption
function query($aQueryString, $aBindArray = array(), $someOptions = array()){
public static function query($aQueryString, $aBindArray = array(), $someOptions = array()){
// Standardbelegungen
if( empty($someOptions['dbCharset' ]) ) $someOptions['dbCharset' ] = "ISO-8859-1";
if( empty($someOptions['outCharset']) ) $someOptions['outCharset'] = "UTF-8";
@@ -429,4 +474,70 @@ class dbConnector{
}
/**
* User for the Participo system
*/
class user{
private $id;
private $loginName;
private $name;
private $firstName;
private $dateOfBirth;
private $eMail;
public function __construct($id, $loginName, $name, $firstName, $dateOfBirth, $eMail)
{
$this->id = (int) id;
$this->loginName = $loginName;
$this->name = $name;
$this->firstName = $firstName;
$this->dateOfBirth = $dateOfBirth!=null?DateTime::createFromFormat('Y-m-d', $dateOfBirth):null;
$this->eMail = $eMail;
}
/**
* Create a User from an assoziative array
*
* @param array $member associative array with the UserData from the dbRequest
* @return User initialized user
*/
public static function fromArray($member){
return new User(
$member['id']??null,
$member['loginName']??null,
$member['name']??null,
$member['vorname']??null,
$member['gebDatum']??null,
array_key_exist('eMail', $member)?explode(',', $member['eMail']):null
);
}
/// Setzen aller Attribute
/// @todo Inputvalidation
function set($userData){
$this->id = $userData["id"];
$this->loginName = $userData["loginName"];
$this->name = $userData["name"];
$this->vorname = $userData["vorname"];
$this->gebDatum = $userData["gebDatum"];
$this->eMail = $userData["eMail"];
return;
}
function toAssoc(){
return array(
"id" => $this->id,
"loginName"=> $this->loginName,
"name" => $this->name,
"vorname" => $this->vorname,
"gebDatum" => $this->gebDatum,
"eMail" => $this->eMail);
}
function loadFromDb($dbConn, $id){
$this->set(
loadUserDataFromDb($dbConn, $id)
);
}
}
?>

View File

@@ -1,7 +1,10 @@
<?php
class shiai{
/**
* frame for a 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 +15,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,32 +29,69 @@ class shiai{
$this->promoImgUrl = $promoImgUrl;
}
public function getName(){
return $this->name;
}
public function getAgeClasses(){
return $this->ageclasses ? $this->ageclasses : "-";
}
public function getId(){
public function getId()
{
return $this->id;
}
static public function fromArray($member){
public function getName()
{
return ($this->name != null ? $this->name : 'Wettkampf ohne Namen');
}
public function getHtmlDate()
{
return ($this->date != null ? $this->date->format('Y-m-d') : 'fehlendes Datum');
}
public function getAgeClasses()
{
return ($this->ageclasses != null ? $this->ageclasses : '-');
}
public function getPlace()
{
return ($this->place != null ? $this->place : '-');
}
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,
$member['promoPic'] ?? null
);
}
/**
* shiai event as html code for displaying
*
* @return html formated string
*/
public function getHtml()
{
$retHtml = '';
$retHtml =
'<div>' .
'<h3>' . $this->getName() . '</h3>' .
'<dl>' .
'<dt>Datum:</dt><dd>' . $this->getHtmlDate() . '</dd>' .
'<dt>Altersklassen</dt><dd>' . $this->getAgeClasses() . '</dd>' .
'<dt>Ort</dt><dd>' . $this->getPlace() . '</dd>' .
'</dl>' .
'</div>';
return $retHtml;
}
} // 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 +100,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 black-text">' .
'<div class="modal-content">' .
$this->shiai->getHtml() .
'</div>' . // end modal content
'<div class="modal-footer">' .
'<a href="/pages/desktop/wkParticipo/showWkEvent.php?eventId=' . $this->id . '" class="modal-close waves-effect waves-green btn-flat">Zum Event im Planer</a>' .
'<a href="#!" class="modal-close waves-effect waves-green btn-flat">Schließen</a>' .
'</div>' .
'</div>';
}
public static function fromArray($member)
{
$shiai = json_decode($member['bemerkungen'], true);
return new event(
@@ -115,72 +163,74 @@ 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>';
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,9 +1,7 @@
<?php
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
set_include_path(get_include_path() . PATH_SEPARATOR . "./lib/");
require_once("config/participo.php");
require_once("participoLib/participo.php");
require_once("config/participo.php");
require_once("./local/dbConf.php");

View File

@@ -1,4 +1,5 @@
<!-- MaterializeCss -->
<!-- - Compiled and minified CSS -->
<link rel="stylesheet" href="/ressourcen/materializeCss/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->

View File

@@ -13,3 +13,6 @@
<li>
<a href="kyu.php?kyu=4">4. Kyu - orange-grün</a>
</li>
<li>
<a href="kyu.php?kyu=A">Nage-no-kata</a>
</li>

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 des 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>
@@ -173,15 +172,13 @@ if($_SESSION['login']){
</div>
<span class="card-title">Passwort</span>
<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>Im folgenden Formular kann das Passwort des Kindes gesetzt werden. Damit kann das Kind sich auch in das System einloggen - um z.B. die Wissens-Apps zu benutzen - kann sich aber nicht bei Wettkämpfen anmelden. 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
}