19declare(strict_types=1);
45 $unique_id = uniqid((
string) mt_rand(),
true);
46 $hash = substr(md5($unique_id), 0, 16);
48 $res = $this->db->queryF(
49 'SELECT COUNT(usr_id) cnt FROM reg_dual_opt_in WHERE reg_hash = %s',
53 $row = $this->db->fetchObject(
$res);
65 $this->db->manipulateF(
66 'REPLACE INTO reg_dual_opt_in (id, usr_id, reg_hash, creation_date) VALUES (%s, %s, %s, %s)',
74 $reg->
id()->toString(),
76 $reg->
hash()->toString(),
84 $res = $this->db->queryF(
85 'SELECT id, usr_id, reg_hash, creation_date FROM reg_dual_opt_in WHERE reg_hash = %s',
90 $row = $this->db->fetchAssoc(
$res);
100 if (\count($pending_registrations) === 0) {
104 if (\count($pending_registrations) === 1) {
105 $this->db->manipulateF(
106 'DELETE FROM reg_dual_opt_in WHERE id = %s',
108 [$pending_registrations[0]->
id()->toString()]
113 $pending_registrations
116 $this->db->manipulate(
117 'DELETE FROM reg_dual_opt_in ' .
125 $this->db->manipulateF(
126 'DELETE FROM reg_dual_opt_in WHERE usr_id = %s',
135 public function findExpired(
int $cutoff_ts, ?
int $prioritize_usr_id =
null): array
137 $except_anon_and_sys = $this->db->in(
146 FROM reg_dual_opt_in pr
147 JOIN usr_data ud ON ud.usr_id = pr.usr_id
149 AND pr.creation_date < %s
150 AND ' . $except_anon_and_sys .
'
151 ORDER BY (CASE WHEN pr.usr_id = %s THEN 0 ELSE 1 END), pr.creation_date
154 $res = $this->db->queryF(
157 [$cutoff_ts, $prioritize_usr_id ?? 0]
160 $expired_registrations = [];
161 while ($row = $this->db->fetchAssoc(
$res)) {
165 return $expired_registrations;
174 $usr_id =
new ObjectId($row[
'usr_id']);
176 $created_at = new \DateTimeImmutable(
'@' . $row[
'creation_date']);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
@phpstan-type PendingRegistrationRecord array{id: string, usr_id: int, reg_hash: string,...
__construct(private \ilDBInterface $db)
findByHashValue(string $hash_value)
rebuildObjFromRow(array $row)
findExpired(int $cutoff_ts, ?int $prioritize_usr_id=null)
deleteByUserId(int $usr_id)
store(PendingRegistration $reg)
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...