19 declare(strict_types=1);
49 $this->db = $db ?? $DIC->database();
51 $this->clock = $clock ?? (
new Factory())->clock()->system();
60 $mail_only_inbox_trash = (bool) $this->
settings->get(
'mail_only_inbox_trash',
'0');
61 $mail_expiration_warning_days = (
int) $this->
settings->get(
'mail_notify_orphaned',
'0');
63 if ($mail_expiration_warning_days > 0) {
64 if ($mail_only_inbox_trash) {
66 $res = $this->db->queryF(
68 SELECT mail_id FROM mail_cron_orphaned 69 LEFT JOIN mail_obj_data mdata ON mdata.obj_id = folder_id 70 WHERE ts_do_delete <= %s AND ((mdata.m_type = %s OR mdata.m_type = %s) OR mdata.obj_id IS NULL) 73 [$this->clock->now()->getTimestamp(),
'inbox',
'trash']
77 $res = $this->db->queryF(
78 "SELECT mail_id FROM mail_cron_orphaned WHERE ts_do_delete <= %s",
80 [$this->clock->now()->getTimestamp()]
85 $mail_expiration_days = (
int) $this->
settings->get(
'mail_threshold',
'0');
86 $left_interval_datetime = $this->clock->now()->modify(
'- ' . $mail_expiration_days .
' days');
89 $data = [$left_interval_datetime->format(
'Y-m-d 23:59:59')];
94 LEFT JOIN mail_obj_data mdata ON mdata.obj_id = m.folder_id 95 WHERE m.send_time <= %s 98 if ($mail_only_inbox_trash) {
99 $mails_query .=
" AND ((mdata.m_type = %s OR mdata.m_type = %s) OR mdata.obj_id IS NULL)";
101 array_push(
$data,
'inbox',
'trash');
104 $res = $this->db->queryF($mails_query, $types,
$data);
108 while ($row = $this->db->fetchAssoc(
$res)) {
109 if (
$i > 0 &&
$i % self::PING_THRESHOLD) {
121 $this->mail_ids[] = $mail_id;
__construct(ilMailCronOrphanedMails $job, ?ilDBInterface $db=null, ?ilSetting $setting=null, ?ClockInterface $clock=null)
ilMailCronOrphanedMails $job
addMailIdToDelete(int $mail_id)