19declare(strict_types=1);
48 $this->db =
$db ??
$DIC->database();
57 $mail_only_inbox_trash = (bool) $this->
settings->get(
'mail_only_inbox_trash',
'0');
58 $mail_expiration_warning_days = (
int) $this->
settings->get(
'mail_notify_orphaned',
'0');
60 if ($mail_expiration_warning_days > 0) {
61 if ($mail_only_inbox_trash) {
63 $res = $this->db->queryF(
65 SELECT mail_id FROM mail_cron_orphaned
66 LEFT JOIN mail_obj_data mdata ON mdata.obj_id = folder_id
67 WHERE ts_do_delete <= %s AND ((mdata.m_type = %s OR mdata.m_type = %s) OR mdata.obj_id IS NULL)
70 [$this->clock->now()->getTimestamp(),
'inbox',
'trash']
74 $res = $this->db->queryF(
75 'SELECT mail_id FROM mail_cron_orphaned WHERE ts_do_delete <= %s',
77 [$this->clock->now()->getTimestamp()]
82 $mail_expiration_days = (
int) $this->
settings->get(
'mail_threshold',
'0');
83 $left_interval_datetime = $this->clock->now()->modify(
'- ' . $mail_expiration_days .
' days');
86 $data = [$left_interval_datetime->format(
'Y-m-d 23:59:59')];
91 LEFT JOIN mail_obj_data mdata ON mdata.obj_id = m.folder_id
92 WHERE m.send_time <= %s
95 if ($mail_only_inbox_trash) {
96 $mails_query .=
' AND ((mdata.m_type = %s OR mdata.m_type = %s) OR mdata.obj_id IS NULL)';
103 $res = $this->db->queryF($mails_query, $types,
$data);
107 while ($row = $this->db->fetchAssoc(
$res)) {
108 if ($i > 0 && $i % self::PING_THRESHOLD) {
120 $this->mail_ids[] = $mail_id;
readonly ClockInterface $clock
__construct(private readonly ilMailCronOrphanedMails $job, ?ilDBInterface $db=null, ?ilSetting $setting=null, ?ClockInterface $clock=null)
addMailIdToDelete(int $mail_id)
readonly ilSetting $settings
readonly ilDBInterface $db