ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 \ilMustacheFactory $mail_mustache_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 36 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 \ilMustacheFactory  $mail_mustache_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 43 of file class.SettingsGUI.php.

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

Member Function Documentation

◆ buildConvertCurlyBracesTrafo()

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

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

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

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ buildForm()

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

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

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

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 206 of file class.SettingsGUI.php.

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

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 228 of file class.SettingsGUI.php.

228 : string
229 {
230 return str_replace(['{{', '}}'], ['{{', '}}'], $value);
231 }

◆ executeCommand()

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

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

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

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 105 of file class.SettingsGUI.php.

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

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 74 of file class.SettingsGUI.php.

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

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 41 of file class.SettingsGUI.php.

◆ $upload_handler_gui

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

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


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