ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public function getOptions()
51  {
52  $this->initializeOptions();
53  return parent::getOptions();
54  }
55 
59  public function setValueByArray($a_values)
60  {
61  $this->initializeOptions();
62  parent::setValueByArray($a_values);
63  }
64 
68  public function checkInput()
69  {
70  $this->initializeOptions();
71  return parent::checkInput();
72  }
73 
77  public function render()
78  {
79  $this->initializeOptions();
80  return parent::render();
81  }
82 
86  public 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'), ilMailOptions::INCOMING_LOCAL);
125  $incomingLocal->setDisabled($this->getDisabled());
126 
127  $incomingExternal = new ilRadioOption($DIC->language()->txt('mail_incoming_smtp'), ilMailOptions::INCOMING_EMAIL);
128  $incomingExternal->setDisabled($this->getDisabled());
129 
130  $incomingBoth = new ilRadioOption($DIC->language()->txt('mail_incoming_both'), ilMailOptions::INCOMING_BOTH);
131  $incomingBoth->setDisabled($this->getDisabled());
132 
133  $this->addOption($incomingLocal);
134  $this->addOption($incomingExternal);
135  $this->addOption($incomingBoth);
136 
137  $incomingExternalAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option');
138  $incomingExternalAddressChoice->setDisabled($this->getDisabled());
139 
140  $sub_mail_opt1 = new ilRadioOption($DIC->language()->txt('mail_first_email'), ilMailOptions::FIRST_EMAIL);
141  $sub_mail_opt1->setDisabled($this->getDisabled());
142 
143  $sub_mail_opt2 = new ilRadioOption($DIC->language()->txt('mail_second_email'), ilMailOptions::SECOND_EMAIL);
144  $sub_mail_opt2->setDisabled($this->getDisabled());
145  $sub_mail_opt3 = new ilRadioOption($DIC->language()->txt('mail_both_email'), ilMailOptions::BOTH_EMAIL);
146  $sub_mail_opt3->setDisabled($this->getDisabled());
147 
148  $incomingBothAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option_both');
149  $incomingBothAddressChoice->setDisabled($this->getDisabled());
150  $sub_both_opt1 = new ilRadioOption($DIC->language()->txt('mail_first_email'), ilMailOptions::FIRST_EMAIL);
151  $sub_both_opt1->setDisabled($this->getDisabled());
152 
153  $sub_both_opt2 = new ilRadioOption($DIC->language()->txt('mail_second_email'), ilMailOptions::SECOND_EMAIL);
154  $sub_both_opt2->setDisabled($this->getDisabled());
155  $sub_both_opt3 = new ilRadioOption($DIC->language()->txt('mail_both_email'), ilMailOptions::BOTH_EMAIL);
156  $sub_both_opt3->setDisabled($this->getDisabled());
157  $email_info = array();
158  if (!$this->isFreeOptionChoice()) {
159  $email_info = array();
160  if (
161 // !strlen(ilObjUser::_lookupEmail($DIC->user()->getId())) ||
162  $DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
163  $this->setDisabled(true);
164  }
165 
166  if (!strlen($DIC->user()->getEmail()) || $DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
167  $sub_mail_opt1->setDisabled(true);
168  $sub_mail_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
169  $sub_mail_opt3->setDisabled(true);
170  $sub_mail_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
171  $sub_both_opt1->setDisabled(true);
172  $sub_both_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
173  $sub_both_opt3->setDisabled(true);
174  $sub_both_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
175  } else {
176  $email_info[] = $DIC->user()->getEmail();
177  }
178 
179  if (!strlen($DIC->user()->getSecondEmail()) || $DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
180  $sub_mail_opt2->setDisabled(true);
181  $sub_mail_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
182  $sub_mail_opt3->setDisabled(true);
183  $sub_mail_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
184  $sub_both_opt2->setDisabled(true);
185  $sub_both_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
186  $sub_both_opt3->setDisabled(true);
187  $sub_both_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
188  } else {
189  $email_info[] = $DIC->user()->getSecondEmail();
190  }
191 
192  if (count($email_info) > 1) {
193  $sub_mail_opt1->setInfo($email_info[0]);
194  $sub_both_opt1->setInfo($email_info[0]);
195  $sub_mail_opt2->setInfo($email_info[1]);
196  $sub_both_opt2->setInfo($email_info[1]);
197  $sub_mail_opt3->setInfo(implode(', ', $email_info));
198  $sub_both_opt3->setInfo(implode(', ', $email_info));
199  }
200 
201  if (count($email_info) == 1) {
202  $incomingExternal->setInfo($email_info[0]);
203  $incomingBoth->setInfo($email_info[0]);
204  } else {
205  $incomingExternalAddressChoice->addOption($sub_mail_opt1);
206  $incomingExternalAddressChoice->addOption($sub_mail_opt2);
207  $incomingExternalAddressChoice->addOption($sub_mail_opt3);
208 
209  $incomingBothAddressChoice->addOption($sub_both_opt1);
210  $incomingBothAddressChoice->addOption($sub_both_opt2);
211  $incomingBothAddressChoice->addOption($sub_both_opt3);
212 
213  $incomingExternal->addSubItem($incomingExternalAddressChoice);
214  $incomingBoth->addSubItem($incomingBothAddressChoice);
215  }
216  } else {
217  $incomingExternalAddressChoice->addOption($sub_mail_opt1);
218  $incomingExternalAddressChoice->addOption($sub_mail_opt2);
219  $incomingExternalAddressChoice->addOption($sub_mail_opt3);
220  $incomingBothAddressChoice->addOption($sub_both_opt1);
221  $incomingBothAddressChoice->addOption($sub_both_opt2);
222  $incomingBothAddressChoice->addOption($sub_both_opt3);
223 
224  $incomingExternal->addSubItem($incomingExternalAddressChoice);
225  $incomingBoth->addSubItem($incomingBothAddressChoice);
226  }
227  }
228 }
This class represents an option in a radio group.
global $DIC
Definition: saml.php:7
This class represents a property in a property form.
addOption($a_option)
Add Option.
__construct($title='', $post_var='', $freeOptionChoice=true)
ilIncomingMailInputGUI constructor.
setDisabled($a_disabled)
setDisabled($a_disabled)
Set Disabled.
Class ilIncomingMailInputGUI.