3 declare(strict_types=1);
38 private \ILIAS\HTTP\GlobalHttpState
$http;
46 if (isset($DIC[
'http'])) {
47 $this->
http = $DIC->http();
50 if (isset($DIC[
'lng'])) {
51 $this->
lng = $DIC->language();
54 if (isset($DIC[
'refinery'])) {
58 if (isset($DIC[
'ilObjDataCache'])) {
59 $this->objectDataCache = $DIC[
'ilObjDataCache'];
62 if (isset($DIC[
'rbacreview'])) {
63 $this->rbacReview = $DIC->rbac()->review();
66 $rbacreview = $DIC->rbac()->review();
67 $ilObjDataCache = $DIC[
'ilObjDataCache'];
69 if ($DIC[
'ilSetting']) {
72 $include_roles = $this->
settings->get(
73 'cron_inactivated_user_delete_include_roles',
76 if ($include_roles === null) {
77 $this->include_roles = [];
79 $this->include_roles = array_filter(array_map(
'intval', explode(
',', $include_roles)));
83 'cron_inactivated_user_delete_period',
84 (
string) self::DEFAULT_INACTIVITY_PERIOD
92 return "user_inactivated";
97 return $this->
lng->txt(
"delete_inactivated_user_accounts");
103 $this->
lng->txt(
"delete_inactivated_user_accounts_desc"),
110 return self::SCHEDULE_TYPE_DAILY;
137 $rbacreview = $DIC->rbac()->review();
144 foreach ($usr_ids as $usr_id) {
150 foreach ($this->include_roles as $role_id) {
151 if ($rbacreview->isAssigned($usr_id, $role_id)) {
172 $result->setStatus($status);
180 $this->
lng->txt(
'delete_inactivated_user_accounts_include_roles'),
181 'cron_inactivated_user_delete_include_roles' 183 $sub_mlist->
setInfo($this->
lng->txt(
'delete_inactivated_user_accounts_include_roles_desc'));
185 foreach ($this->rbacReview->getGlobalRoles() as $role_id) {
187 $roles[$role_id] = $this->objectDataCache->lookupTitle($role_id);
190 $sub_mlist->setOptions($roles);
191 $setting = $this->
settings->get(
'cron_inactivated_user_delete_include_roles', null);
192 if ($setting === null) {
195 $setting = explode(
',', $setting);
197 $sub_mlist->setValue($setting);
198 $sub_mlist->setWidth(300);
202 $this->
lng->txt(
'delete_inactivated_user_accounts_period'),
203 'cron_inactivated_user_delete_period' 206 $sub_text->setInfo($this->
lng->txt(
'delete_inactivated_user_accounts_period_desc'));
209 'cron_inactivated_user_delete_period',
210 (
string) self::DEFAULT_INACTIVITY_PERIOD
213 $sub_text->setSize(4);
214 $sub_text->setMaxLength(4);
215 $sub_text->setRequired(
true);
221 $roles = implode(
',', $this->
http->wrapper()->post()->retrieve(
222 'cron_inactivated_user_delete_include_roles',
224 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
229 $period = $this->
http->wrapper()->post()->retrieve(
230 'cron_inactivated_user_delete_period',
232 $this->refinery->kindlyTo()->int(),
237 $this->
settings->set(
'cron_inactivated_user_delete_include_roles', $roles);
238 $this->
settings->set(
'cron_inactivated_user_delete_period', (
string) ($period ?? self::DEFAULT_INACTIVITY_PERIOD));
ILIAS HTTP GlobalHttpState $http
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
ilObjectDataCache $objectDataCache
getDefaultScheduleValue()
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
ILIAS Refinery Factory $refinery
saveCustomSettings(ilPropertyFormGUI $a_form)
const DEFAULT_INACTIVITY_PERIOD
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...