19 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[
'lng'];
54 if (isset($DIC[
'refinery'])) {
58 if (isset($DIC[
'ilObjDataCache'])) {
62 if (isset($DIC[
'rbacreview'])) {
63 $this->rbac_review = $DIC[
'rbacreview'];
66 if (isset($DIC[
'ilSetting'])) {
69 $include_roles = $this->
settings->get(
70 'cron_inactivated_user_delete_include_roles',
73 if ($include_roles === null) {
74 $this->include_roles = [];
76 $this->include_roles = array_filter(array_map(
'intval', explode(
',', $include_roles)));
80 'cron_inactivated_user_delete_period',
81 (
string) self::DEFAULT_INACTIVITY_PERIOD
88 return "user_inactivated";
93 return $this->
lng->txt(
"delete_inactivated_user_accounts");
99 $this->
lng->txt(
"delete_inactivated_user_accounts_desc"),
106 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
136 foreach ($usr_ids as $usr_id) {
141 foreach ($this->include_roles as $role_id) {
142 if ($this->rbac_review->isAssigned($usr_id, $role_id)) {
156 $result->setStatus($status);
164 $this->
lng->txt(
'delete_inactivated_user_accounts_include_roles'),
165 'cron_inactivated_user_delete_include_roles' 167 $sub_mlist->
setInfo($this->
lng->txt(
'delete_inactivated_user_accounts_include_roles_desc'));
169 foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
174 $sub_mlist->setOptions($roles);
175 $setting = $this->
settings->get(
'cron_inactivated_user_delete_include_roles', null);
176 if ($setting === null) {
179 $setting = explode(
',', $setting);
181 $sub_mlist->setValue($setting);
182 $sub_mlist->setWidth(300);
186 $this->
lng->txt(
'delete_inactivated_user_accounts_period'),
187 'cron_inactivated_user_delete_period' 189 $sub_text->allowDecimals(
false);
190 $sub_text->setInfo($this->
lng->txt(
'delete_inactivated_user_accounts_period_desc'));
193 'cron_inactivated_user_delete_period',
194 (
string) self::DEFAULT_INACTIVITY_PERIOD
197 $sub_text->setSize(4);
198 $sub_text->setMaxLength(4);
199 $sub_text->setRequired(
true);
205 $roles = implode(
',', $this->
http->wrapper()->post()->retrieve(
206 'cron_inactivated_user_delete_include_roles',
208 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
213 $period = $this->
http->wrapper()->post()->retrieve(
214 'cron_inactivated_user_delete_period',
216 $this->refinery->kindlyTo()->int(),
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));
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
static http()
Fetches the global http state from ILIAS.
final const STATUS_NO_ACTION
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
ilRbacReview $rbac_review
ILIAS Refinery Factory $refinery
saveCustomSettings(ilPropertyFormGUI $a_form)
const DEFAULT_INACTIVITY_PERIOD