ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
36  protected function initializeOptions()
37  {
38  if (!$this->optionsInitialized) {
39  $this->addSubOptions();
40  $this->optionsInitialized = true;
41  }
42  }
43 
44  public function getOptions()
45  {
46  $this->initializeOptions();
47  return parent::getOptions();
48  }
49 
50  public function setValueByArray($a_values)
51  {
52  $this->initializeOptions();
53  parent::setValueByArray($a_values);
54  }
55 
56  public function checkInput()
57  {
58  $this->initializeOptions();
59  return parent::checkInput();
60  }
61 
62  public function render()
63  {
64  $this->initializeOptions();
65  return parent::render();
66  }
67 
68  public function getItemByPostVar($a_post_var)
69  {
70  $this->initializeOptions();
71  return parent::getItemByPostVar($a_post_var);
72  }
73 
74  public function getSubInputItemsRecursive()
75  {
76  $this->initializeOptions();
77  return parent::getSubInputItemsRecursive();
78  }
79 
83  public function isFreeOptionChoice()
84  {
86  }
87 
92  {
93  $this->freeOptionChoice = $freeOptionChoice;
94  }
95 
96  private function addSubOptions()
97  {
98  global $DIC;
99 
100  $incomingLocal = new ilRadioOption($DIC->language()->txt('mail_incoming_local'), ilMailOptions::INCOMING_LOCAL);
101  $incomingLocal->setDisabled($this->getDisabled());
102 
103  $incomingExternal = new ilRadioOption(
104  $DIC->language()->txt('mail_incoming_smtp'),
106  );
107  $incomingExternal->setDisabled($this->getDisabled());
108 
109  $incomingBoth = new ilRadioOption($DIC->language()->txt('mail_incoming_both'), ilMailOptions::INCOMING_BOTH);
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($DIC->language()->txt('mail_first_email'), ilMailOptions::FIRST_EMAIL);
120  $sub_mail_opt1->setDisabled($this->getDisabled());
121 
122  $sub_mail_opt2 = new ilRadioOption($DIC->language()->txt('mail_second_email'), ilMailOptions::SECOND_EMAIL);
123  $sub_mail_opt2->setDisabled($this->getDisabled());
124  $sub_mail_opt3 = new ilRadioOption($DIC->language()->txt('mail_both_email'), ilMailOptions::BOTH_EMAIL);
125  $sub_mail_opt3->setDisabled($this->getDisabled());
126 
127  $incomingBothAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option_both');
128  $incomingBothAddressChoice->setDisabled($this->getDisabled());
129  $sub_both_opt1 = new ilRadioOption($DIC->language()->txt('mail_first_email'), ilMailOptions::FIRST_EMAIL);
130  $sub_both_opt1->setDisabled($this->getDisabled());
131 
132  $sub_both_opt2 = new ilRadioOption($DIC->language()->txt('mail_second_email'), ilMailOptions::SECOND_EMAIL);
133  $sub_both_opt2->setDisabled($this->getDisabled());
134  $sub_both_opt3 = new ilRadioOption($DIC->language()->txt('mail_both_email'), ilMailOptions::BOTH_EMAIL);
135  $sub_both_opt3->setDisabled($this->getDisabled());
136  $email_info = array();
137  if (!$this->isFreeOptionChoice()) {
138  $email_info = array();
139  if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
140  $this->setDisabled(true);
141  }
142 
143  if (!strlen($DIC->user()->getEmail())) {
144  $sub_mail_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
145  $sub_mail_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
146  $sub_both_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
147  $sub_both_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
148  } else {
149  $email_info[] = $DIC->user()->getEmail();
150  }
151  if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
152  $sub_mail_opt1->setDisabled(true);
153  $sub_mail_opt3->setDisabled(true);
154  $sub_both_opt1->setDisabled(true);
155  $sub_both_opt3->setDisabled(true);
156  }
157 
158  if (!strlen($DIC->user()->getSecondEmail())) {
159  $sub_mail_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
160  $sub_mail_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
161  $sub_both_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
162  $sub_both_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
163  } else {
164  $email_info[] = $DIC->user()->getSecondEmail();
165  }
166  if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
167  $sub_mail_opt2->setDisabled(true);
168  $sub_mail_opt3->setDisabled(true);
169  $sub_both_opt2->setDisabled(true);
170  $sub_both_opt3->setDisabled(true);
171  }
172 
173  if (count($email_info) > 1) {
174  $sub_mail_opt1->setInfo($email_info[0]);
175  $sub_both_opt1->setInfo($email_info[0]);
176  $sub_mail_opt2->setInfo($email_info[1]);
177  $sub_both_opt2->setInfo($email_info[1]);
178  $sub_mail_opt3->setInfo(implode(', ', $email_info));
179  $sub_both_opt3->setInfo(implode(', ', $email_info));
180  }
181 
182  if (count($email_info) == 1) {
183  $incomingExternal->setInfo($email_info[0]);
184  $incomingBoth->setInfo($email_info[0]);
185  } else {
186  $incomingExternalAddressChoice->addOption($sub_mail_opt1);
187  $incomingExternalAddressChoice->addOption($sub_mail_opt2);
188  $incomingExternalAddressChoice->addOption($sub_mail_opt3);
189 
190  $incomingBothAddressChoice->addOption($sub_both_opt1);
191  $incomingBothAddressChoice->addOption($sub_both_opt2);
192  $incomingBothAddressChoice->addOption($sub_both_opt3);
193 
194  $incomingExternal->addSubItem($incomingExternalAddressChoice);
195  $incomingBoth->addSubItem($incomingBothAddressChoice);
196  }
197  } else {
198  $incomingExternalAddressChoice->addOption($sub_mail_opt1);
199  $incomingExternalAddressChoice->addOption($sub_mail_opt2);
200  $incomingExternalAddressChoice->addOption($sub_mail_opt3);
201  $incomingBothAddressChoice->addOption($sub_both_opt1);
202  $incomingBothAddressChoice->addOption($sub_both_opt2);
203  $incomingBothAddressChoice->addOption($sub_both_opt3);
204 
205  $incomingExternal->addSubItem($incomingExternalAddressChoice);
206  $incomingBoth->addSubItem($incomingBothAddressChoice);
207  }
208  }
209 }
This class represents an option in a radio group.
This class represents a property in a property form.
addOption($a_option)
Add Option.
global $DIC
Definition: goto.php:24
__construct($title='', $post_var='', $freeOptionChoice=true)
ilIncomingMailInputGUI constructor.
__construct(Container $dic, ilPlugin $plugin)
setDisabled($a_disabled)
setDisabled($a_disabled)
Set Disabled.
Class ilIncomingMailInputGUI.