ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
28 $this->include_roles = $ilSetting->get(
29 'cron_inactivated_user_delete_include_roles', null
30 );
31 if($this->include_roles === null) $this->include_roles = array();
32 else $this->include_roles = explode(',', $this->include_roles);
33
34 $this->period = $ilSetting->get(
35 'cron_inactivated_user_delete_period',
36 self::DEFAULT_INACTIVITY_PERIOD
37 );
38 }
39 }
global $ilSetting
Definition: privfeed.php:40

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

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

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

64 {
66 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

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

69 {
70 return;
71 }

◆ getDescription()

ilCronDeleteInactivatedUserAccounts::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

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

54 {
55 global $lng;
56
57 return sprintf(
58 $lng->txt("delete_inactivated_user_accounts_desc"),
59 $this->period
60 );
61 }

References $lng.

◆ getId()

ilCronDeleteInactivatedUserAccounts::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

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

42 {
43 return "user_inactivated";
44 }

◆ getTitle()

ilCronDeleteInactivatedUserAccounts::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

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

47 {
48 global $lng;
49
50 return $lng->txt("delete_inactivated_user_accounts");
51 }

References $lng.

◆ hasAutoActivation()

ilCronDeleteInactivatedUserAccounts::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

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

74 {
75 return false;
76 }

◆ hasCustomSettings()

ilCronDeleteInactivatedUserAccounts::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Reimplemented from ilCronJob.

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

84 {
85 return true;
86 }

◆ hasFlexibleSchedule()

ilCronDeleteInactivatedUserAccounts::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

79 {
80 return true;
81 }

◆ run()

ilCronDeleteInactivatedUserAccounts::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

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

89 {
90 global $rbacreview;
91
93
94 $usr_ids = ilObjUser::_getUserIdsByInactivationPeriod($this->period);
95
96 $counter = 0;
97 foreach($usr_ids as $usr_id)
98 {
99 if($usr_id == ANONYMOUS_USER_ID || $usr_id == SYSTEM_USER_ID) continue;
100
101 $continue = true;
102 foreach($this->include_roles as $role_id)
103 {
104 if( $rbacreview->isAssigned($usr_id, $role_id) )
105 {
106 $continue = false;
107 break;
108 }
109 }
110 if($continue) continue;
111
113
114 $user->delete();
115
116 $counter++;
117 }
118
119 if($counter)
120 {
122 }
123 $result = new ilCronJobResult();
124 $result->setStatus($status);
125 return $result;
126 }
$result
Cron job result data container.
static _getUserIdsByInactivationPeriod($period)
get ids of all users that have been inactivated since at least the given period
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

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

177 {
178 global $ilSetting;
179
180 $setting = implode(',', $_POST['cron_inactivated_user_delete_include_roles']);
181 if( !strlen($setting) ) $setting = null;
182 $ilSetting->set('cron_inactivated_user_delete_include_roles', $setting);
183 $ilSetting->set('cron_inactivated_user_delete_period', $_POST['cron_inactivated_user_delete_period']);
184
185 return true;
186 }
$_POST['username']
Definition: cron.php:12

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: