ILIAS  release_8 Revision v8.24
class.ilMailOptionsFormGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected object $parentGui;
27 protected string $positiveCmd = '';
29
35 public function __construct(ilMailOptions $options, object $parentGui, string $positiveCmd)
36 {
37 if (!method_exists($parentGui, 'executeCommand')) {
38 throw new InvalidArgumentException(sprintf(
39 'Parameter $parentGui must be ilCtrlInterface enabled by implementing executeCommand(), %s given.',
40 get_class($parentGui)
41 ));
42 }
43
45
46 $this->options = $options;
47 $this->parentGui = $parentGui;
48 $this->positiveCmd = $positiveCmd;
49
50 $this->init();
51 }
52
53 protected function init(): void
54 {
55 $this->setTitle($this->lng->txt('mail_settings'));
56 $this->setFormAction($this->ctrl->getFormAction($this->parentGui, $this->positiveCmd));
57
58 if ($this->options->maySeeIndividualTransportSettings()) {
59 $incoming_mail_gui = new ilIncomingMailInputGUI(
60 $this->lng->txt('mail_incoming'),
61 'incoming_type',
62 false
63 );
64 $this->addItem($incoming_mail_gui);
65 }
66
67 $options = [];
68 for ($i = 50; $i <= 80; $i++) {
69 $options[$i] = $i;
70 }
71 $si = new ilSelectInputGUI($this->lng->txt('linebreak'), 'linebreak');
72 $si->setOptions($options);
73 $this->addItem($si);
74
75 $ta = new ilTextAreaInputGUI($this->lng->txt('signature'), 'signature');
76 $ta->setRows(10);
77 $ta->setCols(60);
78 $this->addItem($ta);
79
80 if ($this->settings->get('mail_notification', '0')) {
81 $cb = new ilCheckboxInputGUI(
82 $this->lng->txt('cron_mail_notification'),
83 'cronjob_notification'
84 );
85 $cb->setInfo($this->lng->txt('mail_cronjob_notification_info'));
86 $cb->setValue('1');
87 $this->addItem($cb);
88 }
89
90 $this->addCommandButton($this->positiveCmd, $this->lng->txt('save'));
91 }
92
93 public function save(): bool
94 {
95 if (!$this->checkInput()) {
96 return false;
97 }
98
99 if ($this->options->mayModifyIndividualTransportSettings()) {
100 $incoming_type = (int) $this->getInput('incoming_type');
101
102 $mail_address_option = $this->options->getEmailAddressMode();
103 switch ($incoming_type) {
105 $mail_address_option = (int) $this->getInput('mail_address_option');
106 break;
107
109 $mail_address_option = (int) $this->getInput('mail_address_option_both');
110 break;
111 }
112 } else {
113 $incoming_type = $this->options->getIncomingType();
114 $mail_address_option = $this->options->getEmailAddressMode();
115 }
116
117 $this->options->setLinebreak((int) $this->getInput('linebreak'));
118 $this->options->setSignature($this->getInput('signature'));
119 $this->options->setIsCronJobNotificationStatus((bool) $this->getInput('cronjob_notification'));
120 $this->options->setIncomingType($incoming_type);
121 $this->options->setEmailAddressMode($mail_address_option);
122
123 $this->options->updateOptions();
124
125 return true;
126 }
127
128 public function populate(): void
129 {
130 $data = [
131 'linebreak' => $this->options->getLinebreak(),
132 'signature' => $this->options->getSignature(),
133 'cronjob_notification' => $this->options->isCronJobNotificationEnabled(),
134 ];
135
136 if ($this->options->maySeeIndividualTransportSettings()) {
137 $data['incoming_type'] = $this->options->getIncomingType();
138
139 $mail_address_option = $this->options->getEmailAddressMode();
140
141 $data['mail_address_option'] = $mail_address_option;
142 $data['mail_address_option_both'] = $mail_address_option;
143 }
144
145 $this->setValuesByArray($data);
146 }
147}
This class represents a checkbox property in a property form.
setFormAction(string $a_formaction)
Class ilIncomingMailInputGUI.
Class ilMailOptionsFormGUI.
__construct(ilMailOptions $options, object $parentGui, string $positiveCmd)
Class ilMailOptions this class handles user mails.
This class represents a property form user interface.
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
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:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc