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
|
* Datastructure and interface for an user
|
||||||
*/
|
*/
|
||||||
class User
|
// class User
|
||||||
{
|
// {
|
||||||
private $id = null;
|
// private $id = null;
|
||||||
private $familyName = null;
|
// private $familyName = null;
|
||||||
private $givenName = null;
|
// private $givenName = null;
|
||||||
|
|
||||||
private $attributes = null;
|
// private $attributes = null;
|
||||||
|
|
||||||
public function __construct($id, $familyName, $givenName)
|
// public function __construct($id, $familyName, $givenName)
|
||||||
{
|
// {
|
||||||
$this->id = (int)$id;
|
// $this->id = (int)$id;
|
||||||
$this->familyName = $familyName;
|
// $this->familyName = $familyName;
|
||||||
$this->givenName = $givenName;
|
// $this->givenName = $givenName;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static function fromArray($member)
|
// public static function fromArray($member)
|
||||||
{
|
// {
|
||||||
$id = $member['id'];
|
// $id = $member['id'];
|
||||||
$familyName = $member['familyName'];
|
// $familyName = $member['familyName'];
|
||||||
$givenName = $member['givenName'];
|
// $givenName = $member['givenName'];
|
||||||
return new User($id, $familyName, $givenName);
|
// return new User($id, $familyName, $givenName);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static function getUsers($db, $options = [])
|
// public static function getUsers($db, $options = [])
|
||||||
{
|
// {
|
||||||
$attributeId = $options['attributeId'] ?? null;
|
// $attributeId = $options['attributeId'] ?? null;
|
||||||
$params = [];
|
// $params = [];
|
||||||
$query = 'SELECT ' .
|
// $query = 'SELECT ' .
|
||||||
'`cwsvjudo`.`wkParticipo_Users`.`id` AS `id`' .
|
// '`cwsvjudo`.`wkParticipo_Users`.`id` AS `id`' .
|
||||||
', `cwsvjudo`.`wkParticipo_Users`.`vorname` AS `givenName`' .
|
// ', `cwsvjudo`.`wkParticipo_Users`.`vorname` AS `givenName`' .
|
||||||
', `cwsvjudo`.`wkParticipo_Users`.`name` AS `familyName`' .
|
// ', `cwsvjudo`.`wkParticipo_Users`.`name` AS `familyName`' .
|
||||||
', `cwsvjudo`.`wkParticipo_userAttributes`.`name` AS `attributeName`' .
|
// ', `cwsvjudo`.`wkParticipo_userAttributes`.`name` AS `attributeName`' .
|
||||||
'FROM `cwsvjudo`.`wkParticipo_Users` ' .
|
// 'FROM `cwsvjudo`.`wkParticipo_Users` ' .
|
||||||
'JOIN `cwsvjudo`.`wkParticipo_user<=>userAttributes` ' .
|
// 'JOIN `cwsvjudo`.`wkParticipo_user<=>userAttributes` ' .
|
||||||
'ON `cwsvjudo`.`wkParticipo_Users`.`id` = `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`userId`' .
|
// 'ON `cwsvjudo`.`wkParticipo_Users`.`id` = `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`userId`' .
|
||||||
'JOIN `cwsvjudo`.`wkParticipo_userAttributes` ' .
|
// 'JOIN `cwsvjudo`.`wkParticipo_userAttributes` ' .
|
||||||
'ON `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`attributeId` = `cwsvjudo`.`wkParticipo_userAttributes`.`id`';
|
// 'ON `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`attributeId` = `cwsvjudo`.`wkParticipo_userAttributes`.`id`';
|
||||||
if ($attributeId != null) {
|
// if ($attributeId != null) {
|
||||||
$query .= ' WHERE `cwsvjudo`.`wkParticipo_userAttributes`.`id` = :attributeId';
|
// $query .= ' WHERE `cwsvjudo`.`wkParticipo_userAttributes`.`id` = :attributeId';
|
||||||
$params['attributeId'] = ['value' => $attributeId, 'data_type' => PDO::PARAM_INT];
|
// $params['attributeId'] = ['value' => $attributeId, 'data_type' => PDO::PARAM_INT];
|
||||||
}
|
// }
|
||||||
$query .= ';';
|
// $query .= ';';
|
||||||
$response = dbQuery($db, $query, $params);
|
// $response = dbQuery($db, $query, $params);
|
||||||
|
|
||||||
$users = [];
|
// $users = [];
|
||||||
foreach ($response as $r) {
|
// foreach ($response as $r) {
|
||||||
$users[] = User::fromArray($r);
|
// $users[] = User::fromDbArray($r);
|
||||||
}
|
// }
|
||||||
return $users;
|
// return $users;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static function htmlTable($users)
|
// public static function htmlTable($users)
|
||||||
{
|
// {
|
||||||
echo('<table><tr><th>Id<th>Name</th><th>Vorname</th></tr>');
|
// echo('<table><tr><th>Id<th>Name</th><th>Vorname</th></tr>');
|
||||||
foreach ($users as $u) {
|
// foreach ($users as $u) {
|
||||||
echo('<tr><td>' . $u->id . '</td><td>' . $u->familyName . '</td><td>' . $u->givenName . '</td></tr>');
|
// echo('<tr><td>' . $u->id . '</td><td>' . $u->familyName . '</td><td>' . $u->givenName . '</td></tr>');
|
||||||
}
|
// }
|
||||||
echo('</table>');
|
// echo('</table>');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Datastructure and interface for attendances
|
* Datastructure and interface for attendances
|
||||||
@@ -264,9 +264,11 @@ setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<header>
|
<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">
|
<nav class="indigo darken-4">
|
||||||
<i class="material-icons">menu</i>
|
<a href="http://cwsvjudo.bplaced.net/participo" class="breadcrumb">cwsvJudo-Apps</a>
|
||||||
</a></nav>
|
<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">
|
<ul class="sidenav sidenav-fixed sidenav-close" id="nav-mobile">
|
||||||
<li class="logo">
|
<li class="logo">
|
||||||
<a style="height:auto;" class="brand-logo" id="logo-container" href="/participo/">
|
<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";
|
$config['ressourceUrl'] = "http://cwsvjudo.bplaced.net/ressourcen";
|
||||||
|
|
||||||
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . "./lib/");
|
set_include_path( implode(
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . $config['basePath']."/ressourcen/");
|
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']){ ?>
|
<?php if($_SESSION['login']){ ?>
|
||||||
<main>
|
<main>
|
||||||
<h1 id="eventList">Übersicht anstehender Events</h1>
|
<h2 id="eventList">Übersicht anstehender Events</h2>
|
||||||
<!-- Table with events-->
|
<!-- Table with events-->
|
||||||
<?php echo( eventPlaner::getHtmlEventTable(eventPlaner::getCommingWkEvents()) );?>
|
<?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());?>
|
<?php foreach( eventPlaner::getCommingWkEvents() as $event ) echo($event->asHtmlCard());?>
|
||||||
</main>
|
</main>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|||||||
@@ -1,31 +1,41 @@
|
|||||||
<!-- cwsvJudoApps SideNav -->
|
<!-- cwsvJudoApps SideNav -->
|
||||||
<div>
|
<div>
|
||||||
<nav class="indigo darken-4">
|
<nav class="indigo darken-4">
|
||||||
<div class="nav-wrapper">
|
<div class="nav-wrapper">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<a href="http://cwsvjudo.bplaced.net/" class="breadcrumb">cwsvJudo-Apps</a>
|
<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 href="http://cwsvjudo.bplaced.net/participo/events" class="breadcrumb">
|
||||||
</div>
|
<?php echo($meta['title']);?>
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<a class="right top-nav sidenav-trigger waves-effect waves-light hide-on-large-only" href="#" data-target="nav-mobile">
|
<a class="right top-nav sidenav-trigger waves-effect waves-light hide-on-large-only" href="#"
|
||||||
<i class="material-icons">menu</i>
|
data-target="nav-mobile">
|
||||||
</a>
|
<i class="material-icons">menu</i>
|
||||||
</nav>
|
</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<ul class="sidenav sidenav-fixed sidenav-close" id="nav-mobile">
|
<ul class="sidenav sidenav-fixed sidenav-close" id="nav-mobile">
|
||||||
<li class="logo">
|
<li class="logo">
|
||||||
<a style="height:auto;" class="brand-logo" id="logo-container" href="/participo/">
|
<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" />
|
<img alt="cwsvJudoApps" style="max-width:100%;height:12vh;" class="responsive-img"
|
||||||
</a>
|
src="http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png" />
|
||||||
</li>
|
</a>
|
||||||
<?php require_once("sidenav/loginStatus.php");?><!-- brings its own li -->
|
</li>
|
||||||
<li class="bold">
|
<!-- brings its own li -->
|
||||||
<a class="waves-effect waves-teal right-align" href="#eventList">Liste anstehender Events<i class="material-icons">format_list_bulleted</i></a>
|
<?php require_once("sidenav/loginStatus.php");?>
|
||||||
</li>
|
<li class="bold">
|
||||||
<li class="bold">
|
<a class="waves-effect waves-teal right-align" href="#eventList">Liste anstehender Events<i
|
||||||
<a class="waves-effect waves-teal right-align" href="#detailedEventList">Details anstehender Events<i class="material-icons">view_list</i></a>
|
class="material-icons">format_list_bulleted</i></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
<li class="bold">
|
||||||
|
<a class="waves-effect waves-teal right-align" href="#detailedEventList">Eventdetails<i
|
||||||
</div><!-- cwsvJudoApps SideNav -->
|
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 './lib/api.php'; // should be replaced
|
||||||
require_once 'participoLib/participo.php';
|
require_once 'participoLib/participo.php';
|
||||||
require_once 'participoLib/planer.php';
|
require_once 'participoLib/planer.php';
|
||||||
|
require_once("config/phpcount.config.php");
|
||||||
|
require_once("phpcount/phpcount.php");
|
||||||
|
|
||||||
|
PHPCount::AddHit("participo");
|
||||||
|
|
||||||
dbConnector::connect(
|
dbConnector::connect(
|
||||||
$cwsvJudoConfig['db']['host'],
|
$cwsvJudoConfig['db']['host'],
|
||||||
@@ -17,7 +21,6 @@ require_once 'config/participo.php';
|
|||||||
eventPlaner::setDbConnection(dbConnector::getDbConnection());
|
eventPlaner::setDbConnection(dbConnector::getDbConnection());
|
||||||
participo::authentificate();
|
participo::authentificate();
|
||||||
$userData = getUserData(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
|
$userData = getUserData(dbConnector::getDbConnection(), $_SESSION['user']['userId']);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -203,6 +206,20 @@ if (participo::isUserAdmin($userData['id'])) {
|
|||||||
])->htmlCode() .
|
])->htmlCode() .
|
||||||
'</div>'
|
'</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>
|
</main>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class participo{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks, if there already is a valid login, if not redirect to the login form
|
* Checks, if there already is a valid login, if not redirect to the login form
|
||||||
|
* @todo rename to authenticate
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
*/
|
*/
|
||||||
@@ -50,13 +51,13 @@ class participo{
|
|||||||
* check password for user
|
* check password for user
|
||||||
*
|
*
|
||||||
* @param string $loginName user who wants to get in
|
* @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 true $password belongs to $loginName
|
||||||
* @retval false otherwise
|
* @retval false otherwise
|
||||||
*/
|
*/
|
||||||
static public function checkCredentials($loginName, $password){
|
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
|
// Check for dbConnection
|
||||||
if(!dbConnector::getDbConnection()){
|
if(!dbConnector::getDbConnection()){
|
||||||
self::addMessage('error', "<div>No DbConnection available</div>");
|
self::addMessage('error', "<div>No DbConnection available</div>");
|
||||||
@@ -134,6 +135,32 @@ SQL;
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
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{
|
class dbConnector{
|
||||||
static private $db = null;
|
static private $db = null;
|
||||||
|
|
||||||
@@ -478,7 +507,7 @@ class dbConnector{
|
|||||||
/**
|
/**
|
||||||
* User for the Participo system
|
* User for the Participo system
|
||||||
*/
|
*/
|
||||||
class user{
|
class User{
|
||||||
private $id;
|
private $id;
|
||||||
private $loginName;
|
private $loginName;
|
||||||
private $name;
|
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
|
* @param array $member associative array with the UserData from the dbRequest
|
||||||
* @return User initialized user
|
* @return User initialized user
|
||||||
*/
|
*/
|
||||||
public static function fromArray($member){
|
public static function fromDbArray($member){
|
||||||
return new User(
|
return new User(
|
||||||
$member['id']??null,
|
$member['id']??null,
|
||||||
$member['loginName']??null,
|
$member['loginName']??null,
|
||||||
@@ -513,26 +542,19 @@ class user{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Setzen aller Attribute
|
/**
|
||||||
/// @todo Inputvalidation
|
* Export the User data into an associative array
|
||||||
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(){
|
function toAssoc(){
|
||||||
return array(
|
return array(
|
||||||
"id" => $this->id,
|
"id" => $this->id,
|
||||||
"loginName"=> $this->loginName,
|
"loginName"=> $this->loginName,
|
||||||
"name" => $this->name,
|
"name" => $this->name,
|
||||||
"vorname" => $this->vorname,
|
"vorname" => $this->firstName,
|
||||||
"gebDatum" => $this->gebDatum,
|
"gebDatum" => $this->dateOfBirth,
|
||||||
"eMail" => $this->eMail);
|
"eMail" => $this->eMail);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFromDb($dbConn, $id){
|
function loadFromDb($dbConn, $id){
|
||||||
$this->set(
|
$this->set(
|
||||||
loadUserDataFromDb($dbConn, $id)
|
loadUserDataFromDb($dbConn, $id)
|
||||||
|
|||||||
Reference in New Issue
Block a user