ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMailCronOrphanedMails Class Reference

Delete orphaned mails. More...

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

Public Member Functions

 __construct ()
 
 getId ()
 Get id. More...
 
 getTitle ()
 
 getDescription ()
 
 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...
 
 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...
 
 getValidScheduleTypes ()
 Get all available schedule types. 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...
 

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
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

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.

Constructor & Destructor Documentation

◆ __construct()

ilMailCronOrphanedMails::__construct ( )

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

References $lng.

20  {
21  global $lng;
22  $lng->loadLanguageModule('mail');
23  }
global $lng
Definition: privfeed.php:17

Member Function Documentation

◆ addCustomSettingsToForm()

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

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

References $_POST, $ilSetting, $lng, ilPropertyFormGUI\addItem(), and ilFormPropertyGUI\setInfo().

100  {
101  global $ilSetting, $lng;
102 
103  parent::addCustomSettingsToForm($a_form);
104 
105  $threshold = new ilNumberInputGUI($lng->txt('mail_threshold'), 'mail_threshold');
106  $threshold->setInfo($lng->txt('mail_threshold_info'));
107  $threshold->allowDecimals(false);
108  $threshold->setSuffix($lng->txt('days'));
109  $threshold->setMinValue(1);
110  $threshold->setValue($ilSetting->get('mail_threshold'));
111 
112  $a_form->addItem($threshold);
113 
114  $mail_folder = new ilCheckboxInputGUI($lng->txt('only_inbox_trash'), 'mail_only_inbox_trash');
115  $mail_folder->setInfo($lng->txt('only_inbox_trash_info'));
116  $mail_folder->setChecked($ilSetting->get('mail_only_inbox_trash'));
117  $a_form->addItem($mail_folder);
118 
119  $notification = new ilNumberInputGUI($lng->txt('mail_notify_orphaned'), 'mail_notify_orphaned');
120  $notification->setInfo($lng->txt('mail_notify_orphaned_info'));
121  $notification->allowDecimals(false);
122  $notification->setSuffix($lng->txt('days'));
123  $notification->setMinValue(0);
124 
125  $mail_threshold = isset($_POST['mail_threshold']) ? (int)$_POST['mail_threshold'] : $ilSetting->get('mail_threshold');
126  $maxvalue = $mail_threshold-1;
127  $notification->setMaxValue($maxvalue);
128  $notification->setValue($ilSetting->get('mail_notify_orphaned'));
129  $a_form->addItem($notification);
130  }
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.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
$_POST["username"]
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilMailCronOrphanedMails::getDefaultScheduleType ( )

Get schedule type.

Returns
int

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

75  {
76  return self::SCHEDULE_TYPE_DAILY;
77  }

◆ getDefaultScheduleValue()

ilMailCronOrphanedMails::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

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

84  {
85  return;
86  }

◆ getDescription()

ilMailCronOrphanedMails::getDescription ( )
Returns
string

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

References $lng.

47  {
48  global $lng;
49  return $lng->txt("mail_orphaned_mails_desc");
50  }
global $lng
Definition: privfeed.php:17

◆ getId()

ilMailCronOrphanedMails::getId ( )

Get id.

Returns
string

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

30  {
31  return "mail_orphaned_mails";
32  }

◆ getTitle()

ilMailCronOrphanedMails::getTitle ( )
Returns
string

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

References $lng.

38  {
39  global $lng;
40  return $lng->txt("mail_orphaned_mails");
41  }
global $lng
Definition: privfeed.php:17

◆ hasAutoActivation()

ilMailCronOrphanedMails::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

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

57  {
58  return false;
59  }

◆ hasCustomSettings()

ilMailCronOrphanedMails::hasCustomSettings ( )
Returns
bool

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

92  {
93  return true;
94  }

◆ hasFlexibleSchedule()

ilMailCronOrphanedMails::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

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

66  {
67  return false;
68  }

◆ processDeletion()

ilMailCronOrphanedMails::processDeletion ( )
private

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

Referenced by run().

204  {
205  include_once './Services/Mail/classes/class.ilMailCronOrphanedMailsDeletionCollector.php';
206  $collector = new ilMailCronOrphanedMailsDeletionCollector();
207 
208  include_once './Services/Mail/classes/class.ilMailCronOrphanedMailsDeletionProcessor.php';
209  $processor = new ilMailCronOrphanedMailsDeletionProcessor($collector);
210  $processor->processDeletion();
211  }
+ Here is the caller graph for this function:

◆ processNotification()

ilMailCronOrphanedMails::processNotification ( )
private

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

Referenced by run().

194  {
195  include_once './Services/Mail/classes/class.ilMailCronOrphanedMailsNotificationCollector.php';
197 
198  include_once'./Services/Mail/classes/class.ilMailCronOrphanedMailsNotifier.php';
199  $notifier = new ilMailCronOrphanedMailsNotifier($collector);
200  $notifier->processNotification();
201  }
+ Here is the caller graph for this function:

◆ run()

ilMailCronOrphanedMails::run ( )

Run job.

Returns
ilCronJobResult

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

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

163  {
164  global $ilSetting;
165 
166  $mail_threshold = (int)$ilSetting->get('mail_threshold');
167 
168  ilLoggerFactory::getLogger('mail')->info(sprintf(
169  'Started mail deletion job with threshold: %s day(s)', var_export($mail_threshold, 1)
170  ));
171 
172  if((int)$ilSetting->get('mail_notify_orphaned') >= 1 && $mail_threshold >= 1)
173  {
174  $this->processNotification();
175  }
176 
177  if((int)$ilSetting->get('last_cronjob_start_ts') && $mail_threshold >= 1)
178  {
179  $this->processDeletion();
180  }
181 
182  $result = new ilCronJobResult();
183  $status = ilCronJobResult::STATUS_OK;
184  $result->setStatus($status);
185 
186  ilLoggerFactory::getLogger('mail')->info(sprintf(
187  'Finished mail deletion job with threshold: %s day(s)', var_export($mail_threshold, 1)
188  ));
189 
190  return $result;
191  }
$result
global $ilSetting
Definition: privfeed.php:17
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 136 of file class.ilMailCronOrphanedMails.php.

References $ilDB, $ilSetting, $ilUser, ilPropertyFormGUI\getInput(), and ilLoggerFactory\getLogger().

137  {
138  global $ilSetting, $ilUser;
139 
140  $ilSetting->set('mail_threshold', (int)$a_form->getInput('mail_threshold'));
141  $ilSetting->set('mail_only_inbox_trash', (int)$a_form->getInput('mail_only_inbox_trash'));
142  $ilSetting->set('mail_notify_orphaned', (int)$a_form->getInput('mail_notify_orphaned'));
143 
144  if($ilSetting->get('mail_notify_orphaned') == 0)
145  {
146  global $ilDB;
147  //delete all mail_cron_orphaned-table entries!
148  $ilDB->manipulate('DELETE FROM mail_cron_orphaned');
149 
150  ilLoggerFactory::getLogger('mail')->info(sprintf(
151  "Deleted all scheduled mail deletions because a reminder should't be sent (login: %s|usr_id: %s) anymore!", $ilUser->getLogin(), $ilUser->getId()
152  ));
153  }
154 
155  return true;
156  }
$ilUser
Definition: imgupload.php:18
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
global $ilSetting
Definition: privfeed.php:17
global $ilDB
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

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