ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilCronDeleteInactiveUserAccounts Class Reference
+ Inheritance diagram for ilCronDeleteInactiveUserAccounts:
+ Collaboration diagram for ilCronDeleteInactiveUserAccounts:

Public Member Functions

 __construct ()
 
 getId ()
 Get id. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? 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...
 
- 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...
 

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.

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

References $ilSetting.

Member Function Documentation

◆ addCustomSettingsToForm()

ilCronDeleteInactiveUserAccounts::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Add custom settings to form.

Parameters
ilPropertyFormGUI$a_form

Reimplemented from ilCronJob.

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

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

References $ilSetting, $lng, ilPropertyFormGUI\addItem(), DEFAULT_INACTIVITY_PERIOD, and ilPropertyFormGUI\getItemByPostVar().

+ Here is the call graph for this function:

◆ calculateDeletionData()

ilCronDeleteInactiveUserAccounts::calculateDeletionData (   $date_for_deletion)
protected

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

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

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

+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilCronDeleteInactiveUserAccounts::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

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

107 {
109 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilCronDeleteInactiveUserAccounts::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

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

112 {
113 return;
114 }

◆ getDescription()

ilCronDeleteInactiveUserAccounts::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

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

100 {
101 global $lng;
102
103 return $lng->txt("delete_inactive_user_accounts_desc");
104 }

References $lng.

◆ getId()

ilCronDeleteInactiveUserAccounts::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

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

88 {
89 return "user_inactive";
90 }

Referenced by calculateDeletionData().

+ Here is the caller graph for this function:

◆ getTimeDifferenceBySchedule()

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

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

55 {
56 $time_difference = 0;
57 switch($schedule_time)
58 {
60 $time_difference = 86400;
61 break;
63 $time_difference = 60 * $multiplier;
64 break;
66 $time_difference = 3600 * $multiplier;
67 break;
69 $time_difference = 86400 * $multiplier;
70 break;
72 $time_difference = 604800;
73 break;
75 $time_difference = 2629743;
76 break;
78 $time_difference = 7889229;
79 break;
81 $time_difference = 31556926;
82 break;
83 }
84 return $time_difference;
85 }
const SCHEDULE_TYPE_IN_DAYS
const SCHEDULE_TYPE_IN_HOURS
const SCHEDULE_TYPE_IN_MINUTES
const SCHEDULE_TYPE_WEEKLY
const SCHEDULE_TYPE_YEARLY
const SCHEDULE_TYPE_QUARTERLY
const SCHEDULE_TYPE_MONTHLY

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

+ Here is the caller graph for this function:

◆ getTitle()

ilCronDeleteInactiveUserAccounts::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

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

93 {
94 global $lng;
95
96 return $lng->txt("delete_inactive_user_accounts");
97 }

References $lng.

◆ hasAutoActivation()

ilCronDeleteInactiveUserAccounts::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

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

117 {
118 return false;
119 }

◆ hasCustomSettings()

ilCronDeleteInactiveUserAccounts::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Reimplemented from ilCronJob.

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

127 {
128 return true;
129 }

◆ hasFlexibleSchedule()

ilCronDeleteInactiveUserAccounts::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

122 {
123 return true;
124 }

◆ isDecimal()

ilCronDeleteInactiveUserAccounts::isDecimal (   $number)
protected

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

381 {
382 if(strpos($number,',') || strpos($number,'.'))
383 {
384 return true;
385 }
386 return false;
387 }

Referenced by saveCustomSettings().

+ Here is the caller graph for this function:

◆ saveCustomSettings()

ilCronDeleteInactiveUserAccounts::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Save custom settings.

Parameters
ilPropertyFormGUI$a_form
Returns
boolean

Reimplemented from ilCronJob.

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

285 {
286 global $ilSetting, $lng;
287 $lng->loadLanguageModule("user");
288 $setting = implode(',', $_POST['cron_inactive_user_delete_include_roles']);
289 if(!strlen($setting))
290 {
291 $setting = null;
292 }
293
294 $valid = true;
295 $delete_period = ilUtil::stripSlashes($_POST['cron_inactive_user_delete_period']);
296 $reminder_period = ilUtil::stripSlashes($_POST['cron_inactive_user_reminder_period']);
297 $cron_period = (int) ilUtil::stripSlashes($_POST['type']);
298 $cron_period_custom = (int) ilUtil::stripSlashes($_POST['sdyi']);
299
300 if($this->isDecimal($delete_period))
301 {
302 $valid = false;
303 $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');
304 }
305 if($this->isDecimal($reminder_period))
306 {
307 $valid = false;
308 $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');
309 }
310 if($reminder_period >= $delete_period)
311 {
312 $valid = false;
313 $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');
314 }
315 if($cron_period >= ilCronJob::SCHEDULE_TYPE_IN_DAYS && $cron_period <= ilCronJob::SCHEDULE_TYPE_YEARLY && $reminder_period > 0)
316 {
317 $logic = true;
318 $check_window_logic = $delete_period - $reminder_period;
319 if($cron_period == ilCronJob::SCHEDULE_TYPE_IN_DAYS)
320 {
321 if($check_window_logic < $cron_period_custom)
322 {
323 $logic = false;
324 }
325 }
326 else if($cron_period == ilCronJob::SCHEDULE_TYPE_WEEKLY)
327 {
328 if($check_window_logic <= 7)
329 {
330 $logic = false;
331 }
332 }
333 else if($cron_period == ilCronJob::SCHEDULE_TYPE_MONTHLY)
334 {
335 if($check_window_logic <= 31)
336 {
337 $logic = false;
338 }
339 }
340 else if($cron_period == ilCronJob::SCHEDULE_TYPE_QUARTERLY)
341 {
342 if($check_window_logic <= 92)
343 {
344 $logic = false;
345 }
346 }
347 else if($cron_period == ilCronJob::SCHEDULE_TYPE_YEARLY)
348 {
349 if($check_window_logic <= 366)
350 {
351 $logic = false;
352 }
353 }
354 if(!$logic)
355 {
356 $valid = false;
357 $a_form->getItemByPostVar('cron_inactive_user_reminder_period')->setAlert($lng->txt('send_mail_reminder_window_too_small'),'send_mail_reminder_window_too_small');
358 }
359 }
360 if($_POST['cron_inactive_user_delete_period'])
361 {
362 $ilSetting->set('cron_inactive_user_delete_include_roles', $setting);
363 $ilSetting->set('cron_inactive_user_delete_period', $_POST['cron_inactive_user_delete_period']);
364 }
365 if($this->reminderTimer > $reminder_period)
366 {
368 }
369 $ilSetting->set('cron_inactive_user_reminder_period', $reminder_period);
370
371 if(!$valid)
372 {
373 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
374 return false;
375 }
376
377 return true;
378 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST['username']
Definition: cron.php:12
$valid

References $_POST, $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().

+ 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.

Referenced by addCustomSettingsToForm().

◆ 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: