ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilIncomingMailInputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 protected bool $free_option_choice = true;
26 protected bool $options_initialized = false;
27
28 public function __construct(string $title = '', string $post_var = '', bool $free_option_choice = true)
29 {
30 parent::__construct($title, $post_var);
31 $this->setFreeOptionChoice($free_option_choice);
32 }
33
34 protected function initializeOptions(): void
35 {
36 if (!$this->options_initialized) {
37 $this->addSubOptions();
38 $this->options_initialized = true;
39 }
40 }
41
42 public function getOptions(): array
43 {
44 $this->initializeOptions();
45 return parent::getOptions();
46 }
47
48 public function setValueByArray($a_values): void
49 {
50 $this->initializeOptions();
51 parent::setValueByArray($a_values);
52 }
53
54 public function checkInput(): bool
55 {
56 $this->initializeOptions();
57 return parent::checkInput();
58 }
59
60 public function render(): string
61 {
62 $this->initializeOptions();
63 return parent::render();
64 }
65
66 public function getItemByPostVar(string $a_post_var): ?ilFormPropertyGUI
67 {
68 $this->initializeOptions();
69 return parent::getItemByPostVar($a_post_var);
70 }
71
72 public function getSubInputItemsRecursive(): array
73 {
74 $this->initializeOptions();
75 return parent::getSubInputItemsRecursive();
76 }
77
78 public function isFreeOptionChoice(): bool
79 {
81 }
82
83 public function setFreeOptionChoice(bool $free_option_choice): void
84 {
85 $this->free_option_choice = $free_option_choice;
86 }
87
88 private function addSubOptions(): void
89 {
90 global $DIC;
91
92 $incoming_mail_changable_by_user = $DIC['user']->getSettings()
93 ->getSettingByDefinitionClass(IncomingMail::class)->isChangeableByUser();
94
95 $incoming_local = new ilRadioOption(
96 $DIC->language()->txt('mail_incoming_local'),
98 );
99 $incoming_local->setDisabled($this->getDisabled());
100
101 $incoming_external = new ilRadioOption(
102 $DIC->language()->txt('mail_incoming_smtp'),
104 );
105 $incoming_external->setDisabled($this->getDisabled());
106
107 $incoming_both = new ilRadioOption(
108 $DIC->language()->txt('mail_incoming_both'),
110 );
111 $incoming_both->setDisabled($this->getDisabled());
112
113 $this->addOption($incoming_local);
114 $this->addOption($incoming_external);
115 $this->addOption($incoming_both);
116
117 $incoming_external_address_choice = new ilRadioGroupInputGUI('', 'mail_address_option');
118 $incoming_external_address_choice->setDisabled($this->getDisabled());
119
120 $sub_mail_opt1 = new ilRadioOption(
121 $DIC->language()->txt('mail_first_email'),
123 );
124 $sub_mail_opt1->setDisabled($this->getDisabled());
125
126 $sub_mail_opt2 = new ilRadioOption(
127 $DIC->language()->txt('mail_second_email'),
129 );
130 $sub_mail_opt2->setDisabled($this->getDisabled());
131 $sub_mail_opt3 = new ilRadioOption(
132 $DIC->language()->txt('mail_both_email'),
134 );
135 $sub_mail_opt3->setDisabled($this->getDisabled());
136
137 $incoming_both_address_choice = new ilRadioGroupInputGUI('', 'mail_address_option_both');
138 $incoming_both_address_choice->setDisabled($this->getDisabled());
139 $sub_both_opt1 = new ilRadioOption(
140 $DIC->language()->txt('mail_first_email'),
142 );
143 $sub_both_opt1->setDisabled($this->getDisabled());
144
145 $sub_both_opt2 = new ilRadioOption(
146 $DIC->language()->txt('mail_second_email'),
148 );
149 $sub_both_opt2->setDisabled($this->getDisabled());
150 $sub_both_opt3 = new ilRadioOption(
151 $DIC->language()->txt('mail_both_email'),
153 );
154 $sub_both_opt3->setDisabled($this->getDisabled());
155 if ($this->isFreeOptionChoice()) {
156 $incoming_external_address_choice->addOption($sub_mail_opt1);
157 $incoming_external_address_choice->addOption($sub_mail_opt2);
158 $incoming_external_address_choice->addOption($sub_mail_opt3);
159 $incoming_both_address_choice->addOption($sub_both_opt1);
160 $incoming_both_address_choice->addOption($sub_both_opt2);
161 $incoming_both_address_choice->addOption($sub_both_opt3);
162
163 $incoming_external->addSubItem($incoming_external_address_choice);
164 $incoming_both->addSubItem($incoming_both_address_choice);
165 } else {
166 $email_info = [];
167 if (
168 $DIC->settings()->get('usr_settings_disable_mail_incoming_mail') === '1') {
169 $this->setDisabled(true);
170 }
171
172 if ($DIC->user()->getEmail() === '') {
173 $sub_mail_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
174 $sub_mail_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
175 $sub_both_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
176 $sub_both_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
177 } else {
178 $email_info[] = $DIC->user()->getEmail();
179 }
180 if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') === '1') {
181 $sub_mail_opt1->setDisabled(true);
182 $sub_mail_opt3->setDisabled(true);
183 $sub_both_opt1->setDisabled(true);
184 $sub_both_opt3->setDisabled(true);
185 }
186
187 if ($DIC->user()->getSecondEmail() === '') {
188 $sub_mail_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
189 $sub_mail_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
190 $sub_both_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
191 $sub_both_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
192 } else {
193 $email_info[] = $DIC->user()->getSecondEmail();
194 }
195 if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') === '1') {
196 $sub_mail_opt2->setDisabled(true);
197 $sub_mail_opt3->setDisabled(true);
198 $sub_both_opt2->setDisabled(true);
199 $sub_both_opt3->setDisabled(true);
200 }
201
202 if (count($email_info) > 1) {
203 $sub_mail_opt1->setInfo($email_info[0]);
204 $sub_both_opt1->setInfo($email_info[0]);
205 $sub_mail_opt2->setInfo($email_info[1]);
206 $sub_both_opt2->setInfo($email_info[1]);
207 $sub_mail_opt3->setInfo(implode(', ', $email_info));
208 $sub_both_opt3->setInfo(implode(', ', $email_info));
209 }
210
211 if (count($email_info) === 1) {
212 $incoming_external->setInfo($email_info[0]);
213 $incoming_both->setInfo($email_info[0]);
214 } else {
215 $incoming_external_address_choice->addOption($sub_mail_opt1);
216 $incoming_external_address_choice->addOption($sub_mail_opt2);
217 $incoming_external_address_choice->addOption($sub_mail_opt3);
218
219 $incoming_both_address_choice->addOption($sub_both_opt1);
220 $incoming_both_address_choice->addOption($sub_both_opt2);
221 $incoming_both_address_choice->addOption($sub_both_opt3);
222
223 $incoming_external->addSubItem($incoming_external_address_choice);
224 $incoming_both->addSubItem($incoming_both_address_choice);
225 }
226 }
227 }
228}
This class represents a property in a property form.
setDisabled(bool $a_disabled)
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 $free_option_choice=true)
setFreeOptionChoice(bool $free_option_choice)
final const int INCOMING_BOTH
final const int FIRST_EMAIL
final const int INCOMING_LOCAL
final const int BOTH_EMAIL
final const int INCOMING_EMAIL
final const int SECOND_EMAIL
This class represents a property in a property form.
addOption(ilRadioOption $a_option)
This class represents an option in a radio group.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26