ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $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 (?JobScheduleType $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 ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 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 ILIAS\Cron\CronJob
JobScheduleType $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 164 of file class.ilCronDeleteInactivatedUserAccounts.php.

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

164  : void
165  {
166  $sub_mlist = new ilMultiSelectInputGUI(
167  $this->lng->txt('delete_inactivated_user_accounts_include_roles'),
168  'cron_inactivated_user_delete_include_roles'
169  );
170  $sub_mlist->setInfo($this->lng->txt('delete_inactivated_user_accounts_include_roles_desc'));
171  $roles = [];
172  foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
173  if ($role_id !== ANONYMOUS_ROLE_ID) {
174  $roles[$role_id] = $this->objectDataCache->lookupTitle($role_id);
175  }
176  }
177  $sub_mlist->setOptions($roles);
178  $setting = $this->settings->get('cron_inactivated_user_delete_include_roles', null);
179  if ($setting === null) {
180  $setting = [];
181  } else {
182  $setting = explode(',', $setting);
183  }
184  $sub_mlist->setValue($setting);
185  $sub_mlist->setWidth(300);
186  $a_form->addItem($sub_mlist);
187 
188  $sub_text = new ilNumberInputGUI(
189  $this->lng->txt('delete_inactivated_user_accounts_period'),
190  'cron_inactivated_user_delete_period'
191  );
192  $sub_text->allowDecimals(false);
193  $sub_text->setInfo($this->lng->txt('delete_inactivated_user_accounts_period_desc'));
194  $sub_text->setValue(
195  $this->settings->get(
196  'cron_inactivated_user_delete_period',
197  (string) self::DEFAULT_INACTIVITY_PERIOD
198  )
199  );
200  $sub_text->setSize(4);
201  $sub_text->setMaxLength(4);
202  $sub_text->setRequired(true);
203  $a_form->addItem($sub_text);
204  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
allowDecimals(bool $a_value)
This class represents a multi selection list property in a property form.
This class represents a number property in a property form.
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleType ( )

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

108  {
109  return JobScheduleType::DAILY;
110  }

◆ getDefaultScheduleValue()

ilCronDeleteInactivatedUserAccounts::getDefaultScheduleValue ( )

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

References null.

112  : ?int
113  {
114  return null;
115  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDescription()

ilCronDeleteInactivatedUserAccounts::getDescription ( )

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

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

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

◆ getId()

ilCronDeleteInactivatedUserAccounts::getId ( )

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

89  : string
90  {
91  return "user_inactivated";
92  }

◆ getTitle()

ilCronDeleteInactivatedUserAccounts::getTitle ( )

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

References ILIAS\Repository\lng().

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

◆ hasAutoActivation()

ilCronDeleteInactivatedUserAccounts::hasAutoActivation ( )

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

117  : bool
118  {
119  return false;
120  }

◆ hasCustomSettings()

ilCronDeleteInactivatedUserAccounts::hasCustomSettings ( )

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

127  : bool
128  {
129  return true;
130  }

◆ hasFlexibleSchedule()

ilCronDeleteInactivatedUserAccounts::hasFlexibleSchedule ( )

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

122  : bool
123  {
124  return true;
125  }

◆ run()

ilCronDeleteInactivatedUserAccounts::run ( )

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

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

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

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

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