|
|
|
@ -39,17 +39,17 @@ use const MB_CASE_LOWER; |
|
|
|
class UserRepository extends ResourceRepository implements PasswordUpgraderInterface |
|
|
|
class UserRepository extends ResourceRepository implements PasswordUpgraderInterface |
|
|
|
{ |
|
|
|
{ |
|
|
|
protected ?UserPasswordHasherInterface $hasher = null; |
|
|
|
protected ?UserPasswordHasherInterface $hasher = null; |
|
|
|
private $illustrationRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const USER_IMAGE_SIZE_SMALL = 1; |
|
|
|
public const USER_IMAGE_SIZE_SMALL = 1; |
|
|
|
const USER_IMAGE_SIZE_MEDIUM = 2; |
|
|
|
public const USER_IMAGE_SIZE_MEDIUM = 2; |
|
|
|
const USER_IMAGE_SIZE_BIG = 3; |
|
|
|
public const USER_IMAGE_SIZE_BIG = 3; |
|
|
|
const USER_IMAGE_SIZE_ORIGINAL = 4; |
|
|
|
public const USER_IMAGE_SIZE_ORIGINAL = 4; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct(ManagerRegistry $registry, IllustrationRepository $illustrationRepository) |
|
|
|
public function __construct( |
|
|
|
{ |
|
|
|
ManagerRegistry $registry, |
|
|
|
|
|
|
|
private readonly IllustrationRepository $illustrationRepository |
|
|
|
|
|
|
|
) { |
|
|
|
parent::__construct($registry, User::class); |
|
|
|
parent::__construct($registry, User::class); |
|
|
|
$this->illustrationRepository = $illustrationRepository; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function loadUserByIdentifier(string $identifier): ?User |
|
|
|
public function loadUserByIdentifier(string $identifier): ?User |
|
|
|
@ -655,7 +655,8 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
->leftJoin(ExtraFieldValues::class, 'efv', Join::WITH, 'efv.field = ef.id AND efv.itemId = :userId') |
|
|
|
->leftJoin(ExtraFieldValues::class, 'efv', Join::WITH, 'efv.field = ef.id AND efv.itemId = :userId') |
|
|
|
->where('ef.itemType = :itemType') |
|
|
|
->where('ef.itemType = :itemType') |
|
|
|
->setParameter('userId', $userId) |
|
|
|
->setParameter('userId', $userId) |
|
|
|
->setParameter('itemType', ExtraField::USER_FIELD_TYPE); |
|
|
|
->setParameter('itemType', ExtraField::USER_FIELD_TYPE) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// Apply visibility filters |
|
|
|
// Apply visibility filters |
|
|
|
if (!$allVisibility) { |
|
|
|
if (!$allVisibility) { |
|
|
|
@ -665,7 +666,8 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
// Apply field filter if provided |
|
|
|
// Apply field filter if provided |
|
|
|
if (null !== $fieldFilter) { |
|
|
|
if (null !== $fieldFilter) { |
|
|
|
$qb->andWhere('ef.id = :fieldFilter') |
|
|
|
$qb->andWhere('ef.id = :fieldFilter') |
|
|
|
->setParameter('fieldFilter', $fieldFilter); |
|
|
|
->setParameter('fieldFilter', $fieldFilter) |
|
|
|
|
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Order by field order |
|
|
|
// Order by field order |
|
|
|
@ -680,7 +682,7 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
$value = $row['fval'] ?? $row['fval_df']; |
|
|
|
$value = $row['fval'] ?? $row['fval_df']; |
|
|
|
|
|
|
|
|
|
|
|
// Handle multiple values if necessary |
|
|
|
// Handle multiple values if necessary |
|
|
|
if ($splitMultiple && in_array($row['type'], [ExtraField::USER_FIELD_TYPE_SELECT_MULTIPLE], true)) { |
|
|
|
if ($splitMultiple && \in_array($row['type'], [ExtraField::USER_FIELD_TYPE_SELECT_MULTIPLE], true)) { |
|
|
|
$value = explode(';', $value); |
|
|
|
$value = explode(';', $value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -688,9 +690,9 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
$key = $prefix ? 'extra_'.$row['fvar'] : $row['fvar']; |
|
|
|
$key = $prefix ? 'extra_'.$row['fvar'] : $row['fvar']; |
|
|
|
|
|
|
|
|
|
|
|
// Special handling for certain field types |
|
|
|
// Special handling for certain field types |
|
|
|
if ($row['type'] == ExtraField::USER_FIELD_TYPE_TAG) { |
|
|
|
if (ExtraField::USER_FIELD_TYPE_TAG == $row['type']) { |
|
|
|
// Implement your logic to handle tags |
|
|
|
// Implement your logic to handle tags |
|
|
|
} elseif ($row['type'] == ExtraField::USER_FIELD_TYPE_RADIO && $prefix) { |
|
|
|
} elseif (ExtraField::USER_FIELD_TYPE_RADIO == $row['type'] && $prefix) { |
|
|
|
$extraData[$key][$key] = $value; |
|
|
|
$extraData[$key][$key] = $value; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$extraData[$key] = $value; |
|
|
|
$extraData[$key] = $value; |
|
|
|
@ -714,7 +716,8 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
'userId' => $userId, |
|
|
|
'userId' => $userId, |
|
|
|
'fieldVariable' => $fieldVariable, |
|
|
|
'fieldVariable' => $fieldVariable, |
|
|
|
'itemType' => ExtraField::USER_FIELD_TYPE, |
|
|
|
'itemType' => ExtraField::USER_FIELD_TYPE, |
|
|
|
]); |
|
|
|
]) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
if (!$allVisibility) { |
|
|
|
if (!$allVisibility) { |
|
|
|
$qb->andWhere('e.visibleToSelf = true'); |
|
|
|
$qb->andWhere('e.visibleToSelf = true'); |
|
|
|
@ -739,7 +742,7 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
|
|
|
|
|
|
|
|
public function searchUsersByTags( |
|
|
|
public function searchUsersByTags( |
|
|
|
string $tag, |
|
|
|
string $tag, |
|
|
|
int $excludeUserId = null, |
|
|
|
?int $excludeUserId = null, |
|
|
|
int $fieldId = 0, |
|
|
|
int $fieldId = 0, |
|
|
|
int $from = 0, |
|
|
|
int $from = 0, |
|
|
|
int $number_of_items = 10, |
|
|
|
int $number_of_items = 10, |
|
|
|
@ -755,16 +758,19 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
|
|
|
|
|
|
|
|
$qb->innerJoin('u.portals', 'urlRelUser') |
|
|
|
$qb->innerJoin('u.portals', 'urlRelUser') |
|
|
|
->leftJoin(UserRelTag::class, 'uv', 'WITH', 'u = uv.user') |
|
|
|
->leftJoin(UserRelTag::class, 'uv', 'WITH', 'u = uv.user') |
|
|
|
->leftJoin(Tag::class, 'ut', 'WITH', 'uv.tag = ut'); |
|
|
|
->leftJoin(Tag::class, 'ut', 'WITH', 'uv.tag = ut') |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
if ($fieldId !== 0) { |
|
|
|
if (0 !== $fieldId) { |
|
|
|
$qb->andWhere('ut.field = :fieldId') |
|
|
|
$qb->andWhere('ut.field = :fieldId') |
|
|
|
->setParameter('fieldId', $fieldId); |
|
|
|
->setParameter('fieldId', $fieldId) |
|
|
|
|
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($excludeUserId !== null) { |
|
|
|
if (null !== $excludeUserId) { |
|
|
|
$qb->andWhere('u.id != :excludeUserId') |
|
|
|
$qb->andWhere('u.id != :excludeUserId') |
|
|
|
->setParameter('excludeUserId', $excludeUserId); |
|
|
|
->setParameter('excludeUserId', $excludeUserId) |
|
|
|
|
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$qb->andWhere( |
|
|
|
$qb->andWhere( |
|
|
|
@ -784,18 +790,21 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
->setParameter('tag', $tag.'%') |
|
|
|
->setParameter('tag', $tag.'%') |
|
|
|
->setParameter('likeTag', '%' . $tag . '%'); |
|
|
|
->setParameter('likeTag', '%'.$tag.'%') |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// Only active users and not anonymous |
|
|
|
// Only active users and not anonymous |
|
|
|
$qb->andWhere('u.active = :active') |
|
|
|
$qb->andWhere('u.active = :active') |
|
|
|
->andWhere('u.status != :anonymous') |
|
|
|
->andWhere('u.status != :anonymous') |
|
|
|
->setParameter('active', true) |
|
|
|
->setParameter('active', true) |
|
|
|
->setParameter('anonymous', 6); |
|
|
|
->setParameter('anonymous', 6) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
if (!$getCount) { |
|
|
|
if (!$getCount) { |
|
|
|
$qb->orderBy('u.username') |
|
|
|
$qb->orderBy('u.username') |
|
|
|
->setFirstResult($from) |
|
|
|
->setFirstResult($from) |
|
|
|
->setMaxResults($number_of_items); |
|
|
|
->setMaxResults($number_of_items) |
|
|
|
|
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $getCount ? $qb->getQuery()->getSingleScalarResult() : $qb->getQuery()->getResult(); |
|
|
|
return $getCount ? $qb->getQuery()->getSingleScalarResult() : $qb->getQuery()->getResult(); |
|
|
|
@ -810,11 +819,10 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
->where('u.id = :userId AND f.id = :friendId') |
|
|
|
->where('u.id = :userId AND f.id = :friendId') |
|
|
|
->setParameter('userId', $userId) |
|
|
|
->setParameter('userId', $userId) |
|
|
|
->setParameter('friendId', $friendId) |
|
|
|
->setParameter('friendId', $friendId) |
|
|
|
->setMaxResults(1); |
|
|
|
->setMaxResults(1) |
|
|
|
|
|
|
|
; |
|
|
|
$result = $qb->getQuery()->getOneOrNullResult(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
return $qb->getQuery()->getOneOrNullResult(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function relateUsers(User $user1, User $user2, int $relationType): void |
|
|
|
public function relateUsers(User $user1, User $user2, int $relationType): void |
|
|
|
@ -859,26 +867,31 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter |
|
|
|
int $size = self::USER_IMAGE_SIZE_MEDIUM, |
|
|
|
int $size = self::USER_IMAGE_SIZE_MEDIUM, |
|
|
|
$addRandomId = true, |
|
|
|
$addRandomId = true, |
|
|
|
) { |
|
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
$user = $this->find($userId); |
|
|
|
$user = $this->find($userId); |
|
|
|
if (!$user) { |
|
|
|
if (!$user) { |
|
|
|
|
|
|
|
|
|
|
|
return '/img/icons/64/unknown.png'; |
|
|
|
return '/img/icons/64/unknown.png'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch ($size) { |
|
|
|
switch ($size) { |
|
|
|
case self::USER_IMAGE_SIZE_SMALL: |
|
|
|
case self::USER_IMAGE_SIZE_SMALL: |
|
|
|
$width = 32; |
|
|
|
$width = 32; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case self::USER_IMAGE_SIZE_MEDIUM: |
|
|
|
case self::USER_IMAGE_SIZE_MEDIUM: |
|
|
|
$width = 64; |
|
|
|
$width = 64; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case self::USER_IMAGE_SIZE_BIG: |
|
|
|
case self::USER_IMAGE_SIZE_BIG: |
|
|
|
$width = 128; |
|
|
|
$width = 128; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case self::USER_IMAGE_SIZE_ORIGINAL: |
|
|
|
case self::USER_IMAGE_SIZE_ORIGINAL: |
|
|
|
default: |
|
|
|
default: |
|
|
|
$width = 0; |
|
|
|
$width = 0; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|