AdvertModerationNoticeTrait
E-mails the advertiser when the state of the advert changes by someone's decision: - approval (`approved_at` from NULL to filled, not banned) sends `CC_ADVERT_ACTIVATION_NOTICE`, - rejection = ban (`banned` 0 to 1) sends `CC_ADVERT_BAN`, - deletion (`deleted` 0 to 1: the owner's "Delete" on the front end, the admin "Deleted" switch) sends `CC_ADVERT_DELETE`, - deactivation (`deactivated` 0 to 1, admin form or grid switch) sends `CC_ADVERT_DEACTIVATION`.
One e-mail per advert and write, by the priority ban, delete, deactivation, approval (the
strongest decision is the one the advertiser needs to know). The state is read raw before the
write and compared after the commit, so it works for the form save and for updateColumns()
(grid switches, the front end delete). It is sent even with suppressNotifications (admin
edit), because it is an explicit message about a decision. Account anonymization deactivates
without e-mails (updateColumnsWithoutNotices()). The operator turns each e-mail off in
System > E-mails (active).
Table of Contents
Properties
- $moderationNoticesSuppressed : bool
- Set only for the duration of {@see updateColumnsWithoutNotices()}.
- $moderationStateBefore : array<int, array{approved: bool, banned: bool, deleted: bool, deactivated: bool}>
Methods
- moderationNoticeKey() : string|null
- Template key of the notice for a state change, or `null` when nothing is sent.
- updateColumnsWithoutNotices() : Result
- `updateColumns()` without moderation e-mails, for system steps that are not a decision about the advert (account anonymization deactivates the adverts of a deleted account; its owner must not get any more e-mails).
- captureModerationState() : void
- readModerationState() : array<int, array{approved: bool, banned: bool, deleted: bool, deactivated: bool}>
- sendModerationNotices() : void
- watchesModerationColumns() : bool
- Whether `updateColumns()` with these values should capture the state for notices.
Properties
$moderationNoticesSuppressed
Set only for the duration of {@see updateColumnsWithoutNotices()}.
private
bool
$moderationNoticesSuppressed
= false
$moderationStateBefore
private
array<int, array{approved: bool, banned: bool, deleted: bool, deactivated: bool}>
$moderationStateBefore
= []
Methods
moderationNoticeKey()
Template key of the notice for a state change, or `null` when nothing is sent.
public
static moderationNoticeKey(array{approved: bool, banned: bool, deleted: bool, deactivated: bool} $was, array{approved: bool, banned: bool, deleted: bool, deactivated: bool} $now) : string|null
Parameters
- $was : array{approved: bool, banned: bool, deleted: bool, deactivated: bool}
- $now : array{approved: bool, banned: bool, deleted: bool, deactivated: bool}
Return values
string|nullupdateColumnsWithoutNotices()
`updateColumns()` without moderation e-mails, for system steps that are not a decision about the advert (account anonymization deactivates the adverts of a deleted account; its owner must not get any more e-mails).
public
updateColumnsWithoutNotices(int|array<string|int, mixed> $entityId, array<string, mixed> $values) : Result
Parameters
- $entityId : int|array<string|int, mixed>
- $values : array<string, mixed>
Return values
ResultcaptureModerationState()
private
captureModerationState(array<int, int> $advertIds) : void
Parameters
- $advertIds : array<int, int>
readModerationState()
private
readModerationState(array<int, int> $advertIds) : array<int, array{approved: bool, banned: bool, deleted: bool, deactivated: bool}>
Parameters
- $advertIds : array<int, int>
Return values
array<int, array{approved: bool, banned: bool, deleted: bool, deactivated: bool}>sendModerationNotices()
private
sendModerationNotices(array<string, mixed> $meta) : void
Parameters
- $meta : array<string, mixed>
watchesModerationColumns()
Whether `updateColumns()` with these values should capture the state for notices.
private
watchesModerationColumns(array<string, mixed> $values) : bool
Parameters
- $values : array<string, mixed>