Created structure to access the offers of the clubs

This commit is contained in:
2019-04-16 16:08:11 +02:00
parent 63caca5b80
commit 0bafe438e2
7 changed files with 409 additions and 19 deletions

View File

@@ -13,7 +13,6 @@ class PasswordInvalidException extends Exception
class ClubsUser
{
protected $dbo;
protected $id;
protected $user;
protected $hash;
@@ -184,9 +183,7 @@ class ClubsUser
}
protected function __construct()
{
$this->dbo = Factory::getDbo();
}
{}
public static function loadUsers()
{
@@ -261,7 +258,8 @@ class ClubsUser
private function insertUser()
{
$q = $this->dbo->getQuery(true);
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$vuser = $q->q($this->user);
$vpassword = $q->q($this->hash);
@@ -277,16 +275,17 @@ class ClubsUser
->values("$vuser, $vpassword, $vname, $vaddress, $vcity, $vmail, $vphone, $vmobile")
;
$this->dbo->transactionStart();
$this->dbo->setQuery($q);
$this->dbo->execute();
$this->id = $this->dbo->insertid();
$this->dbo->transactionCommit();
$dbo->transactionStart();
$dbo->setQuery($q);
$dbo->execute();
$this->id = $dbo->insertid();
$dbo->transactionCommit();
}
private function updateUser()
{
$q = $this->dbo->getQuery(true);
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$vuser = $q->q($this->user);
$vpassword = $q->q($this->hash);
@@ -311,8 +310,8 @@ class ClubsUser
->where("id=". (int) $this->id)
;
$this->dbo->setQuery($q);
$this->dbo->execute();
$dbo->setQuery($q);
$dbo->execute();
}
private function checkHash(string $password)
@@ -323,10 +322,13 @@ class ClubsUser
if(password_needs_rehash($this->hash, PASSWORD_DEFAULT))
{
$this->hash = password_hash($password, PASSWORD_DEFAULT);
$q = $this->dbo->getQuery(true);
$dbo = Factory::getDbo();
$q = $dbo->getQuery(true);
$q->update('#__club_users')->set('password=' . $q->q($this->hash))->where('id=' . (int) $this->id);
$this->dbo->setQuery($q);
$this->dbo->execute();
$dbo->setQuery($q);
$dbo->execute();
}
}
@@ -334,13 +336,14 @@ class ClubsUser
{
if($this->id === 'new')
return;
$dbo = Factory::getDbo();
$q = $this->dbo->getQuery(true);
$q = $dbo->getQuery(true);
$q->delete('#__club_users')
->where('id=' . (int) $this->id);
$this->dbo->setQuery($q);
$this->dbo->execute();
$dbo->setQuery($q);
$dbo->execute();
}
public static function isUserNameFree($username, int $id = -1)