ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilCronDeleteInactivatedUserAccounts Class Reference
+ Inheritance diagram for ilCronDeleteInactivatedUserAccounts:
+ Collaboration diagram for ilCronDeleteInactivatedUserAccounts:

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 run ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?CronJobScheduleType $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?CronJobScheduleType $a_type, ?int $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...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Private Attributes

const DEFAULT_INACTIVITY_PERIOD = 365
 
int $period
 
array $include_roles
 
ilSetting $settings
 
ilLanguage $lng
 
ilRbacReview $rbac_review
 
ilObjectDataCache $objectDataCache
 
ILIAS HTTP GlobalHttpState $http
 
ILIAS Refinery Factory $refinery
 

Additional Inherited Members

- Protected Attributes inherited from ilCronJob
CronJobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

Member Function Documentation

◆ addCustomSettingsToForm()

ilCronDeleteInactivatedUserAccounts::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

References ilPropertyFormGUI\addItem(), ANONYMOUS_ROLE_ID, ILIAS\Repository\lng(), ILIAS\Repository\objectDataCache(), ilFormPropertyGUI\setInfo(), and ILIAS\Repository\settings().

161  : void
162  {
163  $sub_mlist = new ilMultiSelectInputGUI(
164  $this->lng->txt('delete_inactivated_user_accounts_include_roles'),
165  'cron_inactivated_user_delete_include_roles'
166  );
167  $sub_mlist->setInfo($this->lng->txt('delete_inactivated_user_accounts_include_roles_desc'));
168  $roles = [];
169  foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
170  if ($role_id !== ANONYMOUS_ROLE_ID) {
171  $roles[$role_id] = $this->objectDataCache->lookupTitle($role_id);
172  }
173  }
174  $sub_mlist->setOptions($roles);
175  $setting = $this->settings->get('cron_inactivated_user_delete_include_roles', null);
176  if ($setting === null) {
177  $setting = [];
178  } else {
179  $setting = explode(',', $setting);
180  }
181  $sub_mlist->setValue($setting);
182  $sub_mlist->setWidth(300);
183  $a_form->addItem($sub_mlist);
184 
185  $sub_text = new ilNumberInputGUI(
186  $this->lng->txt('delete_inactivated_user_accounts_period'),
187  'cron_inactivated_user_delete_period'
188  );
189  $sub_text->allowDecimals(false);
190  $sub_text->setInfo($this->lng->txt('delete_inactivated_user_accounts_period_desc'));
191  $sub_text->setValue(
192  $this->settings->get(
193  'cron_inactivated_user_delete_period',
194  (string) self::DEFAULT_INACTIVITY_PERIOD
195  )
196  );
197  $sub_text->setSize(4);
198  $sub_text->setMaxLength(4);
199  $sub_text->setRequired(true);
200  $a_form->addItem($sub_text);
201  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleType ( )

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

105  {
106  return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
107  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleValue ( )

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

109  : ?int
110  {
111  return null;
112  }

◆ getDescription()

ilCronDeleteInactivatedUserAccounts::getDescription ( )

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

References $period, and ILIAS\Repository\lng().

96  : string
97  {
98  return sprintf(
99  $this->lng->txt("delete_inactivated_user_accounts_desc"),
101  );
102  }
+ Here is the call graph for this function:

◆ getId()

ilCronDeleteInactivatedUserAccounts::getId ( )

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

86  : string
87  {
88  return "user_inactivated";
89  }

◆ getTitle()

ilCronDeleteInactivatedUserAccounts::getTitle ( )

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

References ILIAS\Repository\lng().

91  : string
92  {
93  return $this->lng->txt("delete_inactivated_user_accounts");
94  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilCronDeleteInactivatedUserAccounts::hasAutoActivation ( )

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

114  : bool
115  {
116  return false;
117  }

◆ hasCustomSettings()

ilCronDeleteInactivatedUserAccounts::hasCustomSettings ( )

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

124  : bool
125  {
126  return true;
127  }

◆ hasFlexibleSchedule()

ilCronDeleteInactivatedUserAccounts::hasFlexibleSchedule ( )

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

119  : bool
120  {
121  return true;
122  }

◆ run()

ilCronDeleteInactivatedUserAccounts::run ( )

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

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

130  {
132 
133  $usr_ids = ilObjUser::_getUserIdsByInactivationPeriod($this->period);
134 
135  $counter = 0;
136  foreach ($usr_ids as $usr_id) {
137  if ($usr_id === ANONYMOUS_USER_ID || $usr_id === SYSTEM_USER_ID) {
138  continue;
139  }
140 
141  foreach ($this->include_roles as $role_id) {
142  if ($this->rbac_review->isAssigned($usr_id, $role_id)) {
143  $user = ilObjectFactory::getInstanceByObjId($usr_id);
144  $user->delete();
145  $counter++;
146  break;
147  }
148  }
149  }
150 
151  if ($counter > 0) {
152  $status = ilCronJobResult::STATUS_OK;
153  }
154 
155  $result = new ilCronJobResult();
156  $result->setStatus($status);
157 
158  return $result;
159  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
final const STATUS_NO_ACTION
static _getUserIdsByInactivationPeriod(int $period)
get ids of all users that have been inactivated since at least the given period
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ saveCustomSettings()

ilCronDeleteInactivatedUserAccounts::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

References ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), and ILIAS\Repository\settings().

203  : bool
204  {
205  $roles = implode(',', $this->http->wrapper()->post()->retrieve(
206  'cron_inactivated_user_delete_include_roles',
207  $this->refinery->byTrying([
208  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
209  $this->refinery->always([])
210  ])
211  ));
212 
213  $period = $this->http->wrapper()->post()->retrieve(
214  'cron_inactivated_user_delete_period',
215  $this->refinery->byTrying([
216  $this->refinery->kindlyTo()->int(),
217  $this->refinery->always(null)
218  ])
219  );
220 
221  $this->settings->set('cron_inactivated_user_delete_include_roles', $roles);
222  $this->settings->set('cron_inactivated_user_delete_period', (string) ($period ?? self::DEFAULT_INACTIVITY_PERIOD));
223 
224  return true;
225  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

Field Documentation

◆ $http

ILIAS HTTP GlobalHttpState ilCronDeleteInactivatedUserAccounts::$http
private

◆ $include_roles

array ilCronDeleteInactivatedUserAccounts::$include_roles
private

◆ $lng

ilLanguage ilCronDeleteInactivatedUserAccounts::$lng
private

◆ $objectDataCache

ilObjectDataCache ilCronDeleteInactivatedUserAccounts::$objectDataCache
private

◆ $period

int ilCronDeleteInactivatedUserAccounts::$period
private

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

Referenced by getDescription().

◆ $rbac_review

ilRbacReview ilCronDeleteInactivatedUserAccounts::$rbac_review
private

◆ $refinery

ILIAS Refinery Factory ilCronDeleteInactivatedUserAccounts::$refinery
private

◆ $settings

ilSetting ilCronDeleteInactivatedUserAccounts::$settings
private

◆ DEFAULT_INACTIVITY_PERIOD

const ilCronDeleteInactivatedUserAccounts::DEFAULT_INACTIVITY_PERIOD = 365
private

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