ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMailOptionsFormGUI.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/Form/classes/class.ilPropertyFormGUI.php';
5 require_once 'Services/Mail/classes/class.ilMailOptions.php';
6 
11 {
15  protected $lng;
16 
20  protected $settings;
21 
25  protected $user;
26 
30  protected $ctrl;
31 
35  protected $parentGui;
36 
40  protected $positiveCmd = '';
41 
45  protected $options;
46 
55  {
56  global $DIC;
57 
58  if (!method_exists($parentGui, 'executeCommand')) {
59  throw new \InvalidArgumentException(sprintf(
60  'Parameter $parentGui must be ilCtrl enabled by implementing executeCommand(), %s given.',
61  is_object($parentGui) ? get_class($parentGui) : var_export($parentGui, 1)
62  ));
63  }
64 
65  parent::__construct();
66 
67  $this->ctrl = $DIC->ctrl();
68  $this->settings = $DIC->settings();
69  $this->lng = $DIC->language();
70  $this->user = $DIC->user();
71 
72  $this->options = $options;
73  $this->parentGui = $parentGui;
74  $this->positiveCmd = $positiveCmd;
75 
76  $this->init();
77  }
78 
82  protected function init()
83  {
84  $this->setTitle($this->lng->txt('mail_settings'));
85  $this->setFormAction($this->ctrl->getFormAction($this->parentGui, $this->positiveCmd));
86 
87  if ($this->settings->get('usr_settings_hide_mail_incoming_mail') != '1') {
88  require_once 'Services/Mail/classes/Form/class.ilIncomingMailInputGUI.php';
89  $incoming_mail_gui = new ilIncomingMailInputGUI($this->lng->txt('mail_incoming'), 'incoming_type', false);
90  $this->addItem($incoming_mail_gui);
91  }
92 
93  $options = array();
94  for ($i = 50; $i <= 80; $i++) {
95  $options[$i] = $i;
96  }
97  $si = new ilSelectInputGUI($this->lng->txt('linebreak'), 'linebreak');
98  $si->setOptions($options);
99  $this->addItem($si);
100 
101  $ta = new ilTextAreaInputGUI($this->lng->txt('signature'), 'signature');
102  $ta->setRows(10);
103  $ta->setCols(60);
104  $this->addItem($ta);
105 
106  if ($this->settings->get('mail_notification')) {
107  $cb = new ilCheckboxInputGUI($this->lng->txt('cron_mail_notification'), 'cronjob_notification');
108  $cb->setInfo($this->lng->txt('mail_cronjob_notification_info'));
109  $cb->setValue(1);
110  $this->addItem($cb);
111  }
112 
113  $this->addCommandButton($this->positiveCmd, $this->lng->txt('save'));
114  }
115 
119  public function save()
120  {
121  if (!$this->checkInput()) {
122  return false;
123  }
124 
125  if (
126  $this->settings->get('usr_settings_hide_mail_incoming_mail') != '1' &&
127  $this->settings->get('usr_settings_disable_mail_incoming_mail') != '1'
128  ) {
129  $incoming_type = (int) $this->getInput('incoming_type');
130 
131  $mail_address_option = $this->options->getMailAddressOption();
132  switch ($incoming_type) {
134  $mail_address_option = (int) $this->getInput('mail_address_option');
135  break;
136 
138  $mail_address_option = (int) $this->getInput('mail_address_option_both');
139  break;
140  }
141  } else {
142  $incoming_type = $this->options->getIncomingType();
143  $mail_address_option = $this->options->getMailAddressOption();
144  }
145 
146  $this->options->setLinebreak((int) $this->getInput('linebreak'));
147  $this->options->setSignature($this->getInput('signature'));
148  $this->options->setCronjobNotification((int) $this->getInput('cronjob_notification'));
149  $this->options->setIncomingType($incoming_type);
150  $this->options->setMailAddressOption($mail_address_option);
151 
152  $this->options->updateOptions();
153 
154  return true;
155  }
156 
160  public function populate()
161  {
162  $data = array(
163  'linebreak' => $this->options->getLinebreak(),
164  'signature' => $this->options->getSignature(),
165  'cronjob_notification' => $this->options->getCronjobNotification()
166  );
167 
168  if ($this->settings->get('usr_settings_hide_mail_incoming_mail') != '1') {
169  $data['incoming_type'] = $this->options->getIncomingType();
170 
171  $mail_address_option = $this->options->getMailAddressOption();
172 
173  $data['mail_address_option'] = $mail_address_option;
174  $data['mail_address_option_both'] = $mail_address_option;
175  }
176 
177  $this->setValuesByArray($data);
178  }
179 }
Class ilMailOptions this class handles user mails.
settings()
Definition: settings.php:2
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
addItem($a_item)
Add Item (Property, SectionHeader).
user()
Definition: user.php:4
setInfo($a_info)
Set Information Text.
Class ilMailOptionsFormGUI.
setTitle($a_title)
Set Title.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
checkInput()
Check Post Input.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
This class represents a text area property in a property form.
$i
Definition: disco.tpl.php:19
__construct(ilMailOptions $options, $parentGui, $positiveCmd)
ilMailOptionsFormGUI constructor.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
Class ilIncomingMailInputGUI.
$data
Definition: bench.php:6