ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\User\Settings\NewAccountMail\SettingsGUI Class Reference

@ilCtrl_Calls ILIAS\User\Settings\NewAccountMail\SettingsGUI: ILIAS\User\Settings\NewAccountMail\UploadHandlerGUI More...

+ Collaboration diagram for ILIAS\User\Settings\NewAccountMail\SettingsGUI:

Public Member Functions

 __construct (private readonly \ilLanguage $lng, private readonly \ilCtrl $ctrl, private readonly \ilAccess $access, private readonly \ilGlobalTemplateInterface $tpl, private readonly TemplateEngineFactoryInterface $mail_template_engine_factory, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly Refinery $refinery, private readonly ServerRequestInterface $request, private readonly ResourceStorage $irss, private readonly Repository $account_mail_repo)
 
 executeCommand ()
 

Private Member Functions

 showCmd (?StandardForm $form=null)
 
 saveCmd ()
 
 buildForm ()
 
 buildValidateMailBodyConstraint ()
 
 buildConvertCurlyBracesTrafo ()
 
 convertCurlyBracesForFormOutput (string $value)
 

Private Attributes

readonly UploadHandlerGUI $upload_handler_gui
 
readonly Stakeholder $stakeholder
 

Detailed Description

@ilCtrl_Calls ILIAS\User\Settings\NewAccountMail\SettingsGUI: ILIAS\User\Settings\NewAccountMail\UploadHandlerGUI

Definition at line 37 of file class.SettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\User\Settings\NewAccountMail\SettingsGUI::__construct ( private readonly \ilLanguage  $lng,
private readonly \ilCtrl  $ctrl,
private readonly \ilAccess  $access,
private readonly \ilGlobalTemplateInterface  $tpl,
private readonly TemplateEngineFactoryInterface  $mail_template_engine_factory,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly Refinery  $refinery,
private readonly ServerRequestInterface  $request,
private readonly ResourceStorage  $irss,
private readonly Repository  $account_mail_repo 
)

Definition at line 44 of file class.SettingsGUI.php.

56 {
57 $this->stakeholder = new Stakeholder();
58 $this->upload_handler_gui = new UploadHandlerGUI(
59 $this->irss,
60 $this->stakeholder
61 );
62 }

Member Function Documentation

◆ buildConvertCurlyBracesTrafo()

ILIAS\User\Settings\NewAccountMail\SettingsGUI::buildConvertCurlyBracesTrafo ( )
private

Definition at line 218 of file class.SettingsGUI.php.

218 : Transformation
219 {
220 return $this->refinery->custom()->transformation(
221 static fn(string $v) => str_replace(['{{', '}}'], ['{{', '}}'], $v)
222 );
223 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ buildForm()

ILIAS\User\Settings\NewAccountMail\SettingsGUI::buildForm ( )
private

Definition at line 150 of file class.SettingsGUI.php.

150 : StandardForm
151 {
152 $ff = $this->ui_factory->input()->field();
153 $inputs = [];
154 foreach ($this->lng->getInstalledLanguages() as $lang_code) {
155 $account_mail = $this->account_mail_repo->getFor($lang_code);
156
157 $title = $this->lng->txt('meta_l_' . $lang_code);
158 if ($lang_code === $this->lng->getDefaultLanguage()) {
159 $title .= ' (' . $this->lng->txt('default') . ')';
160 }
161
162 $inputs[$lang_code] = $ff->section(
163 [
164 'subject' => $ff->text($this->lng->txt('subject'))
165 ->withAdditionalTransformation(
166 $this->buildConvertCurlyBracesTrafo()
167 )->withAdditionalTransformation(
168 $this->buildValidateMailBodyConstraint()
169 )->withValue($this->convertCurlyBracesForFormOutput($account_mail->getSubject())),
170 'salutation_none_specific' => $ff->text($this->lng->txt('mail_salutation_general'))
171 ->withValue($account_mail->getSalutationNoneSpecific()),
172 'salutation_female' => $ff->text($this->lng->txt('mail_salutation_female'))
173 ->withValue($account_mail->getSalutationFemale()),
174 'salutation_male' => $ff->text($this->lng->txt('mail_salutation_male'))
175 ->withValue($account_mail->getSalutationMale()),
176 'body' => $ff->textarea($this->lng->txt('message_content'))
177 ->withAdditionalTransformation(
178 $this->buildConvertCurlyBracesTrafo()
179 )->withAdditionalTransformation(
180 $this->buildValidateMailBodyConstraint()
181 )->withValue($account_mail->getBody()),
182 'attachment' => $ff->file($this->upload_handler_gui, $this->lng->txt('attachment'))
183 ->withValue(
184 $account_mail->getAttachmentRid() === null
185 ? []
186 : [$account_mail->getAttachmentRid()]
187 )
188 ],
189 $title
190 );
191 }
192
193 return $this->ui_factory->input()->container()->form()->standard(
194 $this->ctrl->getFormActionByClass(self::class, 'save'),
195 [$ff->section(
196 $inputs,
197 $this->lng->txt('user_new_account_mail'),
198 $this->lng->txt('user_new_account_mail_desc')
199 )]
200 );
201 }

References ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by ILIAS\User\Settings\NewAccountMail\SettingsGUI\saveCmd(), and ILIAS\User\Settings\NewAccountMail\SettingsGUI\showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildValidateMailBodyConstraint()

ILIAS\User\Settings\NewAccountMail\SettingsGUI::buildValidateMailBodyConstraint ( )
private

Definition at line 203 of file class.SettingsGUI.php.

203 : Constraint
204 {
205 return $this->refinery->custom()->constraint(
206 function ($v): bool {
207 try {
208 $this->mail_template_engine_factory->getBasicEngine()->render($v, []);
209 return true;
210 } catch (\Exception) {
211 return false;
212 }
213 },
214 $this->lng->txt('mail_template_invalid_tpl_syntax')
215 );
216 }

References ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ convertCurlyBracesForFormOutput()

ILIAS\User\Settings\NewAccountMail\SettingsGUI::convertCurlyBracesForFormOutput ( string  $value)
private

Definition at line 225 of file class.SettingsGUI.php.

225 : string
226 {
227 return str_replace(['{{', '}}'], ['{{', '}}'], $value);
228 }

◆ executeCommand()

ILIAS\User\Settings\NewAccountMail\SettingsGUI::executeCommand ( )

Definition at line 64 of file class.SettingsGUI.php.

64 : void
65 {
66 $this->redirectOnMissingWrite($this->access, $this->ctrl, $this->tpl, $this->lng);
67 if ($this->ctrl->getNextClass() === strtolower(UploadHandlerGUI::class)) {
68 $this->ctrl->forwardCommand($this->upload_handler_gui);
69 return;
70 }
71 $cmd = $this->ctrl->getCmd() . 'Cmd';
72 $this->$cmd();
73 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveCmd()

ILIAS\User\Settings\NewAccountMail\SettingsGUI::saveCmd ( )
private

Definition at line 106 of file class.SettingsGUI.php.

106 : void
107 {
108 $form = $this->buildForm()->withRequest($this->request);
109 $data = $form ->getData();
110 if ($data === null) {
111 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
112 $this->showCmd($form);
113 return;
114 }
115
116 foreach ($data[0] as $lang_code => $new_account_mail) {
117 $old_account_mail = $this->account_mail_repo->getFor($lang_code);
118
119 $new_attachment_rid = $new_account_mail['attachment'] === []
120 ? null
121 : $new_account_mail['attachment'][0];
122
123 if ($old_account_mail->getAttachmentRid() !== null
124 && $old_account_mail->getAttachmentRid() !== $new_attachment_rid
125 && ($rid = $this->irss->manage()->find($old_account_mail->getAttachmentRid())) !== null) {
126 $this->irss->manage()->remove(
127 $rid,
128 $this->stakeholder
129 );
130 $old_account_mail->deleteAttachmentTempFile();
131 }
132
133 $this->account_mail_repo->store(
134 new MailImplementation(
135 $lang_code,
136 trim($new_account_mail['subject']),
137 trim($new_account_mail['body']),
138 trim($new_account_mail['salutation_none_specific']),
139 trim($new_account_mail['salutation_male']),
140 trim($new_account_mail['salutation_female']),
141 $new_attachment_rid
142 )
143 );
144 }
145
146 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
147 $this->showCmd();
148 }

References $data, ILIAS\User\Settings\NewAccountMail\SettingsGUI\buildForm(), ILIAS\Repository\lng(), and ILIAS\User\Settings\NewAccountMail\SettingsGUI\showCmd().

+ Here is the call graph for this function:

◆ showCmd()

ILIAS\User\Settings\NewAccountMail\SettingsGUI::showCmd ( ?StandardForm  $form = null)
private

Definition at line 75 of file class.SettingsGUI.php.

75 : void
76 {
77 $content = [
78 $form ?? $this->buildForm(),
79 $this->ui_factory->panel()->standard(
80 $this->lng->txt('mail_nacc_use_placeholder'),
81 $this->ui_factory->listing()->characteristicValue()->text([
82 '{{MAIL_SALUTATION}}' => $this->lng->txt('mail_nacc_salutation'),
83 '{{FIRST_NAME}}' => $this->lng->txt('firstname'),
84 '{{LAST_NAME}}' => $this->lng->txt('lastname'),
85 '{{EMAIL}}' => $this->lng->txt('email'),
86 '{{LOGIN}}' => $this->lng->txt('mail_nacc_login'),
87 '{{PASSWORD}}' => $this->lng->txt('password'),
88 '{{#IF_PASSWORD}}...{{/IF_PASSWORD}}' => $this->lng->txt('mail_nacc_pw_block'),
89 '{{#IF_NO_PASSWORD}}...{{/IF_NO_PASSWORD}}' => $this->lng->txt('mail_nacc_no_pw_block'),
90 '{{ADMIN_MAIL}}' => $this->lng->txt('mail_nacc_admin_mail'),
91 '{{ILIAS_URL}}' => $this->lng->txt('mail_nacc_ilias_url'),
92 '{{INSTALLATION_NAME}}' => $this->lng->txt('mail_nacc_installation_name'),
93 '{{TARGET}}' => $this->lng->txt('mail_nacc_target'),
94 '{{TARGET_TITLE}}' => $this->lng->txt('mail_nacc_target_title'),
95 '{{TARGET_TYPE}}' => $this->lng->txt('mail_nacc_target_type'),
96 '{{#IF_TARGET}}...{{/IF_TARGET}}' => $this->lng->txt('mail_nacc_target_block'),
97 '{{#IF_TIMELIMIT}}...{{/IF_TIMELIMIT}}' => $this->lng->txt('mail_nacc_if_timelimit'),
98 '{{TIMELIMIT}}' => $this->lng->txt('mail_nacc_timelimit')
99 ])
100 )
101 ];
102
103 $this->tpl->setContent($this->ui_renderer->render($content));
104 }

References ILIAS\User\Settings\NewAccountMail\SettingsGUI\buildForm(), and ILIAS\Repository\lng().

Referenced by ILIAS\User\Settings\NewAccountMail\SettingsGUI\saveCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $stakeholder

readonly Stakeholder ILIAS\User\Settings\NewAccountMail\SettingsGUI::$stakeholder
private

Definition at line 42 of file class.SettingsGUI.php.

◆ $upload_handler_gui

readonly UploadHandlerGUI ILIAS\User\Settings\NewAccountMail\SettingsGUI::$upload_handler_gui
private

Definition at line 41 of file class.SettingsGUI.php.


The documentation for this class was generated from the following file: