ILIAS  release_8 Revision v8.24
class.ilMailCronNotification.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28{
30 protected ilLanguage $lng;
32 protected bool $initDone = false;
33
34 protected function init(): void
35 {
36 global $DIC;
37
38 if (!$this->initDone) {
39 $this->settings = $DIC->settings();
40 $this->lng = $DIC->language();
41 $this->http = $DIC->http();
42
43 $this->initDone = true;
44 }
45 }
46
47 public function getId(): string
48 {
49 return 'mail_notification';
50 }
51
52 public function getTitle(): string
53 {
54 $this->init();
55
56 return $this->lng->txt('cron_mail_notification');
57 }
58
59 public function getDescription(): string
60 {
61 $this->init();
62
63 $this->lng->loadLanguageModule('mail');
64
65 return sprintf(
66 $this->lng->txt('cron_mail_notification_desc'),
67 $this->lng->txt('mail_allow_external')
68 );
69 }
70
71 public function getDefaultScheduleType(): int
72 {
74 }
75
76 public function getDefaultScheduleValue(): ?int
77 {
78 return null;
79 }
80
81 public function hasAutoActivation(): bool
82 {
83 return false;
84 }
85
86 public function hasFlexibleSchedule(): bool
87 {
88 return false;
89 }
90
91 public function hasCustomSettings(): bool
92 {
93 return true;
94 }
95
96 public function run(): ilCronJobResult
97 {
98 $msn = new ilMailSummaryNotification();
99 $msn->send();
100
101 $result = new ilCronJobResult();
102 $result->setStatus(ilCronJobResult::STATUS_OK);
103 return $result;
104 }
105
106 public function addCustomSettingsToForm(ilPropertyFormGUI $a_form): void
107 {
108 $this->init();
109 $cb = new ilCheckboxInputGUI(
110 $this->lng->txt('cron_mail_notification_message'),
111 'mail_notification_message'
112 );
113 $cb->setInfo($this->lng->txt('cron_mail_notification_message_info'));
114 $cb->setChecked((bool) $this->settings->get('mail_notification_message', '0'));
115 $a_form->addItem($cb);
116 }
117
118 public function saveCustomSettings(ilPropertyFormGUI $a_form): bool
119 {
120 $this->init();
121 $this->settings->set(
122 'mail_notification_message',
123 (string) ($this->http->wrapper()->post()->has('mail_notification_message') ? 1 : 0)
124 );
125 return true;
126 }
127
128 public function activationWasToggled(ilDBInterface $db, ilSetting $setting, bool $a_currently_active): void
129 {
130 $setting->set('mail_notification', (string) ((int) $a_currently_active));
131 }
132}
This class represents a checkbox property in a property form.
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9
language handling
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
saveCustomSettings(ilPropertyFormGUI $a_form)
activationWasToggled(ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
Important: This method is (also) called from the setup process, where the constructor of an ilCronJob...
This class represents a property form user interface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
set(string $a_key, string $a_val)
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
Interface ilDBInterface.
static http()
Fetches the global http state from ILIAS.