ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailCronOrphanedMails Class Reference

Delete orphaned mails. More...

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

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 getValidScheduleTypes ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 ping ()
 
 run ()
 
- Public Member Functions inherited from ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $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 (?JobScheduleType $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 ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 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
 
JobManager $cron_manager
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $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 38 of file class.ilMailCronOrphanedMails.php.

Member Function Documentation

◆ addCustomSettingsToForm()

ilMailCronOrphanedMails::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

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

144  : void
145  {
146  $this->init();
147 
148  parent::addCustomSettingsToForm($a_form);
149 
150  $threshold = new ilNumberInputGUI($this->lng->txt('mail_threshold'), 'mail_threshold');
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', ''));
157 
158  $a_form->addItem($threshold);
159 
160  $mail_folder = new ilCheckboxInputGUI(
161  $this->lng->txt('only_inbox_trash'),
162  'mail_only_inbox_trash'
163  );
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);
168 
169  $notification = new ilNumberInputGUI(
170  $this->lng->txt('mail_notify_orphaned'),
171  'mail_notify_orphaned'
172  );
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);
178 
179  if ($this->http->wrapper()->post()->has('mail_threshold')) {
180  $mail_threshold = (int) $this->http->wrapper()->post()->retrieve(
181  'mail_threshold',
183  );
184  } else {
185  $mail_threshold = (int) $this->settings->get('mail_threshold');
186  }
187  $maxvalue = $mail_threshold - 1;
188  $notification->setMaxValue($maxvalue);
189  $notification->setValue($this->settings->get('mail_notify_orphaned', ''));
190  $a_form->addItem($notification);
191  }
static http()
Fetches the global http state from ILIAS.
This class represents a number property in a property form.
+ Here is the call graph for this function:

◆ emptyStringOrFloatOrIntToEmptyOrIntegerString()

ilMailCronOrphanedMails::emptyStringOrFloatOrIntToEmptyOrIntegerString ( )
private

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

References null, and ILIAS\Repository\refinery().

Referenced by addCustomSettingsToForm(), and saveCustomSettings().

68  {
69  $empty_string_or_null_to_stirng_trafo = $this->refinery->custom()->transformation(static function ($value): string {
70  if ($value === '' || null === $value) {
71  return '';
72  }
73 
74  throw new Exception('The value to be transformed is not an empty string');
75  });
76 
77  return $this->refinery->in()->series([
78  $this->refinery->byTrying([
79  $empty_string_or_null_to_stirng_trafo,
80  $this->refinery->kindlyTo()->int(),
81  $this->refinery->in()->series([
82  $this->refinery->kindlyTo()->float(),
83  $this->refinery->kindlyTo()->int()
84  ])
85  ]),
86  $this->refinery->kindlyTo()->string()
87  ]);
88  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
A transformation is a function from one datatype to another.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilMailCronOrphanedMails::getDefaultScheduleType ( )

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

130  {
131  return JobScheduleType::DAILY;
132  }

◆ getDefaultScheduleValue()

ilMailCronOrphanedMails::getDefaultScheduleValue ( )

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

134  : ?int
135  {
136  return 1;
137  }

◆ getDescription()

ilMailCronOrphanedMails::getDescription ( )

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

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

101  : string
102  {
103  $this->init();
104  return $this->lng->txt('mail_orphaned_mails_desc');
105  }
+ Here is the call graph for this function:

◆ getId()

ilMailCronOrphanedMails::getId ( )

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

Referenced by ping().

90  : string
91  {
92  return 'mail_orphaned_mails';
93  }
+ Here is the caller graph for this function:

◆ getTitle()

ilMailCronOrphanedMails::getTitle ( )

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

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

95  : string
96  {
97  $this->init();
98  return $this->lng->txt('mail_orphaned_mails');
99  }
+ Here is the call graph for this function:

◆ getValidScheduleTypes()

ilMailCronOrphanedMails::getValidScheduleTypes ( )

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

References ILIAS\Cron\Job\Schedule\YEARLY.

117  : array
118  {
119  return [
120  JobScheduleType::DAILY,
121  JobScheduleType::WEEKLY,
122  JobScheduleType::MONTHLY,
123  JobScheduleType::QUARTERLY,
125  JobScheduleType::IN_DAYS
126  ];
127  }

◆ hasAutoActivation()

ilMailCronOrphanedMails::hasAutoActivation ( )

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

107  : bool
108  {
109  return false;
110  }

◆ hasCustomSettings()

ilMailCronOrphanedMails::hasCustomSettings ( )

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

139  : bool
140  {
141  return true;
142  }

◆ hasFlexibleSchedule()

ilMailCronOrphanedMails::hasFlexibleSchedule ( )

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

112  : bool
113  {
114  return true;
115  }

◆ init()

ilMailCronOrphanedMails::init ( )
private

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

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().

49  : void
50  {
51  global $DIC;
52 
53  if (!$this->initDone) {
54  $this->settings = $DIC->settings();
55  $this->lng = $DIC->language();
56  $this->db = $DIC->database();
57  $this->user = $DIC->user();
58  $this->http = $DIC->http();
59  $this->refinery = $DIC->refinery();
60  $this->cron_manager = $DIC->cron()->manager();
61 
62  $this->lng->loadLanguageModule('mail');
63  $this->initDone = true;
64  }
65  }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ping()

ilMailCronOrphanedMails::ping ( )

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

References getId().

222  : void
223  {
224  $this->cron_manager->ping($this->getId());
225  }
+ Here is the call graph for this function:

◆ processDeletion()

ilMailCronOrphanedMails::processDeletion ( )
private

Definition at line 271 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 258 of file class.ilMailCronOrphanedMails.php.

References init(), ILIAS\Repository\int(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier\send(), and ILIAS\Repository\settings().

Referenced by run().

258  : void
259  {
260  $this->init();
261 
262  $notifier = new Notifier(
263  $this,
264  new NotificationsCollector($this),
265  (int) $this->settings->get('mail_threshold', '0'),
266  (int) $this->settings->get('mail_notify_orphaned', '0')
267  );
268  $notifier->send();
269  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilMailCronOrphanedMails::run ( )

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

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

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

◆ saveCustomSettings()

ilMailCronOrphanedMails::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

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

193  : bool
194  {
195  $this->init();
196 
197  $this->settings->set('mail_only_inbox_trash', (string) ((int) $a_form->getInput('mail_only_inbox_trash')));
198  $this->settings->set(
199  'mail_threshold',
200  $this->emptyStringOrFloatOrIntToEmptyOrIntegerString()->transform($a_form->getInput('mail_threshold'))
201  );
202  $this->settings->set(
203  'mail_notify_orphaned',
204  $this->emptyStringOrFloatOrIntToEmptyOrIntegerString()->transform($a_form->getInput('mail_notify_orphaned'))
205  );
206 
207  if ((int) $this->settings->get('mail_notify_orphaned', '0') === 0) {
208  //delete all mail_cron_orphaned-table entries!
209  $this->db->manipulate('DELETE FROM mail_cron_orphaned');
210 
211  ilLoggerFactory::getLogger('mail')->info(sprintf(
212  "Deleted all scheduled mail deletions " .
213  "because a reminder shouldn't be sent (login: %s|usr_id: %s) anymore!",
214  $this->user->getLogin(),
215  $this->user->getId()
216  ));
217  }
218 
219  return true;
220  }
static getLogger(string $a_component_id)
Get component logger.
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-...
+ Here is the call graph for this function:

Field Documentation

◆ $cron_manager

JobManager ilMailCronOrphanedMails::$cron_manager
private

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

◆ $db

ilDBInterface ilMailCronOrphanedMails::$db
private

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

◆ $http

GlobalHttpState ilMailCronOrphanedMails::$http
private

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

◆ $initDone

bool ilMailCronOrphanedMails::$initDone = false
private

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

◆ $lng

ilLanguage ilMailCronOrphanedMails::$lng
private

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

◆ $refinery

Refinery ilMailCronOrphanedMails::$refinery
private

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

◆ $settings

ilSetting ilMailCronOrphanedMails::$settings
private

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

◆ $user

ilObjUser ilMailCronOrphanedMails::$user
private

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


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