just one user
This commit is contained in:
@@ -48,66 +48,66 @@ setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
/**
|
||||
* Datastructure and interface for an user
|
||||
*/
|
||||
class User
|
||||
{
|
||||
private $id = null;
|
||||
private $familyName = null;
|
||||
private $givenName = null;
|
||||
// class User
|
||||
// {
|
||||
// private $id = null;
|
||||
// private $familyName = null;
|
||||
// private $givenName = null;
|
||||
|
||||
private $attributes = null;
|
||||
// private $attributes = null;
|
||||
|
||||
public function __construct($id, $familyName, $givenName)
|
||||
{
|
||||
$this->id = (int)$id;
|
||||
$this->familyName = $familyName;
|
||||
$this->givenName = $givenName;
|
||||
}
|
||||
// public function __construct($id, $familyName, $givenName)
|
||||
// {
|
||||
// $this->id = (int)$id;
|
||||
// $this->familyName = $familyName;
|
||||
// $this->givenName = $givenName;
|
||||
// }
|
||||
|
||||
public static function fromArray($member)
|
||||
{
|
||||
$id = $member['id'];
|
||||
$familyName = $member['familyName'];
|
||||
$givenName = $member['givenName'];
|
||||
return new User($id, $familyName, $givenName);
|
||||
}
|
||||
// public static function fromArray($member)
|
||||
// {
|
||||
// $id = $member['id'];
|
||||
// $familyName = $member['familyName'];
|
||||
// $givenName = $member['givenName'];
|
||||
// return new User($id, $familyName, $givenName);
|
||||
// }
|
||||
|
||||
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 .= ';';
|
||||
$response = dbQuery($db, $query, $params);
|
||||
// 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 .= ';';
|
||||
// $response = dbQuery($db, $query, $params);
|
||||
|
||||
$users = [];
|
||||
foreach ($response as $r) {
|
||||
$users[] = User::fromArray($r);
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
// $users = [];
|
||||
// foreach ($response as $r) {
|
||||
// $users[] = User::fromDbArray($r);
|
||||
// }
|
||||
// return $users;
|
||||
// }
|
||||
|
||||
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>');
|
||||
}
|
||||
}
|
||||
// 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>');
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Datastructure and interface for attendances
|
||||
@@ -264,9 +264,11 @@ setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<nav class="indigo darken-4">cwsvJudo Apps<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>
|
||||
<nav class="indigo darken-4">
|
||||
<a href="http://cwsvjudo.bplaced.net/participo" class="breadcrumb">cwsvJudo-Apps</a>
|
||||
<a href="http://cwsvjudo.bplaced.net/participo/attendance" class="breadcrumb">Anwesenheit</a>
|
||||
<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/">
|
||||
|
||||
@@ -6,7 +6,12 @@ $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/");
|
||||
|
||||
set_include_path( implode(
|
||||
PATH_SEPARATOR,
|
||||
[ get_include_path()
|
||||
, $config['basePath']
|
||||
, $config['basePath']."/ressourcen/"
|
||||
, $config['basePath']."/ressourcen/phpLib"
|
||||
, "./lib/"]
|
||||
));
|
||||
?>
|
||||
|
||||
@@ -68,11 +68,11 @@ include_once("events.inc.php");
|
||||
|
||||
<?php if($_SESSION['login']){ ?>
|
||||
<main>
|
||||
<h1 id="eventList">Übersicht anstehender Events</h1>
|
||||
<h2 id="eventList">Übersicht anstehender Events</h2>
|
||||
<!-- Table with events-->
|
||||
<?php echo( eventPlaner::getHtmlEventTable(eventPlaner::getCommingWkEvents()) );?>
|
||||
|
||||
<h1 id="detailedEventList">Detailansicht kommender Wettkämpfe</h1>
|
||||
<h2 id="detailedEventList">Detailansicht kommender Wettkämpfe</h2>
|
||||
<?php foreach( eventPlaner::getCommingWkEvents() as $event ) echo($event->asHtmlCard());?>
|
||||
</main>
|
||||
<?php } ?>
|
||||
|
||||
@@ -1,31 +1,41 @@
|
||||
<!-- 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>
|
||||
<!-- cwsvJudoApps SideNav -->
|
||||
<div>
|
||||
<nav class="indigo darken-4">
|
||||
<div class="nav-wrapper">
|
||||
<div class="col s12">
|
||||
<a href="http://cwsvjudo.bplaced.net/participo" class="breadcrumb">cwsvJudo-Apps</a>
|
||||
<a href="http://cwsvjudo.bplaced.net/participo/events" class="breadcrumb">
|
||||
<?php echo($meta['title']);?>
|
||||
</a>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
</div><!-- cwsvJudoApps SideNav -->
|
||||
<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>
|
||||
<!-- brings its own li -->
|
||||
<?php require_once("sidenav/loginStatus.php");?>
|
||||
<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">Eventdetails<i
|
||||
class="material-icons">view_list</i></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!-- cwsvJudoApps SideNav -->
|
||||
@@ -7,6 +7,10 @@ require_once 'config/participo.php';
|
||||
require_once './lib/api.php'; // should be replaced
|
||||
require_once 'participoLib/participo.php';
|
||||
require_once 'participoLib/planer.php';
|
||||
require_once("config/phpcount.config.php");
|
||||
require_once("phpcount/phpcount.php");
|
||||
|
||||
PHPCount::AddHit("participo");
|
||||
|
||||
dbConnector::connect(
|
||||
$cwsvJudoConfig['db']['host'],
|
||||
@@ -17,7 +21,6 @@ require_once 'config/participo.php';
|
||||
eventPlaner::setDbConnection(dbConnector::getDbConnection());
|
||||
participo::authentificate();
|
||||
$userData = getUserData(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -203,6 +206,20 @@ if (participo::isUserAdmin($userData['id'])) {
|
||||
])->htmlCode() .
|
||||
'</div>'
|
||||
);
|
||||
|
||||
echo("<h2 id=\"commingStarts\">Aktuelle Einschreibungen</h2>");
|
||||
$eventList = participo::getEventStarter("2022-01-01");
|
||||
$htmlTable = null;
|
||||
if($eventList){
|
||||
$htmlTable = "<table>"
|
||||
."<thead><tr><th>Datum</th><th>Veranstaltung</th><th>Starter</th></tr></thead>"
|
||||
."<tbody>";
|
||||
foreach($eventList as $event){
|
||||
$htmlTable .= "<tr><td>".$event['eventDate']."</td><td>".$event['eventName']."</td><td>".$event['userName'].", ".$event['userFirstname']."</td></tr>";
|
||||
}
|
||||
$htmlTable .= "</tbody></table>";
|
||||
}
|
||||
echo($eventList?$htmlTable:"<div>Keine Meldungen zu bevorstehenden Events");
|
||||
} ?>
|
||||
</main>
|
||||
<?php
|
||||
|
||||
@@ -32,7 +32,8 @@ class participo{
|
||||
|
||||
/**
|
||||
* Checks, if there already is a valid login, if not redirect to the login form
|
||||
*
|
||||
* @todo rename to authenticate
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
static public function authentificate(){
|
||||
@@ -50,13 +51,13 @@ class participo{
|
||||
* check password for user
|
||||
*
|
||||
* @param string $loginName user who wants to get in
|
||||
* @param string $password passwor for the user
|
||||
* @param string $password password for the user
|
||||
*
|
||||
* @retval true $password belongs to $loginName
|
||||
* @retval false otherwise
|
||||
*/
|
||||
static public function checkCredentials($loginName, $password){
|
||||
sleep(1); // just to discurrage brute force attacks
|
||||
sleep(1); // just to discourage brute force attacks
|
||||
// Check for dbConnection
|
||||
if(!dbConnector::getDbConnection()){
|
||||
self::addMessage('error', "<div>No DbConnection available</div>");
|
||||
@@ -134,6 +135,32 @@ SQL;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static public function getEventStarter($sinceDate=null){
|
||||
if(!$sinceDate)
|
||||
$sinceDate = "CURDATE()";
|
||||
else
|
||||
$sinceDate = "DATE(\"".$sinceDate."\")";
|
||||
$query = <<<SQL
|
||||
SELECT
|
||||
`wkParticipo_Events`.`date` as eventDate
|
||||
, `wkParticipo_Starter`.`id` as starterId
|
||||
, `wkParticipo_Users`.`name` as userName
|
||||
, `wkParticipo_Users`.`vorname` as userFirstname
|
||||
, `wkParticipo_Events`.`date` as eventDate
|
||||
, `wettkampfkalender`.`veranstaltung` as eventName
|
||||
FROM `wkParticipo_Starter`
|
||||
LEFT JOIN `wkParticipo_Users` ON `wkParticipo_Starter`.`userId` = `wkParticipo_Users`.`id`
|
||||
LEFT JOIN `wkParticipo_Events` ON `wkParticipo_Starter`.`eventId` = `wkParticipo_Events`.`id`
|
||||
LEFT JOIN `wettkampfkalender` ON `wkParticipo_Events`.`wkId` = `wettkampfkalender`.`lfdeNr`
|
||||
WHERE `wkParticipo_Events`.`date` >= $sinceDate
|
||||
ORDER BY `wkParticipo_Events`.`date` DESC;
|
||||
SQL;
|
||||
$commingStarts = dbConnector::query($query);
|
||||
|
||||
return $commingStarts;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,7 +394,9 @@ function logLoginsToJsonFile($userName, $fileName="lastLogins.json"){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* interface for connecting and communicating with a database
|
||||
*/
|
||||
class dbConnector{
|
||||
static private $db = null;
|
||||
|
||||
@@ -478,7 +507,7 @@ class dbConnector{
|
||||
/**
|
||||
* User for the Participo system
|
||||
*/
|
||||
class user{
|
||||
class User{
|
||||
private $id;
|
||||
private $loginName;
|
||||
private $name;
|
||||
@@ -497,12 +526,12 @@ class user{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a User from an assoziative array
|
||||
* Create a User from an assoziative array like it is returned from db requests
|
||||
*
|
||||
* @param array $member associative array with the UserData from the dbRequest
|
||||
* @return User initialized user
|
||||
*/
|
||||
public static function fromArray($member){
|
||||
public static function fromDbArray($member){
|
||||
return new User(
|
||||
$member['id']??null,
|
||||
$member['loginName']??null,
|
||||
@@ -513,26 +542,19 @@ class user{
|
||||
);
|
||||
}
|
||||
|
||||
/// 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;
|
||||
}
|
||||
/**
|
||||
* Export the User data into an associative array
|
||||
*/
|
||||
function toAssoc(){
|
||||
return array(
|
||||
"id" => $this->id,
|
||||
"loginName"=> $this->loginName,
|
||||
"name" => $this->name,
|
||||
"vorname" => $this->vorname,
|
||||
"gebDatum" => $this->gebDatum,
|
||||
"vorname" => $this->firstName,
|
||||
"gebDatum" => $this->dateOfBirth,
|
||||
"eMail" => $this->eMail);
|
||||
}
|
||||
|
||||
function loadFromDb($dbConn, $id){
|
||||
$this->set(
|
||||
loadUserDataFromDb($dbConn, $id)
|
||||
|
||||
Reference in New Issue
Block a user