ILIAS  release_7 Revision v7.30-3-g800a261c036
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->options->maySeeIndividualTransportSettings()) {
71 $incoming_mail_gui = new ilIncomingMailInputGUI(
72 $this->lng->txt('mail_incoming'),
73 'incoming_type',
74 false
75 );
76 $this->addItem($incoming_mail_gui);
77 }
78
79 $options = array();
80 for ($i = 50; $i <= 80; $i++) {
81 $options[$i] = $i;
82 }
83 $si = new ilSelectInputGUI($this->lng->txt('linebreak'), 'linebreak');
84 $si->setOptions($options);
85 $this->addItem($si);
86
87 $ta = new ilTextAreaInputGUI($this->lng->txt('signature'), 'signature');
88 $ta->setRows(10);
89 $ta->setCols(60);
90 $this->addItem($ta);
91
92 if ($this->settings->get('mail_notification')) {
93 $cb = new ilCheckboxInputGUI($this->lng->txt('cron_mail_notification'), 'cronjob_notification');
94 $cb->setInfo($this->lng->txt('mail_cronjob_notification_info'));
95 $cb->setValue(1);
96 $this->addItem($cb);
97 }
98
99 $this->addCommandButton($this->positiveCmd, $this->lng->txt('save'));
100 }
101
105 public function save() : bool
106 {
107 if (!$this->checkInput()) {
108 return false;
109 }
110
111 if ($this->options->mayModifyIndividualTransportSettings()) {
112 $incoming_type = (int) $this->getInput('incoming_type');
113
114 $mail_address_option = $this->options->getEmailAddressMode();
115 switch ($incoming_type) {
117 $mail_address_option = (int) $this->getInput('mail_address_option');
118 break;
119
121 $mail_address_option = (int) $this->getInput('mail_address_option_both');
122 break;
123 }
124 } else {
125 $incoming_type = $this->options->getIncomingType();
126 $mail_address_option = $this->options->getEmailAddressMode();
127 }
128
129 $this->options->setLinebreak((int) $this->getInput('linebreak'));
130 $this->options->setSignature((string) $this->getInput('signature'));
131 $this->options->setIsCronJobNotificationStatus((bool) $this->getInput('cronjob_notification'));
132 $this->options->setIncomingType((int) $incoming_type);
133 $this->options->setEmailAddressMode((int) $mail_address_option);
134
135 $this->options->updateOptions();
136
137 return true;
138 }
139
143 public function populate() : void
144 {
145 $data = [
146 'linebreak' => $this->options->getLinebreak(),
147 'signature' => $this->options->getSignature(),
148 'cronjob_notification' => $this->options->isCronJobNotificationEnabled()
149 ];
150
151 if ($this->options->maySeeIndividualTransportSettings()) {
152 $data['incoming_type'] = $this->options->getIncomingType();
153
154 $mail_address_option = $this->options->getEmailAddressMode();
155
156 $data['mail_address_option'] = $mail_address_option;
157 $data['mail_address_option_both'] = $mail_address_option;
158 }
159
160 $this->setValuesByArray($data);
161 }
162}
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.
global $DIC
Definition: goto.php:24
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
settings()
Definition: settings.php:2
$data
Definition: storeScorm.php:23