ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilMailCronNotification.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
29 {
31  protected ilLanguage $lng;
32  protected ilSetting $settings;
33  protected bool $initDone = false;
34 
35  protected function init(): void
36  {
37  global $DIC;
38 
39  if (!$this->initDone) {
40  $this->settings = $DIC->settings();
41  $this->lng = $DIC->language();
42  $this->http = $DIC->http();
43 
44  $this->initDone = true;
45  }
46  }
47 
48  public function getId(): string
49  {
50  return 'mail_notification';
51  }
52 
53  public function getTitle(): string
54  {
55  $this->init();
56 
57  return $this->lng->txt('cron_mail_notification');
58  }
59 
60  public function getDescription(): string
61  {
62  $this->init();
63 
64  $this->lng->loadLanguageModule('mail');
65 
66  return sprintf(
67  $this->lng->txt('cron_mail_notification_desc'),
68  $this->lng->txt('mail_allow_external')
69  );
70  }
71 
73  {
74  return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
75  }
76 
77  public function getDefaultScheduleValue(): ?int
78  {
79  return null;
80  }
81 
82  public function hasAutoActivation(): bool
83  {
84  return false;
85  }
86 
87  public function hasFlexibleSchedule(): bool
88  {
89  return false;
90  }
91 
92  public function hasCustomSettings(): bool
93  {
94  return true;
95  }
96 
97  public function run(): ilCronJobResult
98  {
99  $msn = new ilMailSummaryNotification();
100  $msn->send();
101 
102  $result = new ilCronJobResult();
103  $result->setStatus(ilCronJobResult::STATUS_OK);
104  return $result;
105  }
106 
107  public function addCustomSettingsToForm(ilPropertyFormGUI $a_form): void
108  {
109  $this->init();
110  $cb = new ilCheckboxInputGUI(
111  $this->lng->txt('cron_mail_notification_message'),
112  'mail_notification_message'
113  );
114  $cb->setInfo($this->lng->txt('cron_mail_notification_message_info'));
115  $cb->setChecked((bool) $this->settings->get('mail_notification_message', '0'));
116  $a_form->addItem($cb);
117  }
118 
119  public function saveCustomSettings(ilPropertyFormGUI $a_form): bool
120  {
121  $this->init();
122  $this->settings->set(
123  'mail_notification_message',
124  (string) ($this->http->wrapper()->post()->has('mail_notification_message') ? 1 : 0)
125  );
126  return true;
127  }
128 
129  public function activationWasToggled(ilDBInterface $db, ilSetting $setting, bool $a_currently_active): void
130  {
131  $setting->set('mail_notification', (string) ((int) $a_currently_active));
132  }
133 }
saveCustomSettings(ilPropertyFormGUI $a_form)
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)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:25
activationWasToggled(ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
addCustomSettingsToForm(ilPropertyFormGUI $a_form)