ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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($DIC->language()->txt('mail_incoming_smtp'),
105  $incomingExternal->setDisabled($this->getDisabled());
106 
107  $incomingBoth = new ilRadioOption($DIC->language()->txt('mail_incoming_both'), ilMailOptions::INCOMING_BOTH);
108  $incomingBoth->setDisabled($this->getDisabled());
109 
110  $this->addOption($incomingLocal);
111  $this->addOption($incomingExternal);
112  $this->addOption($incomingBoth);
113 
114  $incomingExternalAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option');
115  $incomingExternalAddressChoice->setDisabled($this->getDisabled());
116 
117  $sub_mail_opt1 = new ilRadioOption($DIC->language()->txt('mail_first_email'), ilMailOptions::FIRST_EMAIL);
118  $sub_mail_opt1->setDisabled($this->getDisabled());
119 
120  $sub_mail_opt2 = new ilRadioOption($DIC->language()->txt('mail_second_email'), ilMailOptions::SECOND_EMAIL);
121  $sub_mail_opt2->setDisabled($this->getDisabled());
122  $sub_mail_opt3 = new ilRadioOption($DIC->language()->txt('mail_both_email'), ilMailOptions::BOTH_EMAIL);
123  $sub_mail_opt3->setDisabled($this->getDisabled());
124 
125  $incomingBothAddressChoice = new ilRadioGroupInputGUI('', 'mail_address_option_both');
126  $incomingBothAddressChoice->setDisabled($this->getDisabled());
127  $sub_both_opt1 = new ilRadioOption($DIC->language()->txt('mail_first_email'), ilMailOptions::FIRST_EMAIL);
128  $sub_both_opt1->setDisabled($this->getDisabled());
129 
130  $sub_both_opt2 = new ilRadioOption($DIC->language()->txt('mail_second_email'), ilMailOptions::SECOND_EMAIL);
131  $sub_both_opt2->setDisabled($this->getDisabled());
132  $sub_both_opt3 = new ilRadioOption($DIC->language()->txt('mail_both_email'), ilMailOptions::BOTH_EMAIL);
133  $sub_both_opt3->setDisabled($this->getDisabled());
134  $email_info = array();
135  if (!$this->isFreeOptionChoice()) {
136  $email_info = array();
137  if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
138  $this->setDisabled(true);
139  }
140 
141  if (!strlen($DIC->user()->getEmail())) {
142  $sub_mail_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
143  $sub_mail_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
144  $sub_both_opt1->setInfo($DIC->language()->txt('first_email_missing_info'));
145  $sub_both_opt3->setInfo($DIC->language()->txt('first_email_missing_info'));
146  } else {
147  $email_info[] = $DIC->user()->getEmail();
148  }
149  if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
150  $sub_mail_opt1->setDisabled(true);
151  $sub_mail_opt3->setDisabled(true);
152  $sub_both_opt1->setDisabled(true);
153  $sub_both_opt3->setDisabled(true);
154  }
155 
156  if (!strlen($DIC->user()->getSecondEmail())) {
157  $sub_mail_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
158  $sub_mail_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
159  $sub_both_opt2->setInfo($DIC->language()->txt('second_email_missing_info'));
160  $sub_both_opt3->setInfo($DIC->language()->txt('second_email_missing_info'));
161  } else {
162  $email_info[] = $DIC->user()->getSecondEmail();
163  }
164  if ($DIC->settings()->get('usr_settings_disable_mail_incoming_mail') == '1') {
165  $sub_mail_opt2->setDisabled(true);
166  $sub_mail_opt3->setDisabled(true);
167  $sub_both_opt2->setDisabled(true);
168  $sub_both_opt3->setDisabled(true);
169  }
170 
171  if (count($email_info) > 1) {
172  $sub_mail_opt1->setInfo($email_info[0]);
173  $sub_both_opt1->setInfo($email_info[0]);
174  $sub_mail_opt2->setInfo($email_info[1]);
175  $sub_both_opt2->setInfo($email_info[1]);
176  $sub_mail_opt3->setInfo(implode(', ', $email_info));
177  $sub_both_opt3->setInfo(implode(', ', $email_info));
178  }
179 
180  if (count($email_info) == 1) {
181  $incomingExternal->setInfo($email_info[0]);
182  $incomingBoth->setInfo($email_info[0]);
183  } else {
184  $incomingExternalAddressChoice->addOption($sub_mail_opt1);
185  $incomingExternalAddressChoice->addOption($sub_mail_opt2);
186  $incomingExternalAddressChoice->addOption($sub_mail_opt3);
187 
188  $incomingBothAddressChoice->addOption($sub_both_opt1);
189  $incomingBothAddressChoice->addOption($sub_both_opt2);
190  $incomingBothAddressChoice->addOption($sub_both_opt3);
191 
192  $incomingExternal->addSubItem($incomingExternalAddressChoice);
193  $incomingBoth->addSubItem($incomingBothAddressChoice);
194  }
195  } else {
196  $incomingExternalAddressChoice->addOption($sub_mail_opt1);
197  $incomingExternalAddressChoice->addOption($sub_mail_opt2);
198  $incomingExternalAddressChoice->addOption($sub_mail_opt3);
199  $incomingBothAddressChoice->addOption($sub_both_opt1);
200  $incomingBothAddressChoice->addOption($sub_both_opt2);
201  $incomingBothAddressChoice->addOption($sub_both_opt3);
202 
203  $incomingExternal->addSubItem($incomingExternalAddressChoice);
204  $incomingBoth->addSubItem($incomingBothAddressChoice);
205  }
206  }
207 }
This class represents an option in a radio group.
This class represents a property in a property form.
addOption($a_option)
Add Option.
__construct($title='', $post_var='', $freeOptionChoice=true)
ilIncomingMailInputGUI constructor.
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
setDisabled($a_disabled)
setDisabled($a_disabled)
Set Disabled.
Class ilIncomingMailInputGUI.