40 if (isset($DIC[
'ilSetting'])) {
43 $this->roleIdWhiteliste = (string) $this->
settings->get(
44 'cron_users_without_login_delete_incl_roles',
48 $this->thresholdInDays = (int) $this->
settings->get(
49 'cron_users_without_login_delete_threshold',
50 self::DEFAULT_CREATION_THRESHOLD
54 if (isset($DIC[
'lng'])) {
55 $this->lng = $DIC->language();
56 $this->lng->loadLanguageModule(
'usr');
59 if (isset($DIC[
'rbacreview'])) {
60 $this->rbacreview = $DIC->rbac()->review();
63 if (isset($DIC[
'ilObjDataCache'])) {
64 $this->objectDataCache = $DIC[
'ilObjDataCache'];
67 if (isset($DIC[
'http'])) {
68 $this->request = $DIC->http()->request();
78 return 'user_never_logged_in';
88 return $DIC->language()->txt(
'user_never_logged_in');
98 return $DIC->language()->txt(
'user_never_logged_in_info');
106 return self::SCHEDULE_TYPE_DAILY;
148 $result = new \ilCronJobResult();
154 $this->thresholdInDays ?: self::DEFAULT_CREATION_THRESHOLD
157 $roleIdWhitelist = array_filter(array_map(
'intval', explode(
',', $this->roleIdWhiteliste)));
160 foreach ($userIds as $userId) {
166 if (!$user || !($user instanceof \
ilObjUser)) {
172 if (count($roleIdWhitelist) > 0) {
173 $assignedRoleIds = array_filter(array_map(
'intval', (array) $this->rbacreview->assignedRoles($userId)));
175 $respectedRolesToInclude = array_intersect($assignedRoleIds, $roleIdWhitelist);
176 if (count($respectedRolesToInclude) > 0) {
185 $DIC->logger()->usr()->info(sprintf(
186 "Deleting user account with id %s (login: %s)",
197 $message = sprintf(
'%s user(s) deleted', $counter);
212 $this->lng->txt(
'cron_users_without_login_del_role_whitelist'),
215 $roleWhiteList->
setInfo($this->lng->txt(
'cron_users_without_login_del_role_whitelist_info'));
217 foreach ($this->rbacreview->getGlobalRoles() as $role_id) {
219 $roles[$role_id] = $this->objectDataCache->lookupTitle($role_id);
222 $roleWhiteList->setOptions($roles);
223 $roleWhiteList->setValue(array_filter(array_map(
'intval', explode(
',', $this->roleIdWhiteliste))));
224 $roleWhiteList->setWidth(300);
225 $a_form->
addItem($roleWhiteList);
228 $this->lng->txt(
'cron_users_without_login_del_create_date_thr'),
231 $threshold->
setInfo($this->lng->txt(
'cron_users_without_login_del_create_date_thr_info'));
232 $threshold->setValue($this->thresholdInDays);
233 $threshold->setSuffix($this->lng->txt(
'days'));
234 $threshold->setSize(4);
235 $threshold->setMaxLength(4);
236 $threshold->setRequired(
true);
247 $roleIdWhitelist = $this->request->getParsedBody()[
'role_whitelist'] ?? [];
248 $this->roleIdWhiteliste = implode(
',', array_map(
'intval', (is_array($roleIdWhitelist) ? $roleIdWhitelist : [])));
250 $this->thresholdInDays = $this->request->getParsedBody()[
'threshold'] ??
'';
252 if (!is_numeric($this->thresholdInDays) || $this->
hasDecimals($this->thresholdInDays)) {
254 $a_form->
getItemByPostVar(
'threshold')->setAlert($this->lng->txt(
'user_never_logged_in_info_threshold_err_num'));
259 'cron_users_without_login_delete_incl_roles',
260 (
string) $this->roleIdWhiteliste
263 'cron_users_without_login_delete_threshold',
264 (
int) $this->thresholdInDays
279 if (strpos($number,
',') !==
false || strpos($number,
'.') !==
false) {
Cron job application base class.
const SYSTEM_USER_ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveCustomSettings(\ilPropertyFormGUI $a_form)
__construct()
ilCronDeleteNeverLoggedInUserAccounts constructor.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const DEFAULT_CREATION_THRESHOLD
getDefaultScheduleValue()
addCustomSettingsToForm(\ilPropertyFormGUI $a_form)
static getUserIdsNeverLoggedIn(int $thresholdInDays)
Get ids of all users that have never logged in.
Class ilCronDeleteNeverLoggedInUserAccounts.