19 declare(strict_types=1);
36 private \ILIAS\HTTP\GlobalHttpState
$http;
43 $this->main_tpl = $DIC->ui()->mainTemplate();
46 if (isset($DIC[
'ilSetting'])) {
49 $this->roleIdWhiteliste = (string) $this->
settings->get(
50 'cron_users_without_login_delete_incl_roles',
54 $this->thresholdInDays = (
int) $this->
settings->get(
55 'cron_users_without_login_delete_threshold',
56 (
string) self::DEFAULT_CREATION_THRESHOLD
60 if (isset($DIC[
'lng'])) {
61 $this->
lng = $DIC->language();
62 $this->
lng->loadLanguageModule(
'usr');
65 if (isset($DIC[
'rbacreview'])) {
66 $this->rbacreview = $DIC->rbac()->review();
69 if (isset($DIC[
'ilObjDataCache'])) {
73 if (isset($DIC[
'http'])) {
74 $this->
http = $DIC->http();
77 if (isset($DIC[
'refinery'])) {
85 return 'user_never_logged_in';
92 return $DIC->language()->txt(
'user_never_logged_in');
99 return $DIC->language()->txt(
'user_never_logged_in_info');
104 return JobScheduleType::DAILY;
133 $status = JobResult::STATUS_NO_ACTION;
137 $this->thresholdInDays ?: self::DEFAULT_CREATION_THRESHOLD
140 $roleIdWhitelist = array_filter(
array_map(
'intval', explode(
',', $this->roleIdWhiteliste)));
143 foreach ($userIds as $userId) {
155 if (count($roleIdWhitelist) > 0) {
156 $assignedRoleIds = array_filter(
array_map(
'intval', $this->rbacreview->assignedRoles($userId)));
158 $respectedRolesToInclude = array_intersect($assignedRoleIds, $roleIdWhitelist);
159 if (count($respectedRolesToInclude) > 0) {
168 $DIC->logger()->user()->info(sprintf(
169 "Deleting user account with id %s (login: %s)",
179 $status = JobResult::STATUS_OK;
180 $message = sprintf(
'%s user(s) deleted', $counter);
183 $result->setStatus($status);
192 $this->
lng->txt(
'cron_users_without_login_del_role_whitelist'),
195 $roleWhiteList->
setInfo($this->
lng->txt(
'cron_users_without_login_del_role_whitelist_info'));
197 foreach ($this->rbacreview->getGlobalRoles() as $role_id) {
202 $roleWhiteList->setOptions($roles);
203 $roleWhiteList->setValue(array_filter(
array_map(
'intval', explode(
',', $this->roleIdWhiteliste))));
204 $roleWhiteList->setWidth(300);
205 $a_form->
addItem($roleWhiteList);
208 $this->
lng->txt(
'cron_users_without_login_del_create_date_thr'),
212 $threshold->setInfo($this->
lng->txt(
'cron_users_without_login_del_create_date_thr_info'));
213 $threshold->setValue((
string) $this->thresholdInDays);
214 $threshold->setSuffix($this->
lng->txt(
'days'));
215 $threshold->setSize(4);
216 $threshold->setMaxLength(4);
217 $threshold->setRequired(
true);
225 $this->roleIdWhiteliste = implode(
',', $this->
http->wrapper()->post()->retrieve(
228 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
234 $this->thresholdInDays = $this->
http->wrapper()->post()->retrieve(
240 $a_form->
getItemByPostVar(
'threshold')->setAlert($this->
lng->txt(
'user_never_logged_in_info_threshold_err_num'));
245 'cron_users_without_login_delete_incl_roles',
246 $this->roleIdWhiteliste
249 'cron_users_without_login_delete_threshold',
250 (
string) $this->thresholdInDays
255 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
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)
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.