Skip to content

Commit 5469618

Browse files
committed
Component/User: contribute cron jobs
1 parent 858b1c9 commit 5469618

6 files changed

Lines changed: 79 additions & 33 deletions

components/ILIAS/User/User.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
namespace ILIAS;
2222

2323
use ILIAS\User\Setup\Agent;
24-
2524
use ILIAS\Setup\Agent as SetupAgent;
2625
use ILIAS\Refinery\Factory as Refinery;
2726

@@ -41,5 +40,30 @@ public function init(
4140
new Agent(
4241
$pull[Refinery::class]
4342
);
43+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
44+
new \ilCronDeleteInactiveUserAccounts(
45+
'components\\' . self::class,
46+
$use[\ILIAS\Language\Language::class],
47+
true
48+
);
49+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
50+
new \ilCronDeleteInactivatedUserAccounts(
51+
'components\\' . self::class,
52+
$use[\ILIAS\Language\Language::class],
53+
true
54+
);
55+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
56+
new \ilUserCronCheckAccounts(
57+
'components\\' . self::class,
58+
$use[\ILIAS\Language\Language::class],
59+
true
60+
);
61+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
62+
new \ilCronDeleteNeverLoggedInUserAccounts(
63+
'components\\' . self::class,
64+
$use[\ILIAS\Language\Language::class],
65+
true
66+
);
67+
4468
}
4569
}

components/ILIAS/User/classes/Cron/class.ilCronDeleteInactivatedUserAccounts.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,24 @@ class ilCronDeleteInactivatedUserAccounts extends ilCronJob
3333
/** @var int[] */
3434
private array $include_roles;
3535
private ilSetting $settings;
36-
private Language $lng;
3736
private ilRbacReview $rbac_review;
3837
private ilObjectDataCache $objectDataCache;
3938
private \ILIAS\HTTP\GlobalHttpState $http;
4039
private \ILIAS\Refinery\Factory $refinery;
4140

42-
public function __construct()
41+
public function __construct(
42+
string $component,
43+
\ILIAS\Language\Language $lng,
44+
bool $registration = false
45+
) {
46+
parent::__construct($component, $lng);
47+
$this->lng->loadLanguageModule('usr');
48+
if (!$registration) {
49+
$this->additionalConstruct();
50+
}
51+
}
52+
53+
private function additionalConstruct()
4354
{
4455
/** @var ILIAS\DI\Container $DIC */
4556
global $DIC;
@@ -48,10 +59,6 @@ public function __construct()
4859
$this->http = $DIC['http'];
4960
}
5061

51-
if (isset($DIC['lng'])) {
52-
$this->lng = $DIC['lng'];
53-
}
54-
5562
if (isset($DIC['refinery'])) {
5663
$this->refinery = $DIC['refinery'];
5764
}

components/ILIAS/User/classes/Cron/class.ilCronDeleteInactiveUserAccounts.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class ilCronDeleteInactiveUserAccounts extends ilCronJob
4242
private array $include_roles;
4343
private ilCronDeleteInactiveUserReminderMail $cron_delete_reminder_mail;
4444
private ilSetting $settings;
45-
private Language $lng;
4645
private ilComponentLogger $log;
4746
private ilRbacReview $rbac_review;
4847
private ilObjectDataCache $objectDataCache;
@@ -51,7 +50,19 @@ class ilCronDeleteInactiveUserAccounts extends ilCronJob
5150
private ilCronJobRepository $cronRepository;
5251
private \ilGlobalTemplateInterface $main_tpl;
5352

54-
public function __construct()
53+
public function __construct(
54+
string $component,
55+
\ILIAS\Language\Language $lng,
56+
bool $registration = false
57+
) {
58+
parent::__construct($component, $lng);
59+
$this->lng->loadLanguageModule('usr');
60+
if (!$registration) {
61+
$this->additionalConstruct();
62+
}
63+
}
64+
65+
private function additionalConstruct()
5566
{
5667
/** @var ILIAS\DI\Container $DIC */
5768
global $DIC;
@@ -67,10 +78,6 @@ public function __construct()
6778
$this->http = $DIC['http'];
6879
}
6980

70-
if (isset($DIC['lng'])) {
71-
$this->lng = $DIC['lng'];
72-
}
73-
7481
if (isset($DIC['ilLog'])) {
7582
$this->log = $DIC['ilLog'];
7683
}
@@ -259,7 +266,7 @@ private function deleteUserOrSendReminderMail($usr_id): int
259266
if ($this->reminder_period > 0) {
260267
$timestamp_for_deletion = $timestamp_last_login - $grace_period_over;
261268
$account_will_be_deleted_on = $this->calculateDeletionData($timestamp_for_deletion);
262-
if(
269+
if (
263270
$this->cron_delete_reminder_mail->sendReminderMailIfNeeded(
264271
$user,
265272
$this->reminder_period,

components/ILIAS/User/classes/Cron/class.ilCronDeleteNeverLoggedInUserAccounts.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,27 @@ class ilCronDeleteNeverLoggedInUserAccounts extends \ilCronJob
2828

2929
private string $roleIdWhiteliste = '';
3030
private int $thresholdInDays = self::DEFAULT_CREATION_THRESHOLD;
31-
private Language $lng;
3231
private ilSetting $settings;
3332
private ilRbacReview $rbacreview;
3433
private ilObjectDataCache $objectDataCache;
3534
private \ILIAS\HTTP\GlobalHttpState $http;
3635
private \ILIAS\Refinery\Factory $refinery;
3736
private \ilGlobalTemplateInterface $main_tpl;
3837

39-
public function __construct()
38+
39+
public function __construct(
40+
string $component,
41+
\ILIAS\Language\Language $lng,
42+
bool $registration = false
43+
) {
44+
parent::__construct($component, $lng);
45+
$this->lng->loadLanguageModule('usr');
46+
if (!$registration) {
47+
$this->additionalConstruct();
48+
}
49+
}
50+
51+
private function additionalConstruct()
4052
{
4153
global $DIC;
4254
$this->main_tpl = $DIC->ui()->mainTemplate();
@@ -56,11 +68,6 @@ public function __construct()
5668
);
5769
}
5870

59-
if (isset($DIC['lng'])) {
60-
$this->lng = $DIC->language();
61-
$this->lng->loadLanguageModule('usr');
62-
}
63-
6471
if (isset($DIC['rbacreview'])) {
6572
$this->rbacreview = $DIC->rbac()->review();
6673
}

components/ILIAS/User/classes/Cron/class.ilUserCronCheckAccounts.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,21 @@ class ilUserCronCheckAccounts extends ilCronJob
2929
protected int $counter = 0;
3030

3131
private ilDBInterface $db;
32-
private ilLanguage $lng;
3332
private ilComponentLogger $log;
3433

35-
public function __construct()
34+
public function __construct(
35+
string $component,
36+
\ILIAS\Language\Language $lng,
37+
bool $registration = false
38+
) {
39+
parent::__construct($component, $lng);
40+
$this->lng->loadLanguageModule('usr');
41+
if (!$registration) {
42+
$this->additionalConstruct();
43+
}
44+
}
45+
46+
private function additionalConstruct()
3647
{
3748
/** @var ILIAS\DI\Container $DIC */
3849
global $DIC;
@@ -41,10 +52,6 @@ public function __construct()
4152
$this->db = $DIC['ilDB'];
4253
}
4354

44-
if (isset($DIC['lng'])) {
45-
$this->lng = $DIC['lng'];
46-
}
47-
4855
if (isset($DIC['ilDB'])) {
4956
$this->log = $DIC['ilLog'];
5057
}

components/ILIAS/User/service.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
<event type="listen" id="components/ILIAS/Object" />
2323
<event type="listen" id="components/ILIAS/TermsOfService" />
2424
</events>
25-
<crons>
26-
<cron id="user_inactive" class="ilCronDeleteInactiveUserAccounts" />
27-
<cron id="user_inactivated" class="ilCronDeleteInactivatedUserAccounts" />
28-
<cron id="user_check_accounts" class="ilUserCronCheckAccounts" />
29-
<cron id="user_never_logged_in" class="ilCronDeleteNeverLoggedInUserAccounts" />
30-
</crons>
3125
<pluginslots>
3226
<pluginslot id="udfc" name="UDFClaiming" />
3327
<pluginslot id="udfd" name="UDFDefinition" />

0 commit comments

Comments
 (0)