ILIAS  release_8 Revision v8.24
class.ilIncomingMailInputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected bool $freeOptionChoice = true;
28 protected bool $optionsInitialized = false;
29
30 public function __construct(string $title = '', string $post_var = '', bool $freeOptionChoice = true)
31 {
32 parent::__construct($title, $post_var);
33 $this->setFreeOptionChoice($freeOptionChoice);
34 }
35
36 protected function initializeOptions(): void
37 {
38 if (!$this->optionsInitialized) {
39 $this->addSubOptions();
40 $this->optionsInitialized = true;
41 }
42 }
43
44 public function getOptions(): array
45 {
46 $this->initializeOptions();
47 return parent::getOptions();
48 }
49
50 public function setValueByArray($a_values): void
51 {
52 $this->initializeOptions();
53 parent::setValueByArray($a_values);
54 }
55
56 public function checkInput(): bool
57 {
58 $this->initializeOptions();
59 return parent::checkInput();
60 }
61
62 public function render(): string
63 {
64 $this->initializeOptions();
65 return parent::render();
66 }
67
68 public function getItemByPostVar(string $a_post_var): ?ilFormPropertyGUI
69 {
70 $this->initializeOptions();
71 return parent::getItemByPostVar($a_post_var);
72 }
73
74 public function getSubInputItemsRecursive(): array
75 {
76 $this->initializeOptions();
77 return parent::getSubInputItemsRecursive();
78 }
79
80 public function isFreeOptionChoice(): bool
81 {
83 }
84
85 public function setFreeOptionChoice(bool $freeOptionChoice): void
86 {
87 $this->freeOptionChoice = $freeOptionChoice;
88 }
89
90 private function addSubOptions(): void
91 {
92 global $DIC;
93
94 $incomingLocal = new ilRadioOption(
95 $DIC->language()->txt('mail_incoming_local'),
97 );
98 $incomingLocal->setDisabled($this->getDisabled());
99
100 $incomingExternal = new ilRadioOption(
101 $DIC->language()->txt('mail_incoming_smtp'),
103 );
104 $incomingExternal->setDisabled($this->getDisabled());
105
106 $incomingBoth = new ilRadioOption(
107 $DIC->language()->txt('mail_incoming_both'),
109 );
110 $incomingBoth->setDisabled($this->getDisabled());
111
112 $this->addOption($incomingLocal);
113 $this->addOption($incomingExternal);
114 $this->addOption($incomingBoth);
115
116 $incomingExternalAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option');
117 $incomingExternalAddressChoice->setDisabled($this->getDisabled());
118
119 $sub_mail_opt1 = new ilRadioOption(
120 $DIC->language()->txt('mail_first_email'),
122 );
123 $sub_mail_opt1->setDisabled($this->getDisabled());
124
125 $sub_mail_opt2 = new ilRadioOption(
126 $DIC->language()->txt('mail_second_email'),
128 );
129 $sub_mail_opt2->setDisabled($this->getDisabled());
130 $sub_mail_opt3 = new ilRadioOption(
131 $DIC->language()->txt('mail_both_email'),
133 );
134 $sub_mail_opt3->setDisabled($this->getDisabled());
135
136 $incomingBothAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option_both');
137 $incomingBothAddressChoice->setDisabled($this->getDisabled());
138 $sub_both_opt1 = new ilRadioOption(
139 $DIC->language()->txt('mail_first_email'),
141 );
142 $sub_both_opt1->setDisabled($this->getDisabled());
143
144 $sub_both_opt2 = new ilRadioOption(
145 $DIC->language()->txt('mail_second_email'),
147 );
148 $sub_both_opt2->setDisabled($this->getDisabled());
149 $sub_both_opt3 = new ilRadioOption(
150 $DIC->language()->txt('mail_both_email'),
152 );
153 $sub_both_opt3->setDisabled($this->getDisabled());
154 if (!$this->isFreeOptionChoice()) {
155 $email_info = [];
156 if (
157 $DIC->settings()->get('usr_settings_disable_mail_incoming_mail') === '1') {
158 $this->setDisabled(true);
159 }
160
161 if ($DIC->user()->getEmail() === '') {
162 $sub_mail_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
163 $sub_mail_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
164 $sub_both_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
165 $sub_both_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
166 } else {
167 $email_info[] = $DIC->user()->getEmail();
168 }
169 if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') === '1') {
170 $sub_mail_opt1->setDisabled(true);
171 $sub_mail_opt3->setDisabled(true);
172 $sub_both_opt1->setDisabled(true);
173 $sub_both_opt3->setDisabled(true);
174 }
175
176 if ($DIC->user()->getSecondEmail() === '') {
177 $sub_mail_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
178 $sub_mail_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
179 $sub_both_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
180 $sub_both_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
181 } else {
182 $email_info[] = $DIC->user()->getSecondEmail();
183 }
184 if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') === '1') {
185 $sub_mail_opt2->setDisabled(true);
186 $sub_mail_opt3->setDisabled(true);
187 $sub_both_opt2->setDisabled(true);
188 $sub_both_opt3->setDisabled(true);
189 }
190
191 if (count($email_info) > 1) {
192 $sub_mail_opt1->setInfo($email_info[0]);
193 $sub_both_opt1->setInfo($email_info[0]);
194 $sub_mail_opt2->setInfo($email_info[1]);
195 $sub_both_opt2->setInfo($email_info[1]);
196 $sub_mail_opt3->setInfo(implode(', ', $email_info));
197 $sub_both_opt3->setInfo(implode(', ', $email_info));
198 }
199
200 if (count($email_info) === 1) {
201 $incomingExternal->setInfo($email_info[0]);
202 $incomingBoth->setInfo($email_info[0]);
203 } else {
204 $incomingExternalAddressChoice->addOption($sub_mail_opt1);
205 $incomingExternalAddressChoice->addOption($sub_mail_opt2);
206 $incomingExternalAddressChoice->addOption($sub_mail_opt3);
207
208 $incomingBothAddressChoice->addOption($sub_both_opt1);
209 $incomingBothAddressChoice->addOption($sub_both_opt2);
210 $incomingBothAddressChoice->addOption($sub_both_opt3);
211
212 $incomingExternal->addSubItem($incomingExternalAddressChoice);
213 $incomingBoth->addSubItem($incomingBothAddressChoice);
214 }
215 } else {
216 $incomingExternalAddressChoice->addOption($sub_mail_opt1);
217 $incomingExternalAddressChoice->addOption($sub_mail_opt2);
218 $incomingExternalAddressChoice->addOption($sub_mail_opt3);
219 $incomingBothAddressChoice->addOption($sub_both_opt1);
220 $incomingBothAddressChoice->addOption($sub_both_opt2);
221 $incomingBothAddressChoice->addOption($sub_both_opt3);
222
223 $incomingExternal->addSubItem($incomingExternalAddressChoice);
224 $incomingBoth->addSubItem($incomingBothAddressChoice);
225 }
226 }
227}
This class represents a property in a property form.
setDisabled(bool $a_disabled)
Class ilIncomingMailInputGUI.
setFreeOptionChoice(bool $freeOptionChoice)
getItemByPostVar(string $a_post_var)
Get item by post var.
checkInput()
Check input, strip slashes etc.
getSubInputItemsRecursive()
returns a flat array of possibly existing subitems recursively
__construct(string $title='', string $post_var='', bool $freeOptionChoice=true)
This class represents a property in a property form.
addOption(ilRadioOption $a_option)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc