ILIAS  release_8 Revision v8.24
ilMailCronOrphanedMails Class Reference

Delete orphaned mails. More...

+ Inheritance diagram for ilMailCronOrphanedMails:
+ Collaboration diagram for ilMailCronOrphanedMails:

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 ping ()
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?int $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?int $a_type, ?int $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Private Member Functions

 init ()
 
 emptyStringOrFloatOrIntToEmptyOrIntegerString ()
 
 processNotification ()
 
 processDeletion ()
 

Private Attributes

GlobalHttpState $http
 
Refinery $refinery
 
ilLanguage $lng
 
ilSetting $settings
 
ilDBInterface $db
 
ilObjUser $user
 
bool $initDone = false
 
ilCronManager $cron_manager
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
- Protected Attributes inherited from ilCronJob
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

Delete orphaned mails.

Author
Nadia Matuschek nmatu.nosp@m.sche.nosp@m.k@dat.nosp@m.abay.nosp@m..de

Definition at line 34 of file class.ilMailCronOrphanedMails.php.

Member Function Documentation

◆ addCustomSettingsToForm()

ilMailCronOrphanedMails::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Reimplemented from ilCronJob.

Definition at line 140 of file class.ilMailCronOrphanedMails.php.

140 : void
141 {
142 $this->init();
143
144 parent::addCustomSettingsToForm($a_form);
145
146 $threshold = new ilNumberInputGUI($this->lng->txt('mail_threshold'), 'mail_threshold');
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', ''));
153
154 $a_form->addItem($threshold);
155
156 $mail_folder = new ilCheckboxInputGUI(
157 $this->lng->txt('only_inbox_trash'),
158 'mail_only_inbox_trash'
159 );
160 $mail_folder->setValue('1');
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);
164
165 $notification = new ilNumberInputGUI(
166 $this->lng->txt('mail_notify_orphaned'),
167 'mail_notify_orphaned'
168 );
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);
174
175 if ($this->http->wrapper()->post()->has('mail_threshold')) {
176 $mail_threshold = (int) $this->http->wrapper()->post()->retrieve(
177 'mail_threshold',
179 );
180 } else {
181 $mail_threshold = (int) $this->settings->get('mail_threshold');
182 }
183 $maxvalue = $mail_threshold - 1;
184 $notification->setMaxValue($maxvalue);
185 $notification->setValue($this->settings->get('mail_notify_orphaned', ''));
186 $a_form->addItem($notification);
187 }
This class represents a checkbox property in a property form.
This class represents a number property in a property form.
static http()
Fetches the global http state from ILIAS.

References ilPropertyFormGUI\addItem(), emptyStringOrFloatOrIntToEmptyOrIntegerString(), ILIAS\FileDelivery\http(), init(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ emptyStringOrFloatOrIntToEmptyOrIntegerString()

ilMailCronOrphanedMails::emptyStringOrFloatOrIntToEmptyOrIntegerString ( )
private

Definition at line 63 of file class.ilMailCronOrphanedMails.php.

64 {
65 $empty_string_or_null_to_stirng_trafo = $this->refinery->custom()->transformation(static function ($value): string {
66 if ($value === '' || null === $value) {
67 return '';
68 }
69
70 throw new Exception('The value to be transformed is not an empty string');
71 });
72
73 return $this->refinery->in()->series([
74 $this->refinery->byTrying([
75 $empty_string_or_null_to_stirng_trafo,
76 $this->refinery->kindlyTo()->int(),
77 $this->refinery->in()->series([
78 $this->refinery->kindlyTo()->float(),
79 $this->refinery->kindlyTo()->int()
80 ])
81 ]),
82 $this->refinery->kindlyTo()->string()
83 ]);
84 }
A transformation is a function from one datatype to another.

References ILIAS\Repository\refinery().

Referenced by addCustomSettingsToForm(), and saveCustomSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilMailCronOrphanedMails::getDefaultScheduleType ( )

Reimplemented from ilCronJob.

Definition at line 125 of file class.ilMailCronOrphanedMails.php.

125 : int
126 {
128 }
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilMailCronOrphanedMails::getDefaultScheduleValue ( )

Reimplemented from ilCronJob.

Definition at line 130 of file class.ilMailCronOrphanedMails.php.

130 : ?int
131 {
132 return 1;
133 }

◆ getDescription()

ilMailCronOrphanedMails::getDescription ( )

Reimplemented from ilCronJob.

Definition at line 97 of file class.ilMailCronOrphanedMails.php.

97 : string
98 {
99 $this->init();
100 return $this->lng->txt('mail_orphaned_mails_desc');
101 }

References init(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilMailCronOrphanedMails::getId ( )

Reimplemented from ilCronJob.

Definition at line 86 of file class.ilMailCronOrphanedMails.php.

86 : string
87 {
88 return 'mail_orphaned_mails';
89 }

Referenced by ping().

+ Here is the caller graph for this function:

◆ getTitle()

ilMailCronOrphanedMails::getTitle ( )

Reimplemented from ilCronJob.

Definition at line 91 of file class.ilMailCronOrphanedMails.php.

91 : string
92 {
93 $this->init();
94 return $this->lng->txt('mail_orphaned_mails');
95 }

References init(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getValidScheduleTypes()

ilMailCronOrphanedMails::getValidScheduleTypes ( )

Returns a collection of all valid schedule types for a specific job.

Returns
int[]

Reimplemented from ilCronJob.

Definition at line 113 of file class.ilMailCronOrphanedMails.php.

113 : array
114 {
115 return [
122 ];
123 }
const SCHEDULE_TYPE_IN_DAYS
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_WEEKLY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_YEARLY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_QUARTERLY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_MONTHLY
@depracated This will be replaced with an ENUM in ILIAS 9

References ilCronJob\SCHEDULE_TYPE_DAILY, ilCronJob\SCHEDULE_TYPE_IN_DAYS, ilCronJob\SCHEDULE_TYPE_MONTHLY, ilCronJob\SCHEDULE_TYPE_QUARTERLY, ilCronJob\SCHEDULE_TYPE_WEEKLY, and ilCronJob\SCHEDULE_TYPE_YEARLY.

◆ hasAutoActivation()

ilMailCronOrphanedMails::hasAutoActivation ( )

Is to be activated on "installation", does only work for ILIAS core cron jobs.

Reimplemented from ilCronJob.

Definition at line 103 of file class.ilMailCronOrphanedMails.php.

103 : bool
104 {
105 return false;
106 }

◆ hasCustomSettings()

ilMailCronOrphanedMails::hasCustomSettings ( )

Reimplemented from ilCronJob.

Definition at line 135 of file class.ilMailCronOrphanedMails.php.

135 : bool
136 {
137 return true;
138 }

◆ hasFlexibleSchedule()

ilMailCronOrphanedMails::hasFlexibleSchedule ( )

Reimplemented from ilCronJob.

Definition at line 108 of file class.ilMailCronOrphanedMails.php.

108 : bool
109 {
110 return true;
111 }

◆ init()

ilMailCronOrphanedMails::init ( )
private

Definition at line 45 of file class.ilMailCronOrphanedMails.php.

45 : void
46 {
47 global $DIC;
48
49 if (!$this->initDone) {
50 $this->settings = $DIC->settings();
51 $this->lng = $DIC->language();
52 $this->db = $DIC->database();
53 $this->user = $DIC->user();
54 $this->http = $DIC->http();
55 $this->refinery = $DIC->refinery();
56 $this->cron_manager = $DIC->cron()->manager();
57
58 $this->lng->loadLanguageModule('mail');
59 $this->initDone = true;
60 }
61 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\settings(), and ILIAS\Repository\user().

Referenced by addCustomSettingsToForm(), getDescription(), getTitle(), processDeletion(), processNotification(), run(), and saveCustomSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ping()

ilMailCronOrphanedMails::ping ( )

Definition at line 218 of file class.ilMailCronOrphanedMails.php.

218 : void
219 {
220 $this->cron_manager->ping($this->getId());
221 }

References getId().

+ Here is the call graph for this function:

◆ processDeletion()

ilMailCronOrphanedMails::processDeletion ( )
private

Definition at line 267 of file class.ilMailCronOrphanedMails.php.

References init().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processNotification()

ilMailCronOrphanedMails::processNotification ( )
private

Definition at line 254 of file class.ilMailCronOrphanedMails.php.

254 : void
255 {
256 $this->init();
257
258 $notifier = new Notifier(
259 $this,
260 new NotificationsCollector($this),
261 (int) $this->settings->get('mail_threshold', '0'),
262 (int) $this->settings->get('mail_notify_orphaned', '0')
263 );
264 $notifier->send();
265 }

References init(), and ILIAS\Repository\settings().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilMailCronOrphanedMails::run ( )

Reimplemented from ilCronJob.

Definition at line 223 of file class.ilMailCronOrphanedMails.php.

224 {
225 $this->init();
226
227 $mail_expiration_days = (int) $this->settings->get('mail_threshold', '0');
228
229 ilLoggerFactory::getLogger('mail')->info(sprintf(
230 'Started mail deletion job with threshold: %s day(s)',
231 var_export($mail_expiration_days, true)
232 ));
233
234 if ($mail_expiration_days >= 1 && (int) $this->settings->get('mail_notify_orphaned', '0') >= 1) {
235 $this->processNotification();
236 }
237
238 if ($mail_expiration_days >= 1 && (int) $this->settings->get('last_cronjob_start_ts', (string) time())) {
239 $this->processDeletion();
240 }
241
242 $result = new ilCronJobResult();
244 $result->setStatus($status);
245
246 ilLoggerFactory::getLogger('mail')->info(sprintf(
247 'Finished mail deletion job with threshold: %s day(s)',
248 var_export($mail_expiration_days, true)
249 ));
250
251 return $result;
252 }
static getLogger(string $a_component_id)
Get component logger.

References ilLoggerFactory\getLogger(), init(), ILIAS\Repository\int(), processDeletion(), processNotification(), ILIAS\Repository\settings(), and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

◆ saveCustomSettings()

ilMailCronOrphanedMails::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Reimplemented from ilCronJob.

Definition at line 189 of file class.ilMailCronOrphanedMails.php.

189 : bool
190 {
191 $this->init();
192
193 $this->settings->set('mail_only_inbox_trash', (string) ((int) $a_form->getInput('mail_only_inbox_trash')));
194 $this->settings->set(
195 'mail_threshold',
196 $this->emptyStringOrFloatOrIntToEmptyOrIntegerString()->transform($a_form->getInput('mail_threshold'))
197 );
198 $this->settings->set(
199 'mail_notify_orphaned',
200 $this->emptyStringOrFloatOrIntToEmptyOrIntegerString()->transform($a_form->getInput('mail_notify_orphaned'))
201 );
202
203 if ((int) $this->settings->get('mail_notify_orphaned', '0') === 0) {
204 //delete all mail_cron_orphaned-table entries!
205 $this->db->manipulate('DELETE FROM mail_cron_orphaned');
206
207 ilLoggerFactory::getLogger('mail')->info(sprintf(
208 "Deleted all scheduled mail deletions " .
209 "because a reminder shouldn't be sent (login: %s|usr_id: %s) anymore!",
210 $this->user->getLogin(),
211 $this->user->getId()
212 ));
213 }
214
215 return true;
216 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

References emptyStringOrFloatOrIntToEmptyOrIntegerString(), ilPropertyFormGUI\getInput(), ilLoggerFactory\getLogger(), init(), ILIAS\Repository\settings(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $cron_manager

ilCronManager ilMailCronOrphanedMails::$cron_manager
private

Definition at line 43 of file class.ilMailCronOrphanedMails.php.

◆ $db

ilDBInterface ilMailCronOrphanedMails::$db
private

Definition at line 40 of file class.ilMailCronOrphanedMails.php.

◆ $http

GlobalHttpState ilMailCronOrphanedMails::$http
private

Definition at line 36 of file class.ilMailCronOrphanedMails.php.

◆ $initDone

bool ilMailCronOrphanedMails::$initDone = false
private

Definition at line 42 of file class.ilMailCronOrphanedMails.php.

◆ $lng

ilLanguage ilMailCronOrphanedMails::$lng
private

Definition at line 38 of file class.ilMailCronOrphanedMails.php.

◆ $refinery

Refinery ilMailCronOrphanedMails::$refinery
private

Definition at line 37 of file class.ilMailCronOrphanedMails.php.

◆ $settings

ilSetting ilMailCronOrphanedMails::$settings
private

Definition at line 39 of file class.ilMailCronOrphanedMails.php.

◆ $user

ilObjUser ilMailCronOrphanedMails::$user
private

Definition at line 41 of file class.ilMailCronOrphanedMails.php.


The documentation for this class was generated from the following file: