ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMailCronNotification.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
27{
29 protected ilLanguage $lng;
31 protected bool $init_done = false;
32
33 protected function init(): void
34 {
35 global $DIC;
36
37 if (!$this->init_done) {
38 $this->settings = $DIC->settings();
39 $this->lng = $DIC->language();
40 $this->http = $DIC->http();
41
42 $this->init_done = true;
43 }
44 }
45
46 public function getId(): string
47 {
48 return 'mail_notification';
49 }
50
51 public function getTitle(): string
52 {
53 $this->init();
54
55 return $this->lng->txt('cron_mail_notification');
56 }
57
58 public function getDescription(): string
59 {
60 $this->init();
61
62 $this->lng->loadLanguageModule('mail');
63
64 return sprintf(
65 $this->lng->txt('cron_mail_notification_desc'),
66 $this->lng->txt('mail_allow_external')
67 );
68 }
69
71 {
72 return JobScheduleType::DAILY;
73 }
74
75 public function getDefaultScheduleValue(): ?int
76 {
77 return null;
78 }
79
80 public function hasAutoActivation(): bool
81 {
82 return false;
83 }
84
85 public function hasFlexibleSchedule(): bool
86 {
87 return false;
88 }
89
90 public function hasCustomSettings(): bool
91 {
92 return true;
93 }
94
95 public function usesLegacyForms(): bool
96 {
97 return false;
98 }
99
101 \ILIAS\UI\Factory $ui_factory,
102 \ILIAS\Refinery\Factory $factory,
104 ): \ILIAS\UI\Component\Input\Container\Form\FormInput {
105 $status = $ui_factory
106 ->input()
107 ->field()
108 ->checkbox($this->lng->txt('cron_mail_notification_message'))
109 ->withByline($this->lng->txt('cron_mail_notification_message_info'))
110 ->withValue((bool) $this->settings->get('mail_notification_message', '0'))
111 ->withDedicatedName('mail_notification_message');
112
113 return $status;
114 }
115
116 public function saveCustomConfiguration(mixed $form_data): void
117 {
118 $this->init();
119 $this->settings->set(
120 'mail_notification_message',
121 (string) ((int) $form_data)
122 );
123 }
124
125 public function run(): JobResult
126 {
127 $msn = new ilMailSummaryNotification();
128 $msn->send();
129
130 $result = new JobResult();
131 $result->setStatus(JobResult::STATUS_OK);
132 return $result;
133 }
134
135 public function addCustomSettingsToForm(ilPropertyFormGUI $a_form): void
136 {
137 throw new RuntimeException('Not implemented');
138 }
139
140 public function saveCustomSettings(ilPropertyFormGUI $a_form): bool
141 {
142 throw new RuntimeException('Not implemented');
143 }
144
145 public function activationWasToggled(ilDBInterface $db, ilSetting $setting, bool $a_currently_active): void
146 {
147 $setting->set('mail_notification', (string) ((int) $a_currently_active));
148 }
149}
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)
getCustomConfigurationInput(\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, ilLanguage $lng)
This class represents a property form user interface.
ILIAS Setting Class.
set(string $a_key, string $a_val)
Interface GlobalHttpState.
Interface ilDBInterface.
static http()
Fetches the global http state from ILIAS.
get(string $class_name)
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26