ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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
 
Language $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 162 of file class.ilCronDeleteInactivatedUserAccounts.php.

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

162  : void
163  {
164  $sub_mlist = new ilMultiSelectInputGUI(
165  $this->lng->txt('delete_inactivated_user_accounts_include_roles'),
166  'cron_inactivated_user_delete_include_roles'
167  );
168  $sub_mlist->setInfo($this->lng->txt('delete_inactivated_user_accounts_include_roles_desc'));
169  $roles = [];
170  foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
171  if ($role_id !== ANONYMOUS_ROLE_ID) {
172  $roles[$role_id] = $this->objectDataCache->lookupTitle($role_id);
173  }
174  }
175  $sub_mlist->setOptions($roles);
176  $setting = $this->settings->get('cron_inactivated_user_delete_include_roles', null);
177  if ($setting === null) {
178  $setting = [];
179  } else {
180  $setting = explode(',', $setting);
181  }
182  $sub_mlist->setValue($setting);
183  $sub_mlist->setWidth(300);
184  $a_form->addItem($sub_mlist);
185 
186  $sub_text = new ilNumberInputGUI(
187  $this->lng->txt('delete_inactivated_user_accounts_period'),
188  'cron_inactivated_user_delete_period'
189  );
190  $sub_text->allowDecimals(false);
191  $sub_text->setInfo($this->lng->txt('delete_inactivated_user_accounts_period_desc'));
192  $sub_text->setValue(
193  $this->settings->get(
194  'cron_inactivated_user_delete_period',
195  (string) self::DEFAULT_INACTIVITY_PERIOD
196  )
197  );
198  $sub_text->setSize(4);
199  $sub_text->setMaxLength(4);
200  $sub_text->setRequired(true);
201  $a_form->addItem($sub_text);
202  }
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 105 of file class.ilCronDeleteInactivatedUserAccounts.php.

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

◆ getDefaultScheduleValue()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleValue ( )

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

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

◆ getDescription()

ilCronDeleteInactivatedUserAccounts::getDescription ( )

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

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

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

◆ getId()

ilCronDeleteInactivatedUserAccounts::getId ( )

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

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

◆ getTitle()

ilCronDeleteInactivatedUserAccounts::getTitle ( )

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

References ILIAS\Repository\lng().

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

◆ hasAutoActivation()

ilCronDeleteInactivatedUserAccounts::hasAutoActivation ( )

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

115  : bool
116  {
117  return false;
118  }

◆ hasCustomSettings()

ilCronDeleteInactivatedUserAccounts::hasCustomSettings ( )

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

125  : bool
126  {
127  return true;
128  }

◆ hasFlexibleSchedule()

ilCronDeleteInactivatedUserAccounts::hasFlexibleSchedule ( )

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

120  : bool
121  {
122  return true;
123  }

◆ run()

ilCronDeleteInactivatedUserAccounts::run ( )

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

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

131  {
133 
134  $usr_ids = ilObjUser::_getUserIdsByInactivationPeriod($this->period);
135 
136  $counter = 0;
137  foreach ($usr_ids as $usr_id) {
138  if ($usr_id === ANONYMOUS_USER_ID || $usr_id === SYSTEM_USER_ID) {
139  continue;
140  }
141 
142  foreach ($this->include_roles as $role_id) {
143  if ($this->rbac_review->isAssigned($usr_id, $role_id)) {
144  $user = ilObjectFactory::getInstanceByObjId($usr_id);
145  $user->delete();
146  $counter++;
147  break;
148  }
149  }
150  }
151 
152  if ($counter > 0) {
153  $status = ilCronJobResult::STATUS_OK;
154  }
155 
156  $result = new ilCronJobResult();
157  $result->setStatus($status);
158 
159  return $result;
160  }
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 204 of file class.ilCronDeleteInactivatedUserAccounts.php.

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

204  : bool
205  {
206  $roles = implode(',', $this->http->wrapper()->post()->retrieve(
207  'cron_inactivated_user_delete_include_roles',
208  $this->refinery->byTrying([
209  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
210  $this->refinery->always([])
211  ])
212  ));
213 
214  $period = $this->http->wrapper()->post()->retrieve(
215  'cron_inactivated_user_delete_period',
216  $this->refinery->byTrying([
217  $this->refinery->kindlyTo()->int(),
218  $this->refinery->always(null)
219  ])
220  );
221 
222  $this->settings->set('cron_inactivated_user_delete_include_roles', $roles);
223  $this->settings->set('cron_inactivated_user_delete_period', (string) ($period ?? self::DEFAULT_INACTIVITY_PERIOD));
224 
225  return true;
226  }
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

Language ilCronDeleteInactivatedUserAccounts::$lng
private

◆ $objectDataCache

ilObjectDataCache ilCronDeleteInactivatedUserAccounts::$objectDataCache
private

◆ $period

int ilCronDeleteInactivatedUserAccounts::$period
private

Definition at line 32 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: