just one user

This commit is contained in:
marko
2022-10-27 10:36:20 +02:00
parent 32d809f5a0
commit 3e60b97050
6 changed files with 168 additions and 112 deletions

View File

@@ -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)