ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCronDeleteInactivatedUserAccounts Class Reference
+ Inheritance diagram for ilCronDeleteInactivatedUserAccounts:
+ Collaboration diagram for ilCronDeleteInactivatedUserAccounts:

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...
 
 run ()
 Run job. 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...
 
 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
 
- 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
 

Private Attributes

 $period = null
 
 $include_roles = null
 

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCronDeleteInactivatedUserAccounts::__construct ( )

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

23 {
24 global $DIC;
25
26 $ilSetting = $DIC['ilSetting'];
27
28 if (is_object($ilSetting)) {
29 $this->include_roles = $ilSetting->get(
30 'cron_inactivated_user_delete_include_roles',
31 null
32 );
33 if ($this->include_roles === null) {
34 $this->include_roles = array();
35 } else {
36 $this->include_roles = explode(',', $this->include_roles);
37 }
38
39 $this->period = $ilSetting->get(
40 'cron_inactivated_user_delete_period',
41 self::DEFAULT_INACTIVITY_PERIOD
42 );
43 }
44 }
global $DIC
Definition: goto.php:24
global $ilSetting
Definition: privfeed.php:17

References $DIC, and $ilSetting.

Member Function Documentation

◆ addCustomSettingsToForm()

ilCronDeleteInactivatedUserAccounts::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Add custom settings to form.

Parameters
ilPropertyFormGUI$a_form

Reimplemented from ilCronJob.

Definition at line 139 of file class.ilCronDeleteInactivatedUserAccounts.php.

140 {
141 global $DIC;
142
143 $lng = $DIC['lng'];
144 $rbacreview = $DIC['rbacreview'];
145 $ilObjDataCache = $DIC['ilObjDataCache'];
146 $ilSetting = $DIC['ilSetting'];
147
148 include_once('Services/Form/classes/class.ilMultiSelectInputGUI.php');
149 $sub_mlist = new ilMultiSelectInputGUI(
150 $lng->txt('delete_inactivated_user_accounts_include_roles'),
151 'cron_inactivated_user_delete_include_roles'
152 );
153 $sub_mlist->setInfo($lng->txt('delete_inactivated_user_accounts_include_roles_desc'));
154 $roles = array();
155 foreach ($rbacreview->getGlobalRoles() as $role_id) {
156 if ($role_id != ANONYMOUS_ROLE_ID) {
157 $roles[$role_id] = $ilObjDataCache->lookupTitle($role_id);
158 }
159 }
160 $sub_mlist->setOptions($roles);
161 $setting = $ilSetting->get('cron_inactivated_user_delete_include_roles', null);
162 if ($setting === null) {
163 $setting = array();
164 } else {
165 $setting = explode(',', $setting);
166 }
167 $sub_mlist->setValue($setting);
168 $sub_mlist->setWidth(300);
169 #$sub_mlist->setHeight(100);
170 $a_form->addItem($sub_mlist);
171
172 $default_setting = self::DEFAULT_INACTIVITY_PERIOD;
173 $sub_text = new ilNumberInputGUI(
174 $lng->txt('delete_inactivated_user_accounts_period'),
175 'cron_inactivated_user_delete_period'
176 );
177 $sub_text->allowDecimals(false);
178 $sub_text->setInfo($lng->txt('delete_inactivated_user_accounts_period_desc'));
179 $sub_text->setValue($ilSetting->get("cron_inactivated_user_delete_period", $default_setting));
180 $sub_text->setSize(4);
181 $sub_text->setMaxLength(4);
182 $sub_text->setRequired(true);
183 $a_form->addItem($sub_text);
184 }
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).
const ANONYMOUS_ROLE_ID
Definition: constants.php:26
$lng

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

+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

Definition at line 72 of file class.ilCronDeleteInactivatedUserAccounts.php.

73 {
75 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

Definition at line 77 of file class.ilCronDeleteInactivatedUserAccounts.php.

78 {
79 return;
80 }

◆ getDescription()

ilCronDeleteInactivatedUserAccounts::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

Definition at line 60 of file class.ilCronDeleteInactivatedUserAccounts.php.

61 {
62 global $DIC;
63
64 $lng = $DIC['lng'];
65
66 return sprintf(
67 $lng->txt("delete_inactivated_user_accounts_desc"),
68 $this->period
69 );
70 }

References $DIC, and $lng.

◆ getId()

ilCronDeleteInactivatedUserAccounts::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

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

47 {
48 return "user_inactivated";
49 }

◆ getTitle()

ilCronDeleteInactivatedUserAccounts::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

Definition at line 51 of file class.ilCronDeleteInactivatedUserAccounts.php.

52 {
53 global $DIC;
54
55 $lng = $DIC['lng'];
56
57 return $lng->txt("delete_inactivated_user_accounts");
58 }

References $DIC, and $lng.

◆ hasAutoActivation()

ilCronDeleteInactivatedUserAccounts::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 82 of file class.ilCronDeleteInactivatedUserAccounts.php.

83 {
84 return false;
85 }

◆ hasCustomSettings()

ilCronDeleteInactivatedUserAccounts::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Reimplemented from ilCronJob.

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

93 {
94 return true;
95 }

◆ hasFlexibleSchedule()

ilCronDeleteInactivatedUserAccounts::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

88 {
89 return true;
90 }

◆ run()

ilCronDeleteInactivatedUserAccounts::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

Definition at line 97 of file class.ilCronDeleteInactivatedUserAccounts.php.

98 {
99 global $DIC;
100
101 $rbacreview = $DIC['rbacreview'];
102
104
105 $usr_ids = ilObjUser::_getUserIdsByInactivationPeriod($this->period);
106
107 $counter = 0;
108 foreach ($usr_ids as $usr_id) {
109 if ($usr_id == ANONYMOUS_USER_ID || $usr_id == SYSTEM_USER_ID) {
110 continue;
111 }
112
113 $continue = true;
114 foreach ($this->include_roles as $role_id) {
115 if ($rbacreview->isAssigned($usr_id, $role_id)) {
116 $continue = false;
117 break;
118 }
119 }
120 if ($continue) {
121 continue;
122 }
123
125
126 $user->delete();
127
128 $counter++;
129 }
130
131 if ($counter) {
133 }
134 $result = new ilCronJobResult();
135 $result->setStatus($status);
136 return $result;
137 }
$result
Cron job result data container.
static _getUserIdsByInactivationPeriod($period)
get ids of all users that have been inactivated since at least the given period
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
const SYSTEM_USER_ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: constants.php:24
const ANONYMOUS_USER_ID
Definition: constants.php:25

References $DIC, $result, ilObjUser\_getUserIdsByInactivationPeriod(), ANONYMOUS_USER_ID, ilObjectFactory\getInstanceByObjId(), ilCronJobResult\STATUS_NO_ACTION, ilCronJobResult\STATUS_OK, and SYSTEM_USER_ID.

+ Here is the call graph for this function:

◆ saveCustomSettings()

ilCronDeleteInactivatedUserAccounts::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Save custom settings.

Parameters
ilPropertyFormGUI$a_form
Returns
boolean

Reimplemented from ilCronJob.

Definition at line 186 of file class.ilCronDeleteInactivatedUserAccounts.php.

187 {
188 global $DIC;
189
190 $ilSetting = $DIC['ilSetting'];
191
192 $setting = implode(',', $_POST['cron_inactivated_user_delete_include_roles']);
193 if (!strlen($setting)) {
194 $setting = null;
195 }
196 $ilSetting->set('cron_inactivated_user_delete_include_roles', $setting);
197 $ilSetting->set('cron_inactivated_user_delete_period', $_POST['cron_inactivated_user_delete_period']);
198
199 return true;
200 }
$_POST["username"]

References $_POST, $DIC, and $ilSetting.

Field Documentation

◆ $include_roles

ilCronDeleteInactivatedUserAccounts::$include_roles = null
private

◆ $period

ilCronDeleteInactivatedUserAccounts::$period = null
private

◆ DEFAULT_INACTIVITY_PERIOD

const ilCronDeleteInactivatedUserAccounts::DEFAULT_INACTIVITY_PERIOD = 365

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