3 declare(strict_types=1);
34 private \ILIAS\HTTP\GlobalHttpState
$http;
41 $this->main_tpl = $DIC->ui()->mainTemplate();
44 if (isset($DIC[
'ilSetting'])) {
47 $this->roleIdWhiteliste = (string) $this->
settings->get(
48 'cron_users_without_login_delete_incl_roles',
52 $this->thresholdInDays = (
int) $this->
settings->get(
53 'cron_users_without_login_delete_threshold',
54 (
string) self::DEFAULT_CREATION_THRESHOLD
58 if (isset($DIC[
'lng'])) {
59 $this->
lng = $DIC->language();
60 $this->
lng->loadLanguageModule(
'usr');
63 if (isset($DIC[
'rbacreview'])) {
64 $this->rbacreview = $DIC->rbac()->review();
67 if (isset($DIC[
'ilObjDataCache'])) {
71 if (isset($DIC[
'http'])) {
72 $this->
http = $DIC->http();
75 if (isset($DIC[
'refinery'])) {
83 return 'user_never_logged_in';
90 return $DIC->language()->txt(
'user_never_logged_in');
97 return $DIC->language()->txt(
'user_never_logged_in_info');
102 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
135 $this->thresholdInDays ?: self::DEFAULT_CREATION_THRESHOLD
138 $roleIdWhitelist = array_filter(array_map(
'intval', explode(
',', $this->roleIdWhiteliste)));
141 foreach ($userIds as $userId) {
153 if (count($roleIdWhitelist) > 0) {
154 $assignedRoleIds = array_filter(array_map(
'intval', $this->rbacreview->assignedRoles($userId)));
156 $respectedRolesToInclude = array_intersect($assignedRoleIds, $roleIdWhitelist);
157 if (count($respectedRolesToInclude) > 0) {
166 $DIC->logger()->user()->info(sprintf(
167 "Deleting user account with id %s (login: %s)",
178 $message = sprintf(
'%s user(s) deleted', $counter);
181 $result->setStatus($status);
190 $this->
lng->txt(
'cron_users_without_login_del_role_whitelist'),
193 $roleWhiteList->
setInfo($this->
lng->txt(
'cron_users_without_login_del_role_whitelist_info'));
195 foreach ($this->rbacreview->getGlobalRoles() as $role_id) {
200 $roleWhiteList->setOptions($roles);
201 $roleWhiteList->setValue(array_filter(array_map(
'intval', explode(
',', $this->roleIdWhiteliste))));
202 $roleWhiteList->setWidth(300);
203 $a_form->
addItem($roleWhiteList);
206 $this->
lng->txt(
'cron_users_without_login_del_create_date_thr'),
209 $threshold->allowDecimals(
false);
210 $threshold->setInfo($this->
lng->txt(
'cron_users_without_login_del_create_date_thr_info'));
211 $threshold->setValue((
string) $this->thresholdInDays);
212 $threshold->setSuffix($this->
lng->txt(
'days'));
213 $threshold->setSize(4);
214 $threshold->setMaxLength(4);
215 $threshold->setRequired(
true);
223 $this->roleIdWhiteliste = implode(
',', $this->
http->wrapper()->post()->retrieve(
226 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
232 $this->thresholdInDays = $this->
http->wrapper()->post()->retrieve(
238 $a_form->
getItemByPostVar(
'threshold')->setAlert($this->
lng->txt(
'user_never_logged_in_info_threshold_err_num'));
243 'cron_users_without_login_delete_incl_roles',
244 $this->roleIdWhiteliste
247 'cron_users_without_login_delete_threshold',
248 (
string) $this->thresholdInDays
253 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Refinery Factory $refinery
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
saveCustomSettings(ilPropertyFormGUI $a_form)
ILIAS HTTP GlobalHttpState $http
ilObjectDataCache $objectDataCache
static http()
Fetches the global http state from ILIAS.
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
final const STATUS_NO_ACTION
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
const DEFAULT_CREATION_THRESHOLD
getDefaultScheduleValue()
ilGlobalTemplateInterface $main_tpl
static getUserIdsNeverLoggedIn(int $thresholdInDays)
Get ids of all users that have never logged in.