ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 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
 
- 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 $ilSetting;
25
26 if (is_object($ilSetting)) {
27 $this->include_roles = $ilSetting->get(
28 'cron_inactivated_user_delete_include_roles',
29 null
30 );
31 if ($this->include_roles === null) {
32 $this->include_roles = array();
33 } else {
34 $this->include_roles = explode(',', $this->include_roles);
35 }
36
37 $this->period = $ilSetting->get(
38 'cron_inactivated_user_delete_period',
39 self::DEFAULT_INACTIVITY_PERIOD
40 );
41 }
42 }
global $ilSetting
Definition: privfeed.php:17

References $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 131 of file class.ilCronDeleteInactivatedUserAccounts.php.

132 {
133 global $lng, $rbacreview, $ilObjDataCache, $ilSetting;
134
135 include_once('Services/Form/classes/class.ilMultiSelectInputGUI.php');
136 $sub_mlist = new ilMultiSelectInputGUI(
137 $lng->txt('delete_inactivated_user_accounts_include_roles'),
138 'cron_inactivated_user_delete_include_roles'
139 );
140 $sub_mlist->setInfo($lng->txt('delete_inactivated_user_accounts_include_roles_desc'));
141 $roles = array();
142 foreach ($rbacreview->getGlobalRoles() as $role_id) {
143 if ($role_id != ANONYMOUS_ROLE_ID) {
144 $roles[$role_id] = $ilObjDataCache->lookupTitle($role_id);
145 }
146 }
147 $sub_mlist->setOptions($roles);
148 $setting = $ilSetting->get('cron_inactivated_user_delete_include_roles', null);
149 if ($setting === null) {
150 $setting = array();
151 } else {
152 $setting = explode(',', $setting);
153 }
154 $sub_mlist->setValue($setting);
155 $sub_mlist->setWidth(300);
156 #$sub_mlist->setHeight(100);
157 $a_form->addItem($sub_mlist);
158
159 $default_setting = self::DEFAULT_INACTIVITY_PERIOD;
160 $sub_text = new ilNumberInputGUI(
161 $lng->txt('delete_inactivated_user_accounts_period'),
162 'cron_inactivated_user_delete_period'
163 );
164 $sub_text->allowDecimals(false);
165 $sub_text->setInfo($lng->txt('delete_inactivated_user_accounts_period_desc'));
166 $sub_text->setValue($ilSetting->get("cron_inactivated_user_delete_period", $default_setting));
167 $sub_text->setSize(4);
168 $sub_text->setMaxLength(4);
169 $sub_text->setRequired(true);
170 $a_form->addItem($sub_text);
171
172 /*
173 $default_setting = ilCronDeleteInactiveUserAccounts::DEFAULT_SETTING_INCLUDE_ADMINS;
174 $sub_cb = new ilCheckboxInputGUI($lng->txt('delete_inactivated_user_accounts_include_admins'),'cron_inactivated_user_delete_include_admins');
175 $sub_cb->setChecked($ilSetting->get("cron_inactivated_user_delete_include_admins", $default_setting) ? 1 : 0 );
176 //$sub_cb->setOptionTitle($lng->txt('delete_inactivated_user_accounts_include_admins'));
177 $sub_cb->setInfo($lng->txt('delete_inactivated_user_accounts_include_admins_desc'));
178 $a_form->addItem($sub_cb);
179 */
180 }
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).
global $lng
Definition: privfeed.php:17

References $ilSetting, $lng, ilPropertyFormGUI\addItem(), 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 66 of file class.ilCronDeleteInactivatedUserAccounts.php.

67 {
69 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

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

72 {
73 return;
74 }

◆ getDescription()

ilCronDeleteInactivatedUserAccounts::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

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

57 {
58 global $lng;
59
60 return sprintf(
61 $lng->txt("delete_inactivated_user_accounts_desc"),
62 $this->period
63 );
64 }
sprintf('%.4f', $callTime)

References $lng, and sprintf.

◆ getId()

ilCronDeleteInactivatedUserAccounts::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

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

45 {
46 return "user_inactivated";
47 }

◆ getTitle()

ilCronDeleteInactivatedUserAccounts::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

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

50 {
51 global $lng;
52
53 return $lng->txt("delete_inactivated_user_accounts");
54 }

References $lng.

◆ hasAutoActivation()

ilCronDeleteInactivatedUserAccounts::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

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

77 {
78 return false;
79 }

◆ hasCustomSettings()

ilCronDeleteInactivatedUserAccounts::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Reimplemented from ilCronJob.

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

87 {
88 return true;
89 }

◆ hasFlexibleSchedule()

ilCronDeleteInactivatedUserAccounts::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

82 {
83 return true;
84 }

◆ run()

ilCronDeleteInactivatedUserAccounts::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

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

92 {
93 global $rbacreview;
94
96
97 $usr_ids = ilObjUser::_getUserIdsByInactivationPeriod($this->period);
98
99 $counter = 0;
100 foreach ($usr_ids as $usr_id) {
101 if ($usr_id == ANONYMOUS_USER_ID || $usr_id == SYSTEM_USER_ID) {
102 continue;
103 }
104
105 $continue = true;
106 foreach ($this->include_roles as $role_id) {
107 if ($rbacreview->isAssigned($usr_id, $role_id)) {
108 $continue = false;
109 break;
110 }
111 }
112 if ($continue) {
113 continue;
114 }
115
117
118 $user->delete();
119
120 $counter++;
121 }
122
123 if ($counter) {
125 }
126 $result = new ilCronJobResult();
127 $result->setStatus($status);
128 return $result;
129 }
$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
$counter

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

+ 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 182 of file class.ilCronDeleteInactivatedUserAccounts.php.

183 {
184 global $ilSetting;
185
186 $setting = implode(',', $_POST['cron_inactivated_user_delete_include_roles']);
187 if (!strlen($setting)) {
188 $setting = null;
189 }
190 $ilSetting->set('cron_inactivated_user_delete_include_roles', $setting);
191 $ilSetting->set('cron_inactivated_user_delete_period', $_POST['cron_inactivated_user_delete_period']);
192
193 return true;
194 }
$_POST["username"]

References $_POST, 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: