ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilIncomingMailInputGUI.php
Go to the documentation of this file.
1<?php
2 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4 require_once 'Services/Mail/classes/class.ilMailOptions.php';
5 require_once 'Services/Form/classes/class.ilRadioGroupInputGUI.php';
6 require_once 'Services/Form/classes/class.ilRadioOption.php';
7
13 {
17 protected $freeOptionChoice = true;
18
22 protected $optionsInitialized = false;
23
30 public function __construct($title = '', $post_var = '', $freeOptionChoice = true)
31 {
32 parent::__construct($title, $post_var);
34 }
35
39 protected function initializeOptions()
40 {
41 if (!$this->optionsInitialized) {
42 $this->addSubOptions();
43 $this->optionsInitialized = true;
44 }
45 }
46
50 function getOptions()
51 {
52 $this->initializeOptions();
53 return parent::getOptions();
54 }
55
59 function setValueByArray($a_values)
60 {
61 $this->initializeOptions();
62 parent::setValueByArray($a_values);
63 }
64
68 function checkInput()
69 {
70 $this->initializeOptions();
71 return parent::checkInput();
72 }
73
77 function render()
78 {
79 $this->initializeOptions();
80 return parent::render();
81 }
82
86 function getItemByPostVar($a_post_var)
87 {
88 $this->initializeOptions();
89 return parent::getItemByPostVar($a_post_var);
90 }
91
95 public function getSubInputItemsRecursive()
96 {
97 $this->initializeOptions();
98 return parent::getSubInputItemsRecursive();
99 }
100
104 public function isFreeOptionChoice()
105 {
107 }
108
113 {
114 $this->freeOptionChoice = $freeOptionChoice;
115 }
116
120 private function addSubOptions()
121 {
122 global $DIC;
123
124 $incomingLocal = new ilRadioOption($DIC->language()->txt('mail_incoming_local'),
126 $incomingLocal->setDisabled($this->getDisabled());
127
128 $incomingExternal = new ilRadioOption($DIC->language()->txt('mail_incoming_smtp'),
130 $incomingExternal->setDisabled($this->getDisabled());
131
132 $incomingBoth = new ilRadioOption($DIC->language()->txt('mail_incoming_both'),
134 $incomingBoth->setDisabled($this->getDisabled());
135
136 $this->addOption($incomingLocal);
137 $this->addOption($incomingExternal);
138 $this->addOption($incomingBoth);
139
140 $incomingExternalAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option');
141 $incomingExternalAddressChoice->setDisabled($this->getDisabled());
142
143 $sub_mail_opt1 = new ilRadioOption($DIC->language()->txt('mail_first_email'), ilMailOptions::FIRST_EMAIL);
144 $sub_mail_opt1->setDisabled($this->getDisabled());
145
146 $sub_mail_opt2 = new ilRadioOption($DIC->language()->txt('mail_second_email'), ilMailOptions::SECOND_EMAIL);
147 $sub_mail_opt2->setDisabled($this->getDisabled());
148 $sub_mail_opt3 = new ilRadioOption($DIC->language()->txt('mail_both_email'), ilMailOptions::BOTH_EMAIL);
149 $sub_mail_opt3->setDisabled($this->getDisabled());
150
151 $incomingBothAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option_both');
152 $incomingBothAddressChoice->setDisabled($this->getDisabled());
153 $sub_both_opt1 = new ilRadioOption($DIC->language()->txt('mail_first_email'), ilMailOptions::FIRST_EMAIL);
154 $sub_both_opt1->setDisabled($this->getDisabled());
155
156 $sub_both_opt2 = new ilRadioOption($DIC->language()->txt('mail_second_email'), ilMailOptions::SECOND_EMAIL);
157 $sub_both_opt2->setDisabled($this->getDisabled());
158 $sub_both_opt3 = new ilRadioOption($DIC->language()->txt('mail_both_email'), ilMailOptions::BOTH_EMAIL);
159 $sub_both_opt3->setDisabled($this->getDisabled());
160 $email_info = array();
161 if (!$this->isFreeOptionChoice()) {
162 $email_info = array();
163 if (
164// !strlen(ilObjUser::_lookupEmail($DIC->user()->getId())) ||
165 $DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
166 $this->setDisabled(true);
167 }
168
169 if (!strlen($DIC->user()->getEmail()) || $DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
170 $sub_mail_opt1->setDisabled(true);
171 $sub_mail_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
172 $sub_mail_opt3->setDisabled(true);
173 $sub_mail_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
174 $sub_both_opt1->setDisabled(true);
175 $sub_both_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
176 $sub_both_opt3->setDisabled(true);
177 $sub_both_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
178 } else {
179 $email_info[] = $DIC->user()->getEmail();
180 }
181
182 if (!strlen($DIC->user()->getSecondEmail()) || $DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
183 $sub_mail_opt2->setDisabled(true);
184 $sub_mail_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
185 $sub_mail_opt3->setDisabled(true);
186 $sub_mail_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
187 $sub_both_opt2->setDisabled(true);
188 $sub_both_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
189 $sub_both_opt3->setDisabled(true);
190 $sub_both_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
191 } else {
192 $email_info[] = $DIC->user()->getSecondEmail();
193 }
194
195 if (count($email_info) > 1) {
196 $sub_mail_opt1->setInfo($email_info[0]);
197 $sub_both_opt1->setInfo($email_info[0]);
198 $sub_mail_opt2->setInfo($email_info[1]);
199 $sub_both_opt2->setInfo($email_info[1]);
200 $sub_mail_opt3->setInfo(implode(', ', $email_info));
201 $sub_both_opt3->setInfo(implode(', ', $email_info));
202 }
203
204 if (count($email_info) == 1) {
205 $incomingExternal->setInfo($email_info[0]);
206 $incomingBoth->setInfo($email_info[0]);
207 } else {
208 $incomingExternalAddressChoice->addOption($sub_mail_opt1);
209 $incomingExternalAddressChoice->addOption($sub_mail_opt2);
210 $incomingExternalAddressChoice->addOption($sub_mail_opt3);
211
212 $incomingBothAddressChoice->addOption($sub_both_opt1);
213 $incomingBothAddressChoice->addOption($sub_both_opt2);
214 $incomingBothAddressChoice->addOption($sub_both_opt3);
215
216 $incomingExternal->addSubItem($incomingExternalAddressChoice);
217 $incomingBoth->addSubItem($incomingBothAddressChoice);
218 }
219 } else {
220 $incomingExternalAddressChoice->addOption($sub_mail_opt1);
221 $incomingExternalAddressChoice->addOption($sub_mail_opt2);
222 $incomingExternalAddressChoice->addOption($sub_mail_opt3);
223 $incomingBothAddressChoice->addOption($sub_both_opt1);
224 $incomingBothAddressChoice->addOption($sub_both_opt2);
225 $incomingBothAddressChoice->addOption($sub_both_opt3);
226
227 $incomingExternal->addSubItem($incomingExternalAddressChoice);
228 $incomingBoth->addSubItem($incomingBothAddressChoice);
229 }
230 }
231 }
An exception for terminatinating execution or to throw for unit testing.
setDisabled($a_disabled)
Set Disabled.
Class ilIncomingMailInputGUI.
getItemByPostVar($a_post_var)
Get item by post var.mixed false or item object
getOptions()
Get Options.array Array of RadioOption objects
checkInput()
Check input, strip slashes etc.set alert, if input is not ok.boolean Input ok, true/false
getSubInputItemsRecursive()
returns a flat array of possibly existing subitems recursivelyarray
setValueByArray($a_values)
Set value by array.
__construct($title='', $post_var='', $freeOptionChoice=true)
ilIncomingMailInputGUI constructor.
This class represents a property in a property form.
addOption($a_option)
Add Option.
This class represents an option in a radio group.
global $DIC
Definition: saml.php:7