53 return $this->db->insertData($insert) !== 0;
68 return $this->db->getDataRow($select, [$this,
'rowToRecord']);
84 ->where($select->compare(
'recipient_guid',
'=', $recipient_guid,
ELGG_VALUE_GUID))
85 ->andWhere($select->compare(
'delivery_interval',
'=', $delivery_interval,
ELGG_VALUE_STRING))
87 ->orderBy(
'timestamp',
'ASC')
88 ->addOrderBy(
'id',
'ASC');
90 if ($max_results > 0) {
91 $select->setMaxResults($max_results);
94 return $this->db->getData($select, [$this,
'rowToRecord']);
107 $select->select(
'recipient_guid')
108 ->where($select->compare(
'delivery_interval',
'=', $delivery_interval,
ELGG_VALUE_STRING))
109 ->andWhere($select->compare(
'timestamp',
'<',
$timestamp ?? $this->getCurrentTime()->getTimestamp()))
110 ->orderBy(
'timestamp',
'ASC')
111 ->addOrderBy(
'id',
'ASC')
114 $row = $this->db->getDataRow($select);
119 return (
int) $row->recipient_guid;
133 return $this->db->deleteData(
$delete);
151 ->orderBy(
'timestamp',
'ASC')
152 ->addOrderBy(
'id',
'ASC');
158 return $this->db->deleteData(
$delete);
172 return $this->db->deleteData(
$delete);
185 $update->set(
'delivery_interval', $update->param($delivery_interval,
ELGG_VALUE_STRING))
186 ->where($update->compare(
'recipient_guid',
'=', $recipient_guid,
ELGG_VALUE_GUID));
188 return $this->db->updateData($update);
queueEmail(int $recipient_guid, string $delivery_interval, $item)
Insert a delayed email into the queue.
static table($table, $alias=null)
{}
const ELGG_VALUE_INTEGER
Value types.
trait TimeUsing
Adds methods for setting the current time (for testing)
getCurrentTime($modifier= '')
Get the (cloned) time.
static intoTable($table)
{}
deleteRecipientRows(int $recipient_guid, string $delivery_interval, int $timestamp=null, int $max_id=0)
Delete all the queue items from the database for the given recipient and interval.
rowToRecord(\stdClass $row)
Convert a database row to a manageable object.
deleteAllRecipientRows(int $recipient_guid)
Deletes all the queue items from the database for the given recipient.
deleteRow(int $id)
Remove a queue items from the database.
Interfaces with the database to perform operations on the delayed_email_queue table.
const ELGG_VALUE_TIMESTAMP
static fromTable($table, $alias=null)
{}
getRecipientRows(int $recipient_guid, string $delivery_interval, int $timestamp=null, int $max_results=0)
Get all the rows in the queue for a given recipient.
updateRecipientInterval(int $recipient_guid, string $delivery_interval)
Update the queued notifications for the recipient to a new delivery interval.
__construct(Database $db)
Create new service.
getRow(int $id)
Get a row from the queue.
$id
Generic annotation delete action.
getNextRecipientGUID(string $delivery_interval, int $timestamp=null)
Fetch the GUID of the next recipient to process.
static fromTable($table, $alias=null)
{}