19 declare(strict_types=1);
39 private \ILIAS\HTTP\GlobalHttpState
$http;
47 if (isset($DIC[
'http'])) {
48 $this->
http = $DIC[
'http'];
51 if (isset($DIC[
'lng'])) {
52 $this->
lng = $DIC[
'lng'];
55 if (isset($DIC[
'refinery'])) {
59 if (isset($DIC[
'ilObjDataCache'])) {
63 if (isset($DIC[
'rbacreview'])) {
64 $this->rbac_review = $DIC[
'rbacreview'];
67 if (isset($DIC[
'ilSetting'])) {
70 $include_roles = $this->
settings->get(
71 'cron_inactivated_user_delete_include_roles',
74 if ($include_roles === null) {
75 $this->include_roles = [];
77 $this->include_roles = array_filter(
array_map(
'intval', explode(
',', $include_roles)));
81 'cron_inactivated_user_delete_period',
82 (
string) self::DEFAULT_INACTIVITY_PERIOD
89 return "user_inactivated";
94 return $this->
lng->txt(
"delete_inactivated_user_accounts");
100 $this->
lng->txt(
"delete_inactivated_user_accounts_desc"),
107 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
137 foreach ($usr_ids as $usr_id) {
142 foreach ($this->include_roles as $role_id) {
143 if ($this->rbac_review->isAssigned($usr_id, $role_id)) {
157 $result->setStatus($status);
165 $this->
lng->txt(
'delete_inactivated_user_accounts_include_roles'),
166 'cron_inactivated_user_delete_include_roles' 168 $sub_mlist->
setInfo($this->
lng->txt(
'delete_inactivated_user_accounts_include_roles_desc'));
170 foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
175 $sub_mlist->setOptions($roles);
176 $setting = $this->
settings->get(
'cron_inactivated_user_delete_include_roles', null);
177 if ($setting === null) {
180 $setting = explode(
',', $setting);
182 $sub_mlist->setValue($setting);
183 $sub_mlist->setWidth(300);
187 $this->
lng->txt(
'delete_inactivated_user_accounts_period'),
188 'cron_inactivated_user_delete_period' 190 $sub_text->allowDecimals(
false);
191 $sub_text->setInfo($this->
lng->txt(
'delete_inactivated_user_accounts_period_desc'));
194 'cron_inactivated_user_delete_period',
195 (
string) self::DEFAULT_INACTIVITY_PERIOD
198 $sub_text->setSize(4);
199 $sub_text->setMaxLength(4);
200 $sub_text->setRequired(
true);
206 $roles = implode(
',', $this->
http->wrapper()->post()->retrieve(
207 'cron_inactivated_user_delete_include_roles',
209 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
214 $period = $this->
http->wrapper()->post()->retrieve(
215 'cron_inactivated_user_delete_period',
217 $this->refinery->kindlyTo()->int(),
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));
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
__construct(Container $dic, ilPlugin $plugin)
ILIAS Refinery Factory $refinery
saveCustomSettings(ilPropertyFormGUI $a_form)
const DEFAULT_INACTIVITY_PERIOD