ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailCronOrphanedMails Class Reference

Delete orphaned mails. More...

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

Public Member Functions

 getId ()
 Get id. More...
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getValidScheduleTypes ()
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 run ()
 Run job. More...
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $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...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Protected Member Functions

 init ()
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Protected Attributes

 $lng
 
 $settings
 
 $db
 
 $user
 
 $initDone = false
 

Private Member Functions

 processNotification ()
 
 processDeletion ()
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

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 14 of file class.ilMailCronOrphanedMails.php.

Member Function Documentation

◆ addCustomSettingsToForm()

ilMailCronOrphanedMails::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)
Parameters
ilPropertyFormGUI$a_form

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

References $_POST, ilPropertyFormGUI\addItem(), init(), ilFormPropertyGUI\setInfo(), and settings().

149  {
150  $this->init();
151  parent::addCustomSettingsToForm($a_form);
152 
153  $threshold = new ilNumberInputGUI($this->lng->txt('mail_threshold'), 'mail_threshold');
154  $threshold->setInfo($this->lng->txt('mail_threshold_info'));
155  $threshold->allowDecimals(false);
156  $threshold->setSuffix($this->lng->txt('days'));
157  $threshold->setMinValue(1);
158  $threshold->setValue($this->settings->get('mail_threshold'));
159 
160  $a_form->addItem($threshold);
161 
162  $mail_folder = new ilCheckboxInputGUI($this->lng->txt('only_inbox_trash'), 'mail_only_inbox_trash');
163  $mail_folder->setInfo($this->lng->txt('only_inbox_trash_info'));
164  $mail_folder->setChecked($this->settings->get('mail_only_inbox_trash'));
165  $a_form->addItem($mail_folder);
166 
167  $notification = new ilNumberInputGUI($this->lng->txt('mail_notify_orphaned'), 'mail_notify_orphaned');
168  $notification->setInfo($this->lng->txt('mail_notify_orphaned_info'));
169  $notification->allowDecimals(false);
170  $notification->setSuffix($this->lng->txt('days'));
171  $notification->setMinValue(0);
172 
173  $mail_threshold = isset($_POST['mail_threshold']) ? (int) $_POST['mail_threshold'] : $this->settings->get('mail_threshold');
174  $maxvalue = $mail_threshold - 1;
175  $notification->setMaxValue($maxvalue);
176  $notification->setValue($this->settings->get('mail_notify_orphaned'));
177  $a_form->addItem($notification);
178  }
settings()
Definition: settings.php:2
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
This class represents a number property in a property form.
$_POST["username"]
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilMailCronOrphanedMails::getDefaultScheduleType ( )

Get schedule type.

Returns
int

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

124  {
125  return self::SCHEDULE_TYPE_DAILY;
126  }

◆ getDefaultScheduleValue()

ilMailCronOrphanedMails::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

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

133  {
134  return 1;
135  }

◆ getDescription()

ilMailCronOrphanedMails::getDescription ( )
Returns
string

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

References init().

81  {
82  $this->init();
83  return $this->lng->txt("mail_orphaned_mails_desc");
84  }
+ Here is the call graph for this function:

◆ getId()

ilMailCronOrphanedMails::getId ( )

Get id.

Returns
string

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

64  {
65  return "mail_orphaned_mails";
66  }

◆ getTitle()

ilMailCronOrphanedMails::getTitle ( )
Returns
string

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

References init().

72  {
73  $this->init();
74  return $this->lng->txt("mail_orphaned_mails");
75  }
+ Here is the call graph for this function:

◆ getValidScheduleTypes()

ilMailCronOrphanedMails::getValidScheduleTypes ( )

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

108  {
109  return array(
110  self::SCHEDULE_TYPE_DAILY,
111  self::SCHEDULE_TYPE_WEEKLY,
112  self::SCHEDULE_TYPE_MONTHLY,
113  self::SCHEDULE_TYPE_QUARTERLY,
114  self::SCHEDULE_TYPE_YEARLY,
115  self::SCHEDULE_TYPE_IN_DAYS
116  );
117  }

◆ hasAutoActivation()

ilMailCronOrphanedMails::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

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

91  {
92  return false;
93  }

◆ hasCustomSettings()

ilMailCronOrphanedMails::hasCustomSettings ( )
Returns
bool

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

141  {
142  return true;
143  }

◆ hasFlexibleSchedule()

ilMailCronOrphanedMails::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

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

100  {
101  return true;
102  }

◆ init()

ilMailCronOrphanedMails::init ( )
protected

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

References $DIC, settings(), and user().

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

45  {
46  global $DIC;
47 
48  if (!$this->initDone) {
49  $this->settings = $DIC->settings();
50  $this->lng = $DIC->language();
51  $this->db = $DIC->database();
52  $this->user = $DIC->user();
53 
54  $this->lng->loadLanguageModule('mail');
55  $this->initDone = true;
56  }
57  }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processDeletion()

ilMailCronOrphanedMails::processDeletion ( )
private

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

References init().

Referenced by run().

255  {
256  $this->init();
257  include_once './Services/Mail/classes/class.ilMailCronOrphanedMailsDeletionCollector.php';
258  $collector = new ilMailCronOrphanedMailsDeletionCollector();
259 
260  include_once './Services/Mail/classes/class.ilMailCronOrphanedMailsDeletionProcessor.php';
261  $processor = new ilMailCronOrphanedMailsDeletionProcessor($collector);
262  $processor->processDeletion();
263  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processNotification()

ilMailCronOrphanedMails::processNotification ( )
private

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

References init(), ilMailCronOrphanedMailsNotifier\processNotification(), and settings().

Referenced by run().

240  {
241  $this->init();
242  include_once './Services/Mail/classes/class.ilMailCronOrphanedMailsNotificationCollector.php';
244 
245  include_once'./Services/Mail/classes/class.ilMailCronOrphanedMailsNotifier.php';
246  $notifier = new ilMailCronOrphanedMailsNotifier(
247  $collector,
248  (int) $this->settings->get('mail_threshold'),
249  (int) $this->settings->get('mail_notify_orphaned')
250  );
251  $notifier->processNotification();
252  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilMailCronOrphanedMails::run ( )

Run job.

Returns
ilCronJobResult

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

References $result, ilLoggerFactory\getLogger(), init(), processDeletion(), processNotification(), settings(), and ilCronJobResult\STATUS_OK.

210  {
211  $this->init();
212  $mail_threshold = (int) $this->settings->get('mail_threshold');
213 
214  ilLoggerFactory::getLogger('mail')->info(sprintf(
215  'Started mail deletion job with threshold: %s day(s)',
216  var_export($mail_threshold, 1)
217  ));
218 
219  if ((int) $this->settings->get('mail_notify_orphaned') >= 1 && $mail_threshold >= 1) {
220  $this->processNotification();
221  }
222 
223  if ((int) $this->settings->get('last_cronjob_start_ts', time()) && $mail_threshold >= 1) {
224  $this->processDeletion();
225  }
226 
227  $result = new ilCronJobResult();
228  $status = ilCronJobResult::STATUS_OK;
229  $result->setStatus($status);
230 
231  ilLoggerFactory::getLogger('mail')->info(sprintf(
232  'Finished mail deletion job with threshold: %s day(s)',
233  var_export($mail_threshold, 1)
234  ));
235 
236  return $result;
237  }
settings()
Definition: settings.php:2
$result
static getLogger($a_component_id)
Get component logger.
Cron job result data container.
+ Here is the call graph for this function:

◆ saveCustomSettings()

ilMailCronOrphanedMails::saveCustomSettings ( ilPropertyFormGUI  $a_form)
Parameters
ilPropertyFormGUI$a_form
Returns
bool

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

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

185  {
186  $this->init();
187  $this->settings->set('mail_threshold', (int) $a_form->getInput('mail_threshold'));
188  $this->settings->set('mail_only_inbox_trash', (int) $a_form->getInput('mail_only_inbox_trash'));
189  $this->settings->set('mail_notify_orphaned', (int) $a_form->getInput('mail_notify_orphaned'));
190 
191  if ($this->settings->get('mail_notify_orphaned') == 0) {
192  //delete all mail_cron_orphaned-table entries!
193  $this->db->manipulate('DELETE FROM mail_cron_orphaned');
194 
195  ilLoggerFactory::getLogger('mail')->info(sprintf(
196  "Deleted all scheduled mail deletions because a reminder should't be sent (login: %s|usr_id: %s) anymore!",
197  $this->user->getLogin(),
198  $this->user->getId()
199  ));
200  }
201 
202  return true;
203  }
settings()
Definition: settings.php:2
user()
Definition: user.php:4
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilMailCronOrphanedMails::$db
protected

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

◆ $initDone

ilMailCronOrphanedMails::$initDone = false
protected

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

◆ $lng

ilMailCronOrphanedMails::$lng
protected

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

◆ $settings

ilMailCronOrphanedMails::$settings
protected

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

◆ $user

ilMailCronOrphanedMails::$user
protected

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


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