Received
in package
implements
ArrayAccess
uses
ArrayAccessHelper
This class represents the received copy of a personal message in a member's inbox. It has info such as whether the PM has been read by this member, deleted by the member, etc., and whether it was sent to this member as a visible recipient or as a hidden one (i.e a "BCC" recipient).
Tags
Table of Contents
Interfaces
- ArrayAccess
Properties
- $bcc : bool
- $deleted : bool
- $id : int
- $in_inbox : bool
- $is_new : bool
- $labels : array<string|int, mixed>
- $loaded : array<string|int, mixed>
- $member : int
- $name : string
- $replied : bool
- $unread : bool
- $messages_request : object
- $prop_aliases : array<string|int, mixed>
- $recent : array<string|int, mixed>
Methods
- __construct() : mixed
- Constructor.
- __set() : void
- Sets custom properties.
- addLabel() : array<string|int, mixed>
- Applies a label to this PM.
- count() : int
- Counts the personal messages in a given label, with optional limits.
- getLatest() : int
- Gets the ID of the most recent personal message in a label or the inbox.
- getRecent() : array<string|int, mixed>
- Gets the IDs of the most recent personal messages in a label or the inbox.
- loadByPm() : array<string|int, mixed>
- Loads instances of this class for the passed personal message IDs.
- loadUnread() : array<string|int, mixed>
- Loads instances of this class for unread personal messages.
- offsetExists() : bool
- Checks whether a property has been set when object is accessed as an array.
- offsetGet() : mixed
- Gets properties when object is accessed as an array.
- offsetSet() : void
- Sets properties when object is accessed as an array.
- offsetUnset() : void
- Unsets properties when object is accessed as an array.
- old() : array<string|int, mixed>
- Returns the IDs of personal messages received before a given time.
- removeLabel() : array<string|int, mixed>
- Removes a label from this PM.
- save() : void
- Update the received status in the database.
- setNotNew() : void
- Removes the 'is_new' status from the current user's PMs.
- getLabels() : void
- Gets the IDs of labels applied to this PM by a member who received it.
- queryData() : Generator<string|int, array<string|int, mixed>>
- Generator that runs queries about PM data and yields the result rows.
Properties
$bcc
public
bool
$bcc
= false
Whether the member was a hidden recipient.
Just like a "blind carbon copy" recipient of an e-mail message, a BCC recipient of a personal message is not visible to other recipients.
$deleted
public
bool
$deleted
= false
Whether the recipient has deleted the PM.
$id
public
int
$id
The PM's ID number.
$in_inbox
public
bool
$in_inbox
= true
Whether the PM is in the recipient's inbox folder.
$is_new
public
bool
$is_new
= false
Whether the recipient has been informed yet that they received the PM.
$labels
public
array<string|int, mixed>
$labels
= []
Labels assigned to this PM by the recipient.
$loaded
public
static array<string|int, mixed>
$loaded
= []
All loaded instances of this class.
$member
public
int
$member
ID number of the recipient of the PM.
$name
public
string
$name
Name of the recipient of the PM.
$replied
public
bool
$replied
= false
Whether the recipient has replied the PM.
$unread
public
bool
$unread
= true
Whether the recipient has read the PM.
$messages_request
protected
static object
$messages_request
Database query used in Received::queryData().
$prop_aliases
protected
array<string|int, mixed>
$prop_aliases
= ['id_pm' => 'id', 'id_member' => 'member', 'real_name' => 'name']
Alternate names for some object properties.
$recent
protected
static array<string|int, mixed>
$recent
= []
Holds the results of Received::getRecent().
The keys of this array are string representations of the parameters that Received::getRecent() was called with. The values are lists of PM IDs that match those parameters.
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $props = [] ]) : mixed
Parameters
- $props : array<string|int, mixed> = []
-
Properties to set for this message.
__set()
Sets custom properties.
public
__set(string $prop, mixed $value) : void
Parameters
- $prop : string
-
The property name.
- $value : mixed
-
The value to set.
addLabel()
Applies a label to this PM.
public
addLabel(int $label_id) : array<string|int, mixed>
Parameters
- $label_id : int
Return values
array<string|int, mixed> —The label IDs.
count()
Counts the personal messages in a given label, with optional limits.
public
static count([int $label = -1 ][, int $boundary = 0 ][, bool $greater_than = false ]) : int
Parameters
- $label : int = -1
-
The ID of a label, or -1 for the inbox.
- $boundary : int = 0
-
The ID of a PM that limits the range of counted PMs.
- $greater_than : bool = false
-
If true, only count PMs whose IDs are greater than $boundary. If false, only count PMs whose IDs are less than it.
Return values
intgetLatest()
Gets the ID of the most recent personal message in a label or the inbox.
public
static getLatest([int $label = -1 ]) : int
Parameters
- $label : int = -1
-
The ID of a label, or -1 for the inbox.
Return values
int —The ID of the most recent PM.
getRecent()
Gets the IDs of the most recent personal messages in a label or the inbox.
public
static getRecent([int $label = -1 ][, string $sort = 'pmr.id_pm' ][, bool $descending = true ][, int $limit = 0 ][, int $offset = 0 ]) : array<string|int, mixed>
Parameters
- $label : int = -1
-
The ID of a label, or -1 for the inbox. Default: -1.
- $sort : string = 'pmr.id_pm'
-
The column to sort by in the SQL query. Default: pmr.id_pm
- $descending : bool = true
-
Whether to sort descending or ascending. Default: true.
- $limit : int = 0
-
How many results to get. Zero for no limit. Default: 0.
- $offset : int = 0
-
How many results to skip before retrieving the rest. Default: 0.
Return values
array<string|int, mixed> —The IDs of the most recent PMs.
loadByPm()
Loads instances of this class for the passed personal message IDs.
public
static loadByPm(int|array<string|int, mixed> $ids) : array<string|int, mixed>
The newly loaded instances are returned, but also stored in self::$loaded for future reference.
Parameters
- $ids : int|array<string|int, mixed>
-
The IDs of one or more personal messages.
Return values
array<string|int, mixed> —The newly loaded instances of this class.
loadUnread()
Loads instances of this class for unread personal messages.
public
static loadUnread() : array<string|int, mixed>
Return values
array<string|int, mixed>offsetExists()
Checks whether a property has been set when object is accessed as an array.
public
offsetExists(mixed $prop) : bool
Parameters
- $prop : mixed
-
The property name.
Return values
booloffsetGet()
Gets properties when object is accessed as an array.
public
& offsetGet(mixed $prop) : mixed
Parameters
- $prop : mixed
-
The property name.
Return values
mixed —A reference to the property.
offsetSet()
Sets properties when object is accessed as an array.
public
offsetSet(mixed $prop, mixed $value) : void
Parameters
- $prop : mixed
-
The property name.
- $value : mixed
-
The value to set.
offsetUnset()
Unsets properties when object is accessed as an array.
public
offsetUnset(mixed $prop) : void
Parameters
- $prop : mixed
-
The property name.
old()
Returns the IDs of personal messages received before a given time.
public
static old(int $time) : array<string|int, mixed>
Parameters
- $time : int
-
A Unix timestamp.
Return values
array<string|int, mixed> —The IDs of personal messages received before $time.
removeLabel()
Removes a label from this PM.
public
removeLabel(int $label_id) : array<string|int, mixed>
Parameters
- $label_id : int
Return values
array<string|int, mixed> —The label IDs.
save()
Update the received status in the database.
public
save() : void
setNotNew()
Removes the 'is_new' status from the current user's PMs.
public
static setNotNew() : void
getLabels()
Gets the IDs of labels applied to this PM by a member who received it.
protected
getLabels() : void
The data is stored in $this->labels.
queryData()
Generator that runs queries about PM data and yields the result rows.
protected
static queryData(array<string|int, mixed> $selects[, array<string|int, mixed> $params = [] ][, array<string|int, mixed> $joins = [] ][, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ][, array<string|int, mixed> $group = [] ][, int|string $limit = 0 ]) : Generator<string|int, array<string|int, mixed>>
Parameters
- $selects : array<string|int, mixed>
-
Table columns to select.
- $params : array<string|int, mixed> = []
-
Parameters to substitute into query text.
- $joins : array<string|int, mixed> = []
-
Zero or more complete JOIN clauses. E.g.: 'LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' Note that 'FROM {db_prefix}boards AS b' is always part of the query.
- $where : array<string|int, mixed> = []
-
Zero or more conditions for the WHERE clause. Conditions will be placed in parentheses and concatenated with AND. If this is left empty, no WHERE clause will be used.
- $order : array<string|int, mixed> = []
-
Zero or more conditions for the ORDER BY clause. If this is left empty, no ORDER BY clause will be used.
- $group : array<string|int, mixed> = []
-
Zero or more conditions for the GROUP BY clause. If this is left empty, no GROUP BY clause will be used.
- $limit : int|string = 0
-
Maximum number of results to retrieve. If this is left empty, all results will be retrieved.
Return values
Generator<string|int, array<string|int, mixed>> —Iterating over the result gives database rows.