19 declare(strict_types=1);
44 private function init(): void
48 if (!$this->init_done) {
50 $this->
lng = $DIC->language();
51 $this->db = $DIC->database();
52 $this->
user = $DIC->user();
53 $this->
http = $DIC->http();
55 $this->cron_manager = $DIC->cron()->manager();
57 $this->
lng->loadLanguageModule(
'mail');
58 $this->init_done =
true;
64 $empty_string_or_null_to_stirng_trafo = $this->
refinery->custom()->transformation(
static function ($value):
string {
65 if ($value ===
'' || $value ===
null) {
69 throw new Exception(
'The value to be transformed is not an empty string');
72 return $this->
refinery->in()->series([
74 $empty_string_or_null_to_stirng_trafo,
75 $this->refinery->kindlyTo()->int(),
77 $this->
refinery->kindlyTo()->float(),
81 $this->
refinery->kindlyTo()->string()
87 return 'mail_orphaned_mails';
93 return $this->
lng->txt(
'mail_orphaned_mails');
99 return $this->
lng->txt(
'mail_orphaned_mails_desc');
115 JobScheduleType::DAILY,
116 JobScheduleType::WEEKLY,
117 JobScheduleType::MONTHLY,
118 JobScheduleType::QUARTERLY,
120 JobScheduleType::IN_DAYS
126 return JobScheduleType::DAILY;
143 parent::addCustomSettingsToForm($a_form);
146 $threshold->
setInfo($this->
lng->txt(
'mail_threshold_info'));
147 $threshold->allowDecimals(
false);
148 $threshold->setSuffix($this->
lng->txt(
'days'));
149 $threshold->setMinValue(1);
150 $threshold->setSize(4);
151 $threshold->setValue($this->
settings->get(
'mail_threshold',
''));
156 $this->
lng->txt(
'only_inbox_trash'),
157 'mail_only_inbox_trash' 159 $mail_folder->setValue(
'1');
160 $mail_folder->setInfo($this->
lng->txt(
'only_inbox_trash_info'));
161 $mail_folder->setChecked((
bool) $this->
settings->get(
'mail_only_inbox_trash',
'0'));
162 $a_form->
addItem($mail_folder);
165 $this->
lng->txt(
'mail_notify_orphaned'),
166 'mail_notify_orphaned' 168 $notification->
setInfo($this->
lng->txt(
'mail_notify_orphaned_info'));
169 $notification->allowDecimals(
false);
170 $notification->setSize(4);
171 $notification->setSuffix($this->
lng->txt(
'days'));
172 $notification->setMinValue(0);
174 if ($this->
http->wrapper()->post()->has(
'mail_threshold')) {
175 $mail_threshold = (
int) $this->
http->wrapper()->post()->retrieve(
180 $mail_threshold = (
int) $this->
settings->get(
'mail_threshold');
182 $maxvalue = $mail_threshold - 1;
183 $notification->setMaxValue($maxvalue);
184 $notification->setValue($this->
settings->get(
'mail_notify_orphaned',
''));
185 $a_form->
addItem($notification);
192 $this->
settings->set(
'mail_only_inbox_trash', (
string) ((
int) $a_form->
getInput(
'mail_only_inbox_trash')));
198 'mail_notify_orphaned',
202 if ((
int) $this->
settings->get(
'mail_notify_orphaned',
'0') === 0) {
204 $this->db->manipulate(
'DELETE FROM mail_cron_orphaned');
207 'Deleted all scheduled mail deletions ' .
208 "because a reminder shouldn't be sent (login: %s|usr_id: %s) anymore!",
209 $this->
user->getLogin(),
219 $this->cron_manager->ping($this->
getId());
226 $mail_expiration_days = (
int) $this->
settings->get(
'mail_threshold',
'0');
229 'Started mail deletion job with threshold: %s day(s)',
230 var_export($mail_expiration_days,
true)
233 if ($mail_expiration_days >= 1 && (
int) $this->
settings->get(
'mail_notify_orphaned',
'0') >= 1) {
237 if ($mail_expiration_days >= 1 && (
int) $this->
settings->get(
'last_cronjob_start_ts', (
string) time())) {
242 $status = JobResult::STATUS_OK;
243 $result->setStatus($status);
246 'Finished mail deletion job with threshold: %s day(s)',
247 var_export($mail_expiration_days,
true)
260 (
int) $this->
settings->get(
'mail_threshold',
'0'),
261 (
int) $this->
settings->get(
'mail_notify_orphaned',
'0')
271 $processor->delete();
static getLogger(string $a_component_id)
Get component logger.
getDefaultScheduleValue()
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
emptyStringOrFloatOrIntToEmptyOrIntegerString()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
saveCustomSettings(ilPropertyFormGUI $a_form)