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/">
|
||||
|
||||
Reference in New Issue
Block a user