3declare(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']) {
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',
92 return "user_inactivated";
97 return $this->
lng->txt(
"delete_inactivated_user_accounts");
103 $this->
lng->txt(
"delete_inactivated_user_accounts_desc"),
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'
205 $sub_text->allowDecimals(
false);
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',
223 $this->refinery->byTrying([
224 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
225 $this->refinery->always([])
229 $period = $this->
http->wrapper()->post()->retrieve(
230 'cron_inactivated_user_delete_period',
232 $this->refinery->kindlyTo()->int(),
233 $this->refinery->always(
null)
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));
ilObjectDataCache $objectDataCache
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
saveCustomSettings(ilPropertyFormGUI $a_form)
getDefaultScheduleValue()
ILIAS HTTP GlobalHttpState $http
ILIAS Refinery Factory $refinery
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
const DEFAULT_INACTIVITY_PERIOD
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9
static _getUserIdsByInactivationPeriod(int $period)
get ids of all users that have been inactivated since at least the given period
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
class ilRbacReview Contains Review functions of core Rbac.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
static http()
Fetches the global http state from ILIAS.