19 declare(strict_types=1);
49 private function init(): void
53 if (!$this->initDone) {
55 $this->
lng = $DIC->language();
56 $this->db = $DIC->database();
57 $this->
user = $DIC->user();
58 $this->
http = $DIC->http();
60 $this->cron_manager = $DIC->cron()->manager();
62 $this->
lng->loadLanguageModule(
'mail');
63 $this->initDone =
true;
69 $empty_string_or_null_to_stirng_trafo = $this->
refinery->custom()->transformation(
static function ($value):
string {
70 if ($value ===
'' ||
null === $value) {
74 throw new Exception(
'The value to be transformed is not an empty string');
77 return $this->
refinery->in()->series([
79 $empty_string_or_null_to_stirng_trafo,
80 $this->refinery->kindlyTo()->int(),
82 $this->
refinery->kindlyTo()->float(),
86 $this->
refinery->kindlyTo()->string()
92 return 'mail_orphaned_mails';
98 return $this->
lng->txt(
'mail_orphaned_mails');
104 return $this->
lng->txt(
'mail_orphaned_mails_desc');
120 JobScheduleType::DAILY,
121 JobScheduleType::WEEKLY,
122 JobScheduleType::MONTHLY,
123 JobScheduleType::QUARTERLY,
125 JobScheduleType::IN_DAYS
131 return JobScheduleType::DAILY;
148 parent::addCustomSettingsToForm($a_form);
151 $threshold->
setInfo($this->
lng->txt(
'mail_threshold_info'));
152 $threshold->allowDecimals(
false);
153 $threshold->setSuffix($this->
lng->txt(
'days'));
154 $threshold->setMinValue(1);
155 $threshold->setSize(4);
156 $threshold->setValue($this->
settings->get(
'mail_threshold',
''));
161 $this->
lng->txt(
'only_inbox_trash'),
162 'mail_only_inbox_trash' 164 $mail_folder->setValue(
'1');
165 $mail_folder->setInfo($this->
lng->txt(
'only_inbox_trash_info'));
166 $mail_folder->setChecked((
bool) $this->
settings->get(
'mail_only_inbox_trash',
'0'));
167 $a_form->
addItem($mail_folder);
170 $this->
lng->txt(
'mail_notify_orphaned'),
171 'mail_notify_orphaned' 173 $notification->
setInfo($this->
lng->txt(
'mail_notify_orphaned_info'));
174 $notification->allowDecimals(
false);
175 $notification->setSize(4);
176 $notification->setSuffix($this->
lng->txt(
'days'));
177 $notification->setMinValue(0);
179 if ($this->
http->wrapper()->post()->has(
'mail_threshold')) {
180 $mail_threshold = (
int) $this->
http->wrapper()->post()->retrieve(
185 $mail_threshold = (
int) $this->
settings->get(
'mail_threshold');
187 $maxvalue = $mail_threshold - 1;
188 $notification->setMaxValue($maxvalue);
189 $notification->setValue($this->
settings->get(
'mail_notify_orphaned',
''));
190 $a_form->
addItem($notification);
197 $this->
settings->set(
'mail_only_inbox_trash', (
string) ((
int) $a_form->
getInput(
'mail_only_inbox_trash')));
203 'mail_notify_orphaned',
207 if ((
int) $this->
settings->get(
'mail_notify_orphaned',
'0') === 0) {
209 $this->db->manipulate(
'DELETE FROM mail_cron_orphaned');
212 "Deleted all scheduled mail deletions " .
213 "because a reminder shouldn't be sent (login: %s|usr_id: %s) anymore!",
214 $this->
user->getLogin(),
224 $this->cron_manager->ping($this->
getId());
231 $mail_expiration_days = (
int) $this->
settings->get(
'mail_threshold',
'0');
234 'Started mail deletion job with threshold: %s day(s)',
235 var_export($mail_expiration_days,
true)
238 if ($mail_expiration_days >= 1 && (
int) $this->
settings->get(
'mail_notify_orphaned',
'0') >= 1) {
242 if ($mail_expiration_days >= 1 && (
int) $this->
settings->get(
'last_cronjob_start_ts', (
string) time())) {
247 $status = JobResult::STATUS_OK;
248 $result->setStatus($status);
251 'Finished mail deletion job with threshold: %s day(s)',
252 var_export($mail_expiration_days,
true)
265 (
int) $this->
settings->get(
'mail_threshold',
'0'),
266 (
int) $this->
settings->get(
'mail_notify_orphaned',
'0')
276 $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)