ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCronDeleteInactiveUserAccounts Class Reference
+ Inheritance diagram for ilCronDeleteInactiveUserAccounts:
+ Collaboration diagram for ilCronDeleteInactiveUserAccounts:

Public Member Functions

 __construct ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
- 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...
 

Data Fields

const DEFAULT_INACTIVITY_PERIOD = 365
 
const DEFAULT_REMINDER_PERIOD = 0
 
- 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

 getTimeDifferenceBySchedule ($schedule_time, $multiplier)
 
 calculateDeletionData ($date_for_deletion)
 
 isDecimal ($number)
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Private Attributes

 $period = null
 
 $reminderTimer = null
 
 $include_roles = null
 

Detailed Description

Definition at line 17 of file class.ilCronDeleteInactiveUserAccounts.php.

Constructor & Destructor Documentation

◆ __construct()

ilCronDeleteInactiveUserAccounts::__construct ( )

Definition at line 26 of file class.ilCronDeleteInactiveUserAccounts.php.

References $DIC, and $ilSetting.

27  {
28  global $DIC;
29 
30  $ilSetting = $DIC['ilSetting'];
31 
32  if (is_object($ilSetting)) {
33  $this->include_roles = $ilSetting->get(
34  'cron_inactive_user_delete_include_roles',
35  null
36  );
37  if ($this->include_roles === null) {
38  $this->include_roles = array();
39  } else {
40  $this->include_roles = explode(',', $this->include_roles);
41  }
42 
43  $this->period = $ilSetting->get(
44  'cron_inactive_user_delete_period',
45  self::DEFAULT_INACTIVITY_PERIOD
46  );
47  $this->reminderTimer = $ilSetting->get(
48  'cron_inactive_user_reminder_period',
49  self::DEFAULT_REMINDER_PERIOD
50  );
51  }
52  }
global $DIC
Definition: saml.php:7
global $ilSetting
Definition: privfeed.php:17

Member Function Documentation

◆ addCustomSettingsToForm()

ilCronDeleteInactiveUserAccounts::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Definition at line 219 of file class.ilCronDeleteInactiveUserAccounts.php.

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

220  {
221  global $DIC;
222 
223  $lng = $DIC['lng'];
224  $rbacreview = $DIC['rbacreview'];
225  $ilObjDataCache = $DIC['ilObjDataCache'];
226  $ilSetting = $DIC['ilSetting'];
227  $lng->loadLanguageModule("user");
228 
229  $schedule = $a_form->getItemByPostVar('type');
230  $schedule->setTitle(
231  $lng->txt('delete_inactive_user_accounts_frequency'),
232  'delete_inactive_user_accounts_frequency'
233  );
234  $schedule->setInfo(
235  $lng->txt('delete_inactive_user_accounts_frequency_desc'),
236  'delete_inactive_user_accounts_frequency_desc'
237  );
238 
239  include_once('Services/Form/classes/class.ilMultiSelectInputGUI.php');
240  $sub_mlist = new ilMultiSelectInputGUI(
241  $lng->txt('delete_inactive_user_accounts_include_roles'),
242  'cron_inactive_user_delete_include_roles'
243  );
244  $sub_mlist->setInfo($lng->txt('delete_inactive_user_accounts_include_roles_desc'));
245  $roles = array();
246  foreach ($rbacreview->getGlobalRoles() as $role_id) {
247  if ($role_id != ANONYMOUS_ROLE_ID) {
248  $roles[$role_id] = $ilObjDataCache->lookupTitle($role_id);
249  }
250  }
251  $sub_mlist->setOptions($roles);
252  $setting = $ilSetting->get('cron_inactive_user_delete_include_roles', null);
253  if ($setting === null) {
254  $setting = array();
255  } else {
256  $setting = explode(',', $setting);
257  }
258  $sub_mlist->setValue($setting);
259  $sub_mlist->setWidth(300);
260  #$sub_mlist->setHeight(100);
261  $a_form->addItem($sub_mlist);
262 
263  $default_setting = self::DEFAULT_INACTIVITY_PERIOD;
264  $sub_text = new ilNumberInputGUI(
265  $lng->txt('delete_inactive_user_accounts_period'),
266  'cron_inactive_user_delete_period'
267  );
268  $sub_text->setInfo($lng->txt('delete_inactive_user_accounts_period_desc'));
269  $sub_text->setValue($ilSetting->get("cron_inactive_user_delete_period", $default_setting));
270  $sub_text->setSize(4);
271  $sub_text->setMaxLength(4);
272  $sub_text->setRequired(true);
273  $a_form->addItem($sub_text);
274 
275  $sub_period = new ilNumberInputGUI(
276  $lng->txt('send_mail_to_inactive_users'),
277  'cron_inactive_user_reminder_period'
278  );
279  $sub_period->setInfo($lng->txt("send_mail_to_inactive_users_desc"));
280  $sub_period->setValue($ilSetting->get("cron_inactive_user_reminder_period", $default_setting));
281  $sub_period->setSuffix($lng->txt("send_mail_to_inactive_users_suffix"));
282  $sub_period->setSize(4);
283  $sub_period->setMaxLength(4);
284  $sub_period->setRequired(false);
285  $sub_period->setMinValue(0);
286  $a_form->addItem($sub_period);
287  /*
288  $default_setting = ilCronDeleteInactiveUserAccounts::DEFAULT_SETTING_INCLUDE_ADMINS;
289  $sub_cb = new ilCheckboxInputGUI($lng->txt('delete_inactive_user_accounts_include_admins'),'cron_inactive_user_delete_include_admins');
290  $sub_cb->setChecked($ilSetting->get("cron_inactive_user_delete_include_admins", $default_setting) ? 1 : 0 );
291  //$sub_cb->setOptionTitle($lng->txt('delete_inactive_user_accounts_include_admins'));
292  $sub_cb->setInfo($lng->txt('delete_inactive_user_accounts_include_admins_desc'));
293  $a_form->addItem($sub_cb);
294  */
295  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
global $DIC
Definition: saml.php:7
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
This class represents a multi selection list property in a property form.
$lng
This class represents a number property in a property form.
global $ilSetting
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ calculateDeletionData()

ilCronDeleteInactiveUserAccounts::calculateDeletionData (   $date_for_deletion)
protected

Definition at line 200 of file class.ilCronDeleteInactiveUserAccounts.php.

References ilCronManager\getCronJobData(), getId(), and getTimeDifferenceBySchedule().

Referenced by hasCustomSettings().

201  {
202  $cron_timing = ilCronManager::getCronJobData($this->getId());
203  $time_difference = 0;
204  $multiplier = 1;
205 
206  if (!is_array($cron_timing) || !is_array($cron_timing[0])) {
207  return time() + $date_for_deletion + $time_difference;
208  }
209 
210  if (array_key_exists('schedule_type', $cron_timing[0])) {
211  if ((array_key_exists('schedule_type', $cron_timing[0]) && $cron_timing[0]['schedule_value'] != null)) {
212  $multiplier = $cron_timing[0]['schedule_value'];
213  }
214  $time_difference = $this->getTimeDifferenceBySchedule($cron_timing[0]['schedule_type'], $multiplier);
215  }
216  return time() + $date_for_deletion + $time_difference;
217  }
static getCronJobData($a_id=null, $a_include_inactive=true)
Get cron job configuration/execution data.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilCronDeleteInactiveUserAccounts::getDefaultScheduleType ( )

Definition at line 114 of file class.ilCronDeleteInactiveUserAccounts.php.

115  {
116  return self::SCHEDULE_TYPE_DAILY;
117  }

◆ getDefaultScheduleValue()

ilCronDeleteInactiveUserAccounts::getDefaultScheduleValue ( )

Definition at line 119 of file class.ilCronDeleteInactiveUserAccounts.php.

120  {
121  return;
122  }

◆ getDescription()

ilCronDeleteInactiveUserAccounts::getDescription ( )

Definition at line 105 of file class.ilCronDeleteInactiveUserAccounts.php.

References $DIC, and $lng.

106  {
107  global $DIC;
108 
109  $lng = $DIC['lng'];
110 
111  return $lng->txt("delete_inactive_user_accounts_desc");
112  }
global $DIC
Definition: saml.php:7
$lng

◆ getId()

ilCronDeleteInactiveUserAccounts::getId ( )

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

Referenced by calculateDeletionData().

92  {
93  return "user_inactive";
94  }
+ Here is the caller graph for this function:

◆ getTimeDifferenceBySchedule()

ilCronDeleteInactiveUserAccounts::getTimeDifferenceBySchedule (   $schedule_time,
  $multiplier 
)
protected
Parameters
$schedule_time
$multiplier
Returns
int

Definition at line 59 of file class.ilCronDeleteInactiveUserAccounts.php.

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

Referenced by calculateDeletionData().

60  {
61  $time_difference = 0;
62  switch ($schedule_time) {
64  $time_difference = 86400;
65  break;
67  $time_difference = 60 * $multiplier;
68  break;
70  $time_difference = 3600 * $multiplier;
71  break;
73  $time_difference = 86400 * $multiplier;
74  break;
76  $time_difference = 604800;
77  break;
79  $time_difference = 2629743;
80  break;
82  $time_difference = 7889229;
83  break;
85  $time_difference = 31556926;
86  break;
87  }
88  return $time_difference;
89  }
const SCHEDULE_TYPE_IN_MINUTES
const SCHEDULE_TYPE_MONTHLY
const SCHEDULE_TYPE_WEEKLY
const SCHEDULE_TYPE_IN_DAYS
const SCHEDULE_TYPE_YEARLY
const SCHEDULE_TYPE_DAILY
const SCHEDULE_TYPE_QUARTERLY
const SCHEDULE_TYPE_IN_HOURS
+ Here is the caller graph for this function:

◆ getTitle()

ilCronDeleteInactiveUserAccounts::getTitle ( )

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

References $DIC, and $lng.

97  {
98  global $DIC;
99 
100  $lng = $DIC['lng'];
101 
102  return $lng->txt("delete_inactive_user_accounts");
103  }
global $DIC
Definition: saml.php:7
$lng

◆ hasAutoActivation()

ilCronDeleteInactiveUserAccounts::hasAutoActivation ( )

Definition at line 124 of file class.ilCronDeleteInactiveUserAccounts.php.

125  {
126  return false;
127  }

◆ hasCustomSettings()

◆ hasFlexibleSchedule()

ilCronDeleteInactiveUserAccounts::hasFlexibleSchedule ( )

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

130  {
131  return true;
132  }

◆ isDecimal()

ilCronDeleteInactiveUserAccounts::isDecimal (   $number)
protected

Definition at line 373 of file class.ilCronDeleteInactiveUserAccounts.php.

Referenced by saveCustomSettings().

374  {
375  if (strpos($number, ',') || strpos($number, '.')) {
376  return true;
377  }
378  return false;
379  }
+ Here is the caller graph for this function:

◆ saveCustomSettings()

ilCronDeleteInactiveUserAccounts::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Definition at line 297 of file class.ilCronDeleteInactiveUserAccounts.php.

References $_POST, $DIC, $ilSetting, $lng, $valid, ilCronDeleteInactiveUserReminderMail\flushDataTable(), ilPropertyFormGUI\getItemByPostVar(), isDecimal(), ilCronJob\SCHEDULE_TYPE_IN_DAYS, ilCronJob\SCHEDULE_TYPE_MONTHLY, ilCronJob\SCHEDULE_TYPE_QUARTERLY, ilCronJob\SCHEDULE_TYPE_WEEKLY, ilCronJob\SCHEDULE_TYPE_YEARLY, ilUtil\sendFailure(), and ilUtil\stripSlashes().

298  {
299  global $DIC;
300 
301  $ilSetting = $DIC['ilSetting'];
302  $lng = $DIC['lng'];
303  $lng->loadLanguageModule("user");
304  $setting = implode(',', $_POST['cron_inactive_user_delete_include_roles']);
305  if (!strlen($setting)) {
306  $setting = null;
307  }
308 
309  $valid = true;
310  $delete_period = ilUtil::stripSlashes($_POST['cron_inactive_user_delete_period']);
311  $reminder_period = ilUtil::stripSlashes($_POST['cron_inactive_user_reminder_period']);
312  $cron_period = (int) ilUtil::stripSlashes($_POST['type']);
313  $cron_period_custom = (int) ilUtil::stripSlashes($_POST['sdyi']);
314 
315  if ($this->isDecimal($delete_period)) {
316  $valid = false;
317  $a_form->getItemByPostVar('cron_inactive_user_delete_period')->setAlert($lng->txt('send_mail_to_inactive_users_numbers_only'), 'send_mail_to_inactive_users_numbers_only');
318  }
319  if ($this->isDecimal($reminder_period)) {
320  $valid = false;
321  $a_form->getItemByPostVar('cron_inactive_user_reminder_period')->setAlert($lng->txt('send_mail_to_inactive_users_numbers_only'), 'send_mail_to_inactive_users_numbers_only');
322  }
323  if ($reminder_period >= $delete_period) {
324  $valid = false;
325  $a_form->getItemByPostVar('cron_inactive_user_reminder_period')->setAlert($lng->txt('send_mail_to_inactive_users_must_be_smaller_than'), 'send_mail_to_inactive_users_must_be_smaller_than');
326  }
327  if ($cron_period >= ilCronJob::SCHEDULE_TYPE_IN_DAYS && $cron_period <= ilCronJob::SCHEDULE_TYPE_YEARLY && $reminder_period > 0) {
328  $logic = true;
329  $check_window_logic = $delete_period - $reminder_period;
330  if ($cron_period == ilCronJob::SCHEDULE_TYPE_IN_DAYS) {
331  if ($check_window_logic < $cron_period_custom) {
332  $logic = false;
333  }
334  } elseif ($cron_period == ilCronJob::SCHEDULE_TYPE_WEEKLY) {
335  if ($check_window_logic <= 7) {
336  $logic = false;
337  }
338  } elseif ($cron_period == ilCronJob::SCHEDULE_TYPE_MONTHLY) {
339  if ($check_window_logic <= 31) {
340  $logic = false;
341  }
342  } elseif ($cron_period == ilCronJob::SCHEDULE_TYPE_QUARTERLY) {
343  if ($check_window_logic <= 92) {
344  $logic = false;
345  }
346  } elseif ($cron_period == ilCronJob::SCHEDULE_TYPE_YEARLY) {
347  if ($check_window_logic <= 366) {
348  $logic = false;
349  }
350  }
351  if (!$logic) {
352  $valid = false;
353  $a_form->getItemByPostVar('cron_inactive_user_reminder_period')->setAlert($lng->txt('send_mail_reminder_window_too_small'), 'send_mail_reminder_window_too_small');
354  }
355  }
356  if ($_POST['cron_inactive_user_delete_period']) {
357  $ilSetting->set('cron_inactive_user_delete_include_roles', $setting);
358  $ilSetting->set('cron_inactive_user_delete_period', $_POST['cron_inactive_user_delete_period']);
359  }
360  if ($this->reminderTimer > $reminder_period) {
362  }
363  $ilSetting->set('cron_inactive_user_reminder_period', $reminder_period);
364 
365  if (!$valid) {
366  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
367  return false;
368  }
369 
370  return true;
371  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
global $DIC
Definition: saml.php:7
$valid
const SCHEDULE_TYPE_MONTHLY
const SCHEDULE_TYPE_WEEKLY
$lng
const SCHEDULE_TYPE_IN_DAYS
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const SCHEDULE_TYPE_YEARLY
global $ilSetting
Definition: privfeed.php:17
const SCHEDULE_TYPE_QUARTERLY
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $include_roles

ilCronDeleteInactiveUserAccounts::$include_roles = null
private

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

◆ $period

ilCronDeleteInactiveUserAccounts::$period = null
private

Definition at line 22 of file class.ilCronDeleteInactiveUserAccounts.php.

◆ $reminderTimer

ilCronDeleteInactiveUserAccounts::$reminderTimer = null
private

Definition at line 23 of file class.ilCronDeleteInactiveUserAccounts.php.

◆ DEFAULT_INACTIVITY_PERIOD

const ilCronDeleteInactiveUserAccounts::DEFAULT_INACTIVITY_PERIOD = 365

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

◆ DEFAULT_REMINDER_PERIOD

const ilCronDeleteInactiveUserAccounts::DEFAULT_REMINDER_PERIOD = 0

Definition at line 20 of file class.ilCronDeleteInactiveUserAccounts.php.


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