19 declare(strict_types=1);
45 private function init(): void
49 if (!$this->initDone) {
51 $this->
lng = $DIC->language();
52 $this->db = $DIC->database();
53 $this->
user = $DIC->user();
54 $this->
http = $DIC->http();
56 $this->cron_manager = $DIC->cron()->manager();
58 $this->
lng->loadLanguageModule(
'mail');
59 $this->initDone =
true;
65 $empty_string_or_null_to_stirng_trafo = $this->
refinery->custom()->transformation(
static function ($value):
string {
66 if ($value ===
'' || null === $value) {
70 throw new Exception(
'The value to be transformed is not an empty string');
73 return $this->
refinery->in()->series([
75 $empty_string_or_null_to_stirng_trafo,
76 $this->refinery->kindlyTo()->int(),
78 $this->
refinery->kindlyTo()->float(),
82 $this->
refinery->kindlyTo()->string()
88 return 'mail_orphaned_mails';
94 return $this->
lng->txt(
'mail_orphaned_mails');
100 return $this->
lng->txt(
'mail_orphaned_mails_desc');
116 self::SCHEDULE_TYPE_DAILY,
117 self::SCHEDULE_TYPE_WEEKLY,
118 self::SCHEDULE_TYPE_MONTHLY,
119 self::SCHEDULE_TYPE_QUARTERLY,
120 self::SCHEDULE_TYPE_YEARLY,
121 self::SCHEDULE_TYPE_IN_DAYS
127 return self::SCHEDULE_TYPE_DAILY;
144 parent::addCustomSettingsToForm($a_form);
147 $threshold->
setInfo($this->
lng->txt(
'mail_threshold_info'));
148 $threshold->allowDecimals(
false);
149 $threshold->setSuffix($this->
lng->txt(
'days'));
150 $threshold->setMinValue(1);
151 $threshold->setSize(4);
152 $threshold->setValue($this->
settings->get(
'mail_threshold',
''));
157 $this->
lng->txt(
'only_inbox_trash'),
158 'mail_only_inbox_trash' 161 $mail_folder->setInfo($this->
lng->txt(
'only_inbox_trash_info'));
162 $mail_folder->setChecked((
bool) $this->
settings->get(
'mail_only_inbox_trash',
'0'));
163 $a_form->
addItem($mail_folder);
166 $this->
lng->txt(
'mail_notify_orphaned'),
167 'mail_notify_orphaned' 169 $notification->
setInfo($this->
lng->txt(
'mail_notify_orphaned_info'));
170 $notification->allowDecimals(
false);
171 $notification->setSize(4);
172 $notification->setSuffix($this->
lng->txt(
'days'));
173 $notification->setMinValue(0);
175 if ($this->
http->wrapper()->post()->has(
'mail_threshold')) {
176 $mail_threshold = (
int) $this->
http->wrapper()->post()->retrieve(
181 $mail_threshold = (
int) $this->
settings->get(
'mail_threshold');
183 $maxvalue = $mail_threshold - 1;
184 $notification->setMaxValue($maxvalue);
185 $notification->setValue($this->
settings->get(
'mail_notify_orphaned',
''));
186 $a_form->
addItem($notification);
193 $this->
settings->set(
'mail_only_inbox_trash', (
string) ((
int) $a_form->
getInput(
'mail_only_inbox_trash')));
199 'mail_notify_orphaned',
203 if ((
int) $this->
settings->get(
'mail_notify_orphaned',
'0') === 0) {
205 $this->db->manipulate(
'DELETE FROM mail_cron_orphaned');
208 "Deleted all scheduled mail deletions " .
209 "because a reminder shouldn't be sent (login: %s|usr_id: %s) anymore!",
210 $this->
user->getLogin(),
220 $this->cron_manager->ping($this->
getId());
227 $mail_expiration_days = (
int) $this->
settings->get(
'mail_threshold',
'0');
230 'Started mail deletion job with threshold: %s day(s)',
231 var_export($mail_expiration_days,
true)
234 if ($mail_expiration_days >= 1 && (
int) $this->
settings->get(
'mail_notify_orphaned',
'0') >= 1) {
238 if ($mail_expiration_days >= 1 && (
int) $this->
settings->get(
'last_cronjob_start_ts', (
string) time())) {
244 $result->setStatus($status);
247 'Finished mail deletion job with threshold: %s day(s)',
248 var_export($mail_expiration_days,
true)
261 (
int) $this->
settings->get(
'mail_threshold',
'0'),
262 (
int) $this->
settings->get(
'mail_notify_orphaned',
'0')
272 $processor->delete();
Interface GlobalHttpState.
ilCronManager $cron_manager
static getLogger(string $a_component_id)
Get component logger.
getDefaultScheduleValue()
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
emptyStringOrFloatOrIntToEmptyOrIntegerString()
static http()
Fetches the global http state from ILIAS.
saveCustomSettings(ilPropertyFormGUI $a_form)