19 declare(strict_types=1);
49 $this->db = $db ?? $DIC->database();
50 $this->setting = $settings ?? $DIC->settings();
51 $this->clock = $clock ?? (
new Factory())->clock()->system();
56 private function collect():
void 58 $mail_expiration_days = (
int) $this->setting->get(
'mail_threshold',
'0');
59 $mail_expiration_warning_days = (
int) $this->setting->get(
'mail_notify_orphaned',
'0');
61 if ($mail_expiration_days > $mail_expiration_warning_days) {
62 $notify_days_before = $mail_expiration_days - $mail_expiration_warning_days;
64 $notify_days_before = 1;
67 $left_interval_datetime = $this->clock->now()->modify(
'- ' . $notify_days_before .
' days');
70 $data = [$left_interval_datetime->format(
'Y-m-d 23:59:59')];
72 $notification_query =
" 73 SELECT m.mail_id, m.user_id, m.folder_id, m.send_time, m.m_subject, mdata.title 75 LEFT JOIN mail_obj_data mdata ON mdata.obj_id = m.folder_id 76 LEFT JOIN mail_cron_orphaned mco ON mco.mail_id = m.mail_id 77 WHERE mco.mail_id IS NULL AND m.send_time <= %s 80 if ((
int) $this->setting->get(
'mail_only_inbox_trash',
'0') > 0) {
81 $notification_query .=
" AND ((mdata.m_type = %s OR mdata.m_type = %s) OR mdata.obj_id IS NULL)";
88 $notification_query .=
" ORDER BY m.user_id, m.folder_id, m.mail_id";
91 $collection_obj =
null;
93 $res = $this->db->queryF($notification_query, $types,
$data);
95 while ($row = $this->db->fetchAssoc(
$res)) {
96 if ($i > 0 && $i % self::PING_THRESHOLD === 0) {
102 $collection_obj =
null;
105 if ($collection_obj ===
null) {
107 $collection_obj =
new ReportDto((
int) $row[
'user_id']);
111 $folder_obj = $collection_obj->getFolderObjectById((
int) $row[
'folder_id']);
112 if ($folder_obj ===
null) {
113 $folder_obj =
new FolderDto((
int) $row[
'folder_id'], $row[
'title']);
114 $collection_obj->addFolderObject($folder_obj);
117 $orphaned_mail_obj =
new MailDto(
118 (
int) $row[
'mail_id'],
121 $folder_obj->addMailObject($orphaned_mail_obj);
128 return isset($this->collection[$user_id]);
133 $this->collection[$collection_obj->
getUserId()] = $collection_obj;
addCollectionObject(ReportDto $collection_obj)
existsCollectionObjForUserId(int $user_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(private readonly ilMailCronOrphanedMails $job, ?ilDBInterface $db=null, ?ilSetting $settings=null, ?ClockInterface $clock=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ilSetting $setting
readonly ilDBInterface $db
readonly ClockInterface $clock