19declare(strict_types=1);
41 private \ILIAS\HTTP\GlobalHttpState
$http;
49 if (isset(
$DIC[
'http'])) {
50 $this->
http = $DIC[
'http'];
53 if (isset(
$DIC[
'lng'])) {
54 $this->
lng = $DIC[
'lng'];
57 if (isset(
$DIC[
'refinery'])) {
61 if (isset(
$DIC[
'ilObjDataCache'])) {
65 if (isset(
$DIC[
'rbacreview'])) {
66 $this->rbac_review =
$DIC[
'rbacreview'];
69 if (isset(
$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',
91 return "user_inactivated";
96 return $this->
lng->txt(
"delete_inactivated_user_accounts");
102 $this->
lng->txt(
"delete_inactivated_user_accounts_desc"),
109 return JobScheduleType::DAILY;
134 $status = JobResult::STATUS_NO_ACTION;
139 foreach ($usr_ids as $usr_id) {
144 foreach ($this->include_roles as $role_id) {
145 if ($this->rbac_review->isAssigned($usr_id, $role_id)) {
155 $status = JobResult::STATUS_OK;
159 $result->setStatus($status);
167 $this->
lng->txt(
'delete_inactivated_user_accounts_include_roles'),
168 'cron_inactivated_user_delete_include_roles'
170 $sub_mlist->setInfo($this->
lng->txt(
'delete_inactivated_user_accounts_include_roles_desc'));
172 foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
177 $sub_mlist->setOptions($roles);
178 $setting = $this->
settings->get(
'cron_inactivated_user_delete_include_roles',
null);
179 if ($setting ===
null) {
182 $setting = explode(
',', $setting);
184 $sub_mlist->setValue($setting);
185 $sub_mlist->setWidth(300);
189 $this->
lng->txt(
'delete_inactivated_user_accounts_period'),
190 'cron_inactivated_user_delete_period'
192 $sub_text->allowDecimals(
false);
193 $sub_text->setInfo($this->
lng->txt(
'delete_inactivated_user_accounts_period_desc'));
196 'cron_inactivated_user_delete_period',
197 (
string) self::DEFAULT_INACTIVITY_PERIOD
200 $sub_text->setSize(4);
201 $sub_text->setMaxLength(4);
202 $sub_text->setRequired(
true);
208 $roles = implode(
',', $this->
http->wrapper()->post()->retrieve(
209 'cron_inactivated_user_delete_include_roles',
210 $this->refinery->byTrying([
211 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
212 $this->refinery->always([])
216 $period = $this->
http->wrapper()->post()->retrieve(
217 'cron_inactivated_user_delete_period',
219 $this->refinery->kindlyTo()->int(),
220 $this->refinery->always(
null)
224 $this->
settings->set(
'cron_inactivated_user_delete_include_roles', $roles);
225 $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.
ilRbacReview $rbac_review
saveCustomSettings(ilPropertyFormGUI $a_form)
getDefaultScheduleValue()
ILIAS HTTP GlobalHttpState $http
ILIAS Refinery Factory $refinery
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
const DEFAULT_INACTIVITY_PERIOD
static _getUserIdsByInactivationPeriod(int $period)
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.
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc