ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMailOptionsFormGUI.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
10 protected $lng;
11
13 protected $settings;
14
16 protected $user;
17
19 protected $ctrl;
20
22 protected $parentGui;
23
25 protected $positiveCmd = '';
26
28 protected $options;
29
38 {
39 global $DIC;
40
41 if (!method_exists($parentGui, 'executeCommand')) {
42 throw new InvalidArgumentException(sprintf(
43 'Parameter $parentGui must be ilCtrl enabled by implementing executeCommand(), %s given.',
44 is_object($parentGui) ? get_class($parentGui) : var_export($parentGui, 1)
45 ));
46 }
47
49
50 $this->ctrl = $DIC->ctrl();
51 $this->settings = $DIC->settings();
52 $this->lng = $DIC->language();
53 $this->user = $DIC->user();
54
55 $this->options = $options;
56 $this->parentGui = $parentGui;
57 $this->positiveCmd = $positiveCmd;
58
59 $this->init();
60 }
61
65 protected function init() : void
66 {
67 $this->setTitle($this->lng->txt('mail_settings'));
68 $this->setFormAction($this->ctrl->getFormAction($this->parentGui, $this->positiveCmd));
69
70 if ($this->settings->get('usr_settings_hide_mail_incoming_mail') != '1') {
71 $incoming_mail_gui = new ilIncomingMailInputGUI($this->lng->txt('mail_incoming'), 'incoming_type', false);
72 $this->addItem($incoming_mail_gui);
73 }
74
75 $options = array();
76 for ($i = 50; $i <= 80; $i++) {
77 $options[$i] = $i;
78 }
79 $si = new ilSelectInputGUI($this->lng->txt('linebreak'), 'linebreak');
80 $si->setOptions($options);
81 $this->addItem($si);
82
83 $ta = new ilTextAreaInputGUI($this->lng->txt('signature'), 'signature');
84 $ta->setRows(10);
85 $ta->setCols(60);
86 $this->addItem($ta);
87
88 if ($this->settings->get('mail_notification')) {
89 $cb = new ilCheckboxInputGUI($this->lng->txt('cron_mail_notification'), 'cronjob_notification');
90 $cb->setInfo($this->lng->txt('mail_cronjob_notification_info'));
91 $cb->setValue(1);
92 $this->addItem($cb);
93 }
94
95 $this->addCommandButton($this->positiveCmd, $this->lng->txt('save'));
96 }
97
101 public function save() : bool
102 {
103 if (!$this->checkInput()) {
104 return false;
105 }
106
107 if (
108 $this->settings->get('usr_settings_hide_mail_incoming_mail') != '1' &&
109 $this->settings->get('usr_settings_disable_mail_incoming_mail') != '1'
110 ) {
111 $incoming_type = (int) $this->getInput('incoming_type');
112
113 $mail_address_option = $this->options->getEmailAddressMode();
114 switch ($incoming_type) {
116 $mail_address_option = (int) $this->getInput('mail_address_option');
117 break;
118
120 $mail_address_option = (int) $this->getInput('mail_address_option_both');
121 break;
122 }
123 } else {
124 $incoming_type = $this->options->getIncomingType();
125 $mail_address_option = $this->options->getEmailAddressMode();
126 }
127
128 $this->options->setLinebreak((int) $this->getInput('linebreak'));
129 $this->options->setSignature((string) $this->getInput('signature'));
130 $this->options->setIsCronJobNotificationStatus((bool) $this->getInput('cronjob_notification'));
131 $this->options->setIncomingType((int) $incoming_type);
132 $this->options->setEmailAddressMode((int) $mail_address_option);
133
134 $this->options->updateOptions();
135
136 return true;
137 }
138
142 public function populate() : void
143 {
144 $data = [
145 'linebreak' => $this->options->getLinebreak(),
146 'signature' => $this->options->getSignature(),
147 'cronjob_notification' => $this->options->isCronJobNotificationEnabled()
148 ];
149
150 if ($this->settings->get('usr_settings_hide_mail_incoming_mail') != '1') {
151 $data['incoming_type'] = $this->options->getIncomingType();
152
153 $mail_address_option = $this->options->getEmailAddressMode();
154
155 $data['mail_address_option'] = $mail_address_option;
156 $data['mail_address_option_both'] = $mail_address_option;
157 }
158
159 $this->setValuesByArray($data);
160 }
161}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
Class ilIncomingMailInputGUI.
Class ilMailOptionsFormGUI.
__construct(ilMailOptions $options, $parentGui, string $positiveCmd)
ilMailOptionsFormGUI constructor.
Class ilMailOptions this class handles user mails.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
checkInput()
Check Post Input.
setTitle($a_title)
Set Title.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
settings()
Definition: settings.php:2
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46