19 declare(strict_types=1);
35 private \ILIAS\HTTP\GlobalHttpState
$http;
42 $this->main_tpl = $DIC->ui()->mainTemplate();
45 if (isset($DIC[
'ilSetting'])) {
48 $this->roleIdWhiteliste = (string) $this->
settings->get(
49 'cron_users_without_login_delete_incl_roles',
53 $this->thresholdInDays = (
int) $this->
settings->get(
54 'cron_users_without_login_delete_threshold',
55 (
string) self::DEFAULT_CREATION_THRESHOLD
59 if (isset($DIC[
'lng'])) {
60 $this->
lng = $DIC->language();
61 $this->
lng->loadLanguageModule(
'usr');
64 if (isset($DIC[
'rbacreview'])) {
65 $this->rbacreview = $DIC->rbac()->review();
68 if (isset($DIC[
'ilObjDataCache'])) {
72 if (isset($DIC[
'http'])) {
73 $this->
http = $DIC->http();
76 if (isset($DIC[
'refinery'])) {
84 return 'user_never_logged_in';
91 return $DIC->language()->txt(
'user_never_logged_in');
98 return $DIC->language()->txt(
'user_never_logged_in_info');
103 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
133 $message =
'No user deleted';
136 $this->thresholdInDays ?: self::DEFAULT_CREATION_THRESHOLD
139 $roleIdWhitelist = array_filter(
array_map(
'intval', explode(
',', $this->roleIdWhiteliste)));
142 foreach ($userIds as $userId) {
154 if (count($roleIdWhitelist) > 0) {
155 $assignedRoleIds = array_filter(
array_map(
'intval', $this->rbacreview->assignedRoles($userId)));
157 $respectedRolesToInclude = array_intersect($assignedRoleIds, $roleIdWhitelist);
158 if (count($respectedRolesToInclude) > 0) {
167 $DIC->logger()->user()->info(sprintf(
168 "Deleting user account with id %s (login: %s)",
179 $message = sprintf(
'%s user(s) deleted', $counter);
182 $result->setStatus($status);
183 $result->setMessage($message);
191 $this->
lng->txt(
'cron_users_without_login_del_role_whitelist'),
194 $roleWhiteList->
setInfo($this->
lng->txt(
'cron_users_without_login_del_role_whitelist_info'));
196 foreach ($this->rbacreview->getGlobalRoles() as $role_id) {
201 $roleWhiteList->setOptions($roles);
202 $roleWhiteList->setValue(array_filter(
array_map(
'intval', explode(
',', $this->roleIdWhiteliste))));
203 $roleWhiteList->setWidth(300);
204 $a_form->
addItem($roleWhiteList);
207 $this->
lng->txt(
'cron_users_without_login_del_create_date_thr'),
210 $threshold->allowDecimals(
false);
211 $threshold->setInfo($this->
lng->txt(
'cron_users_without_login_del_create_date_thr_info'));
212 $threshold->setValue((
string) $this->thresholdInDays);
213 $threshold->setSuffix($this->
lng->txt(
'days'));
214 $threshold->setSize(4);
215 $threshold->setMaxLength(4);
216 $threshold->setRequired(
true);
224 $this->roleIdWhiteliste = implode(
',', $this->
http->wrapper()->post()->retrieve(
227 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
233 $this->thresholdInDays = $this->
http->wrapper()->post()->retrieve(
239 $a_form->
getItemByPostVar(
'threshold')->setAlert($this->
lng->txt(
'user_never_logged_in_info_threshold_err_num'));
244 'cron_users_without_login_delete_incl_roles',
245 $this->roleIdWhiteliste
248 'cron_users_without_login_delete_threshold',
249 (
string) $this->thresholdInDays
254 $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.