CoolCMS API

AdvertConfirmByKeyTrait uses trait:short

Confirms an advert (Bazaar) or company profile (Comcat) by the key from the activation e-mail.

The e-mail is sent when the module requires confirmation from the given kind of author (advert.confirmation.required.logged|guest). Logic and contract live in the shared ConfirmByKeyTrait; this trait only wires its hooks to the advert names and returns ADVERT_CONFIRMATION_KEY_INVALID.

IMPORTANT: the confirmation must go through the Api manager, not updateColumn from the front end: the Api rejects confirmedAt writes from guests, so an advert added without an account could never be confirmed.

Requires in the using class:

  • $this->rateLimit (RateLimit), $this->rateLimitConfig (RateLimitConfig),
  • findAdvertForConfirmation(int): BazaarAdvert|ComcatAdvert|null, read fresh from the database (no query cache),
  • updateAdvertColumns(int, array): Result, a write through the Api AdvertManager (cache bump),
  • afterAdvertConfirmed(int): void, the follow-ups after the write (search index, category counts),
  • getConfirmModule(): string (bazaar | comcat).

Table of Contents

Constants

CONFIRM_KEY_MAX_LENGTH  : int = 128
Input longer than any issued key is not even looked up (64 hex characters).

Methods

confirmByKey()  : Result
afterRecordConfirmed()  : void
confirmationKeyInvalidCode()  : ResultCode
confirmIpLimitKey()  : string
confirmRecordLimitKey()  : string
The limit keys keep the format from when the trait knew only adverts (`advert-confirm:<module>:advert:<id>`).
findRecordForConfirmation()  : Advert|Advert|null
passesConfirmLimit()  : bool
Peeks without incrementing: only failed attempts spend the quota ({@see self::rejectConfirmation()}).
rejectConfirmation()  : Result
updateConfirmationColumns()  : Result

Constants

CONFIRM_KEY_MAX_LENGTH

Input longer than any issued key is not even looked up (64 hex characters).

private int CONFIRM_KEY_MAX_LENGTH = 128

Methods

confirmByKey()

public confirmByKey(int $id, string $key, string|null $ip) : Result
Parameters
$id : int
$key : string
$ip : string|null
Return values
Result

confirmIpLimitKey()

private confirmIpLimitKey(string|null $ip) : string
Parameters
$ip : string|null
Return values
string

confirmRecordLimitKey()

The limit keys keep the format from when the trait knew only adverts (`advert-confirm:<module>:advert:<id>`).

private confirmRecordLimitKey(int $id) : string
Parameters
$id : int
Return values
string

passesConfirmLimit()

Peeks without incrementing: only failed attempts spend the quota ({@see self::rejectConfirmation()}).

private passesConfirmLimit(int $id, string|null $ip) : bool
Parameters
$id : int
$ip : string|null
Return values
bool

rejectConfirmation()

private rejectConfirmation(int $id, string|null $ip) : Result
Parameters
$id : int
$ip : string|null
Return values
Result

updateConfirmationColumns()

private updateConfirmationColumns(int $id, array<string, mixed> $values) : Result
Parameters
$id : int
$values : array<string, mixed>
Return values
Result
On this page

Search results