50 return $this->db->insertData($insert) !== 0;
65 return $this->db->getDataRow($select, [$this,
'rowToRecord']);
81 ->where($select->compare(
'recipient_guid',
'=', $recipient_guid,
ELGG_VALUE_GUID))
82 ->andWhere($select->compare(
'delivery_interval',
'=', $delivery_interval,
ELGG_VALUE_STRING))
84 ->orderBy(
'timestamp',
'ASC')
85 ->addOrderBy(
'id',
'ASC');
87 if ($max_results > 0) {
88 $select->setMaxResults($max_results);
91 return $this->db->getData($select, [$this,
'rowToRecord']);
104 $select->select(
'recipient_guid')
105 ->where($select->compare(
'delivery_interval',
'=', $delivery_interval,
ELGG_VALUE_STRING))
106 ->andWhere($select->compare(
'timestamp',
'<',
$timestamp ?? $this->getCurrentTime()->getTimestamp()))
107 ->orderBy(
'timestamp',
'ASC')
108 ->addOrderBy(
'id',
'ASC')
111 $row = $this->db->getDataRow($select);
116 return (
int) $row->recipient_guid;
130 return $this->db->deleteData(
$delete);
148 ->orderBy(
'timestamp',
'ASC')
149 ->addOrderBy(
'id',
'ASC');
155 return $this->db->deleteData(
$delete);
169 return $this->db->deleteData(
$delete);
182 $update->set(
'delivery_interval', $update->param($delivery_interval,
ELGG_VALUE_STRING))
183 ->where($update->compare(
'recipient_guid',
'=', $recipient_guid,
ELGG_VALUE_GUID));
185 return $this->db->updateData($update);
static table(string $table)
Returns a QueryBuilder for updating data in a given table.
queueEmail(int $recipient_guid, string $delivery_interval, $item)
Insert a delayed email into the queue.
const ELGG_VALUE_INTEGER
Value types.
trait TimeUsing
Adds methods for setting the current time (for testing)
static intoTable(string $table)
Returns a QueryBuilder for inserting data in a given table.
getCurrentTime($modifier= '')
Get the (cloned) time.
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.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
rowToRecord(\stdClass $row)
Convert a database row to a manageable object.
static fromTable(string $table)
Returns a QueryBuilder for deleting data from a given table.
deleteAllRecipientRows(int $recipient_guid)
Deletes all the queue items from the database for the given recipient.
__construct(protected Database $db)
Create new service.
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
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.
static fromTable(string $table, string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
updateRecipientInterval(int $recipient_guid, string $delivery_interval)
Update the queued notifications for the recipient to a new delivery interval.
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.