19declare(strict_types=1);
23use ILIAS\User\RedirectOnMissingWrite;
30use Psr\Http\Message\ServerRequestInterface;
38 use RedirectOnMissingWrite;
45 private readonly \
ilCtrl $ctrl,
49 private readonly UIFactory $ui_factory,
50 private readonly UIRenderer $ui_renderer,
52 private readonly ServerRequestInterface $request,
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);
70 $cmd = $this->
ctrl->getCmd() .
'Cmd';
74 private function showCmd(?StandardForm $form =
null): void
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')
102 $this->tpl->setContent($this->ui_renderer->render($content));
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'));
115 foreach (
$data[0] as $lang_code => $new_account_mail) {
116 $old_account_mail = $this->account_mail_repo->getFor($lang_code);
118 $new_attachment_rid = $new_account_mail[
'attachment'] === []
120 : $new_account_mail[
'attachment'][0];
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(
129 $old_account_mail->deleteAttachmentTempFile();
132 $this->account_mail_repo->store(
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']),
145 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
151 $ff = $this->ui_factory->input()->field();
153 foreach ($this->
lng->getInstalledLanguages() as $lang_code) {
154 $account_mail = $this->account_mail_repo->getFor($lang_code);
156 $title = $this->
lng->txt(
'meta_l_' . $lang_code);
157 if ($lang_code === $this->
lng->getDefaultLanguage()) {
158 $title .=
' (' . $this->
lng->txt(
'default') .
')';
161 $inputs[$lang_code] = $ff->section(
163 'subject' => $ff->text($this->lng->txt(
'subject'))
164 ->withAdditionalTransformation(
165 $this->buildConvertCurlyBracesTrafo()
166 )->withAdditionalTransformation(
167 $this->buildValidateMailBodyConstraint()
169 $this->convertCurlyBracesForFormOutput($account_mail->getSubject())
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()
183 $this->convertCurlyBracesForFormOutput($account_mail->getBody())
185 'attachment' => $ff->file($this->upload_handler_gui, $this->lng->txt(
'attachment'))
187 $account_mail->getAttachmentRid() ===
null
189 : [$account_mail->getAttachmentRid()]
196 return $this->ui_factory->input()->container()->form()->standard(
197 $this->
ctrl->getFormActionByClass(self::class,
'save'),
200 $this->lng->txt(
'user_new_account_mail'),
201 $this->lng->txt(
'user_new_account_mail_desc')
208 return $this->
refinery->custom()->constraint(
209 function ($v):
bool {
211 $this->mail_mustache_factory->getBasicEngine()->render($v, []);
213 }
catch (Exception) {
217 $this->
lng->txt(
'mail_template_invalid_tpl_syntax')
223 return $this->
refinery->custom()->transformation(
224 static fn(
string $v) => str_replace([
'{{',
'}}'], [
'{{',
'}}'], $v)
230 return str_replace([
'{{',
'}}'], [
'{{',
'}}'], $value);
Builds a Color from either hex- or rgb values.
@ilCtrl_Calls ILIAS\User\Settings\NewAccountMail\SettingsGUI: ILIAS\User\Settings\NewAccountMail\Uplo...
buildValidateMailBodyConstraint()
readonly UploadHandlerGUI $upload_handler_gui
buildConvertCurlyBracesTrafo()
convertCurlyBracesForFormOutput(string $value)
showCmd(?StandardForm $form=null)
readonly Stakeholder $stakeholder
__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)
Class ilAccessHandler Checks access for ILIAS objects.
Class ilCtrl provides processing control methods.
A constraint encodes some resrtictions on values.
An entity that renders components to a string output.