19 declare(strict_types=1);
46 private function init(): void
50 if (!$this->initDone) {
52 $this->
lng = $DIC->language();
53 $this->db = $DIC->database();
54 $this->
user = $DIC->user();
55 $this->
http = $DIC->http();
57 $this->cron_manager = $DIC->cron()->manager();
59 $this->
lng->loadLanguageModule(
'mail');
60 $this->initDone =
true;
66 $empty_string_or_null_to_stirng_trafo = $this->
refinery->custom()->transformation(
static function ($value):
string {
67 if ($value ===
'' || null === $value) {
71 throw new Exception(
'The value to be transformed is not an empty string');
74 return $this->
refinery->in()->series([
76 $empty_string_or_null_to_stirng_trafo,
77 $this->refinery->kindlyTo()->int(),
79 $this->
refinery->kindlyTo()->float(),
83 $this->
refinery->kindlyTo()->string()
89 return 'mail_orphaned_mails';
95 return $this->
lng->txt(
'mail_orphaned_mails');
101 return $this->
lng->txt(
'mail_orphaned_mails_desc');
117 CronJobScheduleType::SCHEDULE_TYPE_DAILY,
118 CronJobScheduleType::SCHEDULE_TYPE_WEEKLY,
119 CronJobScheduleType::SCHEDULE_TYPE_MONTHLY,
120 CronJobScheduleType::SCHEDULE_TYPE_QUARTERLY,
122 CronJobScheduleType::SCHEDULE_TYPE_IN_DAYS
128 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
145 parent::addCustomSettingsToForm($a_form);
148 $threshold->setInfo($this->
lng->txt(
'mail_threshold_info'));
149 $threshold->allowDecimals(
false);
150 $threshold->setSuffix($this->
lng->txt(
'days'));
151 $threshold->setMinValue(1);
152 $threshold->setSize(4);
153 $threshold->setValue($this->
settings->get(
'mail_threshold',
''));
158 $this->
lng->txt(
'only_inbox_trash'),
159 'mail_only_inbox_trash' 161 $mail_folder->setValue(
'1');
162 $mail_folder->setInfo($this->
lng->txt(
'only_inbox_trash_info'));
163 $mail_folder->setChecked((
bool) $this->
settings->get(
'mail_only_inbox_trash',
'0'));
164 $a_form->
addItem($mail_folder);
167 $this->
lng->txt(
'mail_notify_orphaned'),
168 'mail_notify_orphaned' 170 $notification->setInfo($this->
lng->txt(
'mail_notify_orphaned_info'));
171 $notification->allowDecimals(
false);
172 $notification->setSize(4);
173 $notification->setSuffix($this->
lng->txt(
'days'));
174 $notification->setMinValue(0);
176 if ($this->
http->wrapper()->post()->has(
'mail_threshold')) {
177 $mail_threshold = (
int) $this->
http->wrapper()->post()->retrieve(
182 $mail_threshold = (
int) $this->
settings->get(
'mail_threshold');
184 $maxvalue = $mail_threshold - 1;
185 $notification->setMaxValue($maxvalue);
186 $notification->setValue($this->
settings->get(
'mail_notify_orphaned',
''));
187 $a_form->
addItem($notification);
194 $this->
settings->set(
'mail_only_inbox_trash', (
string) ((
int) $a_form->
getInput(
'mail_only_inbox_trash')));
200 'mail_notify_orphaned',
204 if ((
int) $this->
settings->get(
'mail_notify_orphaned',
'0') === 0) {
206 $this->db->manipulate(
'DELETE FROM mail_cron_orphaned');
209 "Deleted all scheduled mail deletions " .
210 "because a reminder shouldn't be sent (login: %s|usr_id: %s) anymore!",
211 $this->
user->getLogin(),
221 $this->cron_manager->ping($this->
getId());
228 $mail_expiration_days = (
int) $this->
settings->get(
'mail_threshold',
'0');
231 'Started mail deletion job with threshold: %s day(s)',
232 var_export($mail_expiration_days,
true)
235 if ($mail_expiration_days >= 1 && (
int) $this->
settings->get(
'mail_notify_orphaned',
'0') >= 1) {
239 if ($mail_expiration_days >= 1 && (
int) $this->
settings->get(
'last_cronjob_start_ts', (
string) time())) {
245 $result->setStatus($status);
248 'Finished mail deletion job with threshold: %s day(s)',
249 var_export($mail_expiration_days,
true)
262 (
int) $this->
settings->get(
'mail_threshold',
'0'),
263 (
int) $this->
settings->get(
'mail_notify_orphaned',
'0')
273 $processor->delete();
ilCronManager $cron_manager
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDefaultScheduleValue()
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
emptyStringOrFloatOrIntToEmptyOrIntegerString()
static http()
Fetches the global http state from ILIAS.
saveCustomSettings(ilPropertyFormGUI $a_form)