Skip to content

Commit 04deb0d

Browse files
committed
Component/Mail: contribute cron jobs
1 parent ed0eee2 commit 04deb0d

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

components/ILIAS/Mail/Mail.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,17 @@ public function init(
3838
);
3939
$contribute[Component\Resource\PublicAsset::class] = fn() =>
4040
new Component\Resource\ComponentJS($this, "ilMailComposeFunctions.js");
41+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
42+
new \ilMailCronNotification(
43+
self::class,
44+
$use[\ILIAS\Language\Language::class],
45+
$use[\ILIAS\Logging\LoggerFactory::class]
46+
);
47+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
48+
new \ilMailCronOrphanedMails(
49+
self::class,
50+
$use[\ILIAS\Language\Language::class],
51+
$use[\ILIAS\Logging\LoggerFactory::class]
52+
);
4153
}
4254
}

components/ILIAS/Mail/classes/class.ilMailCronNotification.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@
2828
class ilMailCronNotification extends ilCronJob
2929
{
3030
private GlobalHttpState $http;
31-
protected ilLanguage $lng;
3231
protected ilSetting $settings;
3332
protected bool $initDone = false;
3433

35-
protected function init(): void
34+
public function init(): void
3635
{
36+
$this->lng->loadLanguageModule('mail');
37+
3738
global $DIC;
3839

3940
if (!$this->initDone) {
4041
$this->settings = $DIC->settings();
41-
$this->lng = $DIC->language();
4242
$this->http = $DIC->http();
4343

4444
$this->initDone = true;
@@ -52,17 +52,11 @@ public function getId(): string
5252

5353
public function getTitle(): string
5454
{
55-
$this->init();
56-
5755
return $this->lng->txt('cron_mail_notification');
5856
}
5957

6058
public function getDescription(): string
6159
{
62-
$this->init();
63-
64-
$this->lng->loadLanguageModule('mail');
65-
6660
return sprintf(
6761
$this->lng->txt('cron_mail_notification_desc'),
6862
$this->lng->txt('mail_allow_external')

components/ILIAS/Mail/classes/class.ilMailCronOrphanedMails.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,18 @@ class ilMailCronOrphanedMails extends ilCronJob
3636
{
3737
private GlobalHttpState $http;
3838
private Refinery $refinery;
39-
private ilLanguage $lng;
4039
private ilSetting $settings;
4140
private ilDBInterface $db;
4241
private ilObjUser $user;
4342
private bool $initDone = false;
4443
private ilCronManager $cron_manager;
4544

46-
private function init(): void
45+
public function init(): void
4746
{
4847
global $DIC;
4948

5049
if (!$this->initDone) {
5150
$this->settings = $DIC->settings();
52-
$this->lng = $DIC->language();
5351
$this->db = $DIC->database();
5452
$this->user = $DIC->user();
5553
$this->http = $DIC->http();
@@ -91,13 +89,11 @@ public function getId(): string
9189

9290
public function getTitle(): string
9391
{
94-
$this->init();
9592
return $this->lng->txt('mail_orphaned_mails');
9693
}
9794

9895
public function getDescription(): string
9996
{
100-
$this->init();
10197
return $this->lng->txt('mail_orphaned_mails_desc');
10298
}
10399

components/ILIAS/Mail/service.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
<parent id="adm" max="1">adm</parent>
1111
</object>
1212
</objects>
13-
<crons>
14-
<cron id="mail_notification" class="ilMailCronNotification" />
15-
<cron id="mail_orphaned_mails" class="ilMailCronOrphanedMails" />
16-
</crons>
1713
<mailtemplates>
1814
<context id="mail_template_generic" class="ilMailTemplateGenericContext" />
1915
</mailtemplates>

0 commit comments

Comments
 (0)