2014-08-30 18:11:32 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\Dao;
|
|
|
|
|
|
|
|
class UserDao extends AbstractDao implements ICrudDao
|
|
|
|
{
|
2014-09-03 19:07:53 +02:00
|
|
|
public function __construct(
|
|
|
|
\Szurubooru\DatabaseConnection $databaseConnection)
|
2014-08-30 18:11:32 +02:00
|
|
|
{
|
2014-09-14 12:09:22 +02:00
|
|
|
parent::__construct($databaseConnection, 'users', \Szurubooru\Entities\User::class);
|
2014-08-30 18:11:32 +02:00
|
|
|
}
|
|
|
|
|
2014-09-13 23:58:13 +02:00
|
|
|
public function findByName($userName)
|
2014-08-30 18:11:32 +02:00
|
|
|
{
|
2014-09-14 16:16:15 +02:00
|
|
|
return $this->findOneBy('name', $userName);
|
2014-08-30 18:11:32 +02:00
|
|
|
}
|
2014-09-01 19:43:49 +02:00
|
|
|
|
2014-09-13 23:58:13 +02:00
|
|
|
public function findByEmail($userEmail, $allowUnconfirmed = false)
|
2014-09-08 13:06:32 +02:00
|
|
|
{
|
2014-09-14 16:16:15 +02:00
|
|
|
$result = $this->findOneBy('email', $userEmail);
|
|
|
|
if (!$result and $allowUnconfirmed)
|
|
|
|
{
|
|
|
|
$result = $this->findOneBy('emailUnconfirmed', $userEmail);
|
|
|
|
}
|
|
|
|
return $result;
|
2014-09-08 13:06:32 +02:00
|
|
|
}
|
|
|
|
|
2014-09-01 19:43:49 +02:00
|
|
|
public function hasAnyUsers()
|
|
|
|
{
|
2014-09-14 16:16:15 +02:00
|
|
|
return $this->hasAnyRecords();
|
2014-09-01 19:43:49 +02:00
|
|
|
}
|
2014-09-05 13:50:51 +02:00
|
|
|
|
|
|
|
public function deleteByName($userName)
|
|
|
|
{
|
2014-09-14 16:16:15 +02:00
|
|
|
$this->deleteBy('name', $userName);
|
|
|
|
$this->fpdo->deleteFrom('tokens')->where('additionalData', $userName);
|
2014-09-05 13:50:51 +02:00
|
|
|
}
|
2014-08-30 18:11:32 +02:00
|
|
|
}
|