ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilMailCronOrphanedMails Class Reference
+ 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 $init_done = 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

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

Member Function Documentation

◆ addCustomSettingsToForm()

ilMailCronOrphanedMails::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Definition at line 139 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().

139  : void
140  {
141  $this->init();
142 
143  parent::addCustomSettingsToForm($a_form);
144 
145  $threshold = new ilNumberInputGUI($this->lng->txt('mail_threshold'), 'mail_threshold');
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', ''));
152 
153  $a_form->addItem($threshold);
154 
155  $mail_folder = new ilCheckboxInputGUI(
156  $this->lng->txt('only_inbox_trash'),
157  'mail_only_inbox_trash'
158  );
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);
163 
164  $notification = new ilNumberInputGUI(
165  $this->lng->txt('mail_notify_orphaned'),
166  'mail_notify_orphaned'
167  );
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);
173 
174  if ($this->http->wrapper()->post()->has('mail_threshold')) {
175  $mail_threshold = (int) $this->http->wrapper()->post()->retrieve(
176  'mail_threshold',
178  );
179  } else {
180  $mail_threshold = (int) $this->settings->get('mail_threshold');
181  }
182  $maxvalue = $mail_threshold - 1;
183  $notification->setMaxValue($maxvalue);
184  $notification->setValue($this->settings->get('mail_notify_orphaned', ''));
185  $a_form->addItem($notification);
186  }
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 62 of file class.ilMailCronOrphanedMails.php.

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

Referenced by addCustomSettingsToForm(), and saveCustomSettings().

63  {
64  $empty_string_or_null_to_stirng_trafo = $this->refinery->custom()->transformation(static function ($value): string {
65  if ($value === '' || $value === null) {
66  return '';
67  }
68 
69  throw new Exception('The value to be transformed is not an empty string');
70  });
71 
72  return $this->refinery->in()->series([
73  $this->refinery->byTrying([
74  $empty_string_or_null_to_stirng_trafo,
75  $this->refinery->kindlyTo()->int(),
76  $this->refinery->in()->series([
77  $this->refinery->kindlyTo()->float(),
78  $this->refinery->kindlyTo()->int()
79  ])
80  ]),
81  $this->refinery->kindlyTo()->string()
82  ]);
83  }
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 124 of file class.ilMailCronOrphanedMails.php.

125  {
126  return JobScheduleType::DAILY;
127  }

◆ getDefaultScheduleValue()

ilMailCronOrphanedMails::getDefaultScheduleValue ( )

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

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

◆ getDescription()

ilMailCronOrphanedMails::getDescription ( )

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

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

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

◆ getId()

ilMailCronOrphanedMails::getId ( )

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

Referenced by ping().

85  : string
86  {
87  return 'mail_orphaned_mails';
88  }
+ Here is the caller graph for this function:

◆ getTitle()

ilMailCronOrphanedMails::getTitle ( )

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

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

90  : string
91  {
92  $this->init();
93  return $this->lng->txt('mail_orphaned_mails');
94  }
+ Here is the call graph for this function:

◆ getValidScheduleTypes()

ilMailCronOrphanedMails::getValidScheduleTypes ( )

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

References ILIAS\Cron\Job\Schedule\YEARLY.

112  : array
113  {
114  return [
115  JobScheduleType::DAILY,
116  JobScheduleType::WEEKLY,
117  JobScheduleType::MONTHLY,
118  JobScheduleType::QUARTERLY,
120  JobScheduleType::IN_DAYS
121  ];
122  }

◆ hasAutoActivation()

ilMailCronOrphanedMails::hasAutoActivation ( )

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

102  : bool
103  {
104  return false;
105  }

◆ hasCustomSettings()

ilMailCronOrphanedMails::hasCustomSettings ( )

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

134  : bool
135  {
136  return true;
137  }

◆ hasFlexibleSchedule()

ilMailCronOrphanedMails::hasFlexibleSchedule ( )

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

107  : bool
108  {
109  return true;
110  }

◆ init()

ilMailCronOrphanedMails::init ( )
private

Definition at line 44 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().

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

◆ ping()

ilMailCronOrphanedMails::ping ( )

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

References getId().

217  : void
218  {
219  $this->cron_manager->ping($this->getId());
220  }
+ Here is the call graph for this function:

◆ processDeletion()

ilMailCronOrphanedMails::processDeletion ( )
private

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

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

Referenced by run().

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

◆ run()

ilMailCronOrphanedMails::run ( )

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

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

222  : JobResult
223  {
224  $this->init();
225 
226  $mail_expiration_days = (int) $this->settings->get('mail_threshold', '0');
227 
228  ilLoggerFactory::getLogger('mail')->info(sprintf(
229  'Started mail deletion job with threshold: %s day(s)',
230  var_export($mail_expiration_days, true)
231  ));
232 
233  if ($mail_expiration_days >= 1 && (int) $this->settings->get('mail_notify_orphaned', '0') >= 1) {
234  $this->processNotification();
235  }
236 
237  if ($mail_expiration_days >= 1 && (int) $this->settings->get('last_cronjob_start_ts', (string) time())) {
238  $this->processDeletion();
239  }
240 
241  $result = new JobResult();
242  $status = JobResult::STATUS_OK;
243  $result->setStatus($status);
244 
245  ilLoggerFactory::getLogger('mail')->info(sprintf(
246  'Finished mail deletion job with threshold: %s day(s)',
247  var_export($mail_expiration_days, true)
248  ));
249 
250  return $result;
251  }
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 188 of file class.ilMailCronOrphanedMails.php.

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

188  : bool
189  {
190  $this->init();
191 
192  $this->settings->set('mail_only_inbox_trash', (string) ((int) $a_form->getInput('mail_only_inbox_trash')));
193  $this->settings->set(
194  'mail_threshold',
195  $this->emptyStringOrFloatOrIntToEmptyOrIntegerString()->transform($a_form->getInput('mail_threshold'))
196  );
197  $this->settings->set(
198  'mail_notify_orphaned',
199  $this->emptyStringOrFloatOrIntToEmptyOrIntegerString()->transform($a_form->getInput('mail_notify_orphaned'))
200  );
201 
202  if ((int) $this->settings->get('mail_notify_orphaned', '0') === 0) {
203  //delete all mail_cron_orphaned-table entries!
204  $this->db->manipulate('DELETE FROM mail_cron_orphaned');
205 
206  ilLoggerFactory::getLogger('mail')->info(sprintf(
207  'Deleted all scheduled mail deletions ' .
208  "because a reminder shouldn't be sent (login: %s|usr_id: %s) anymore!",
209  $this->user->getLogin(),
210  $this->user->getId()
211  ));
212  }
213 
214  return true;
215  }
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 42 of file class.ilMailCronOrphanedMails.php.

◆ $db

ilDBInterface ilMailCronOrphanedMails::$db
private

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

◆ $http

GlobalHttpState ilMailCronOrphanedMails::$http
private

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

◆ $init_done

bool ilMailCronOrphanedMails::$init_done = false
private

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

◆ $lng

ilLanguage ilMailCronOrphanedMails::$lng
private

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

◆ $refinery

Refinery ilMailCronOrphanedMails::$refinery
private

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

◆ $settings

ilSetting ilMailCronOrphanedMails::$settings
private

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

◆ $user

ilObjUser ilMailCronOrphanedMails::$user
private

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


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