19declare(strict_types=1);
23use ILIAS\User\RedirectOnMissingWrite;
30use Psr\Http\Message\ServerRequestInterface;
39 use RedirectOnMissingWrite;
46 private readonly \
ilCtrl $ctrl,
50 private readonly UIFactory $ui_factory,
51 private readonly UIRenderer $ui_renderer,
53 private readonly ServerRequestInterface $request,
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);
71 $cmd = $this->
ctrl->getCmd() .
'Cmd';
75 private function showCmd(?StandardForm $form =
null): void
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')
103 $this->tpl->setContent($this->ui_renderer->render($content));
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'));
116 foreach (
$data[0] as $lang_code => $new_account_mail) {
117 $old_account_mail = $this->account_mail_repo->getFor($lang_code);
119 $new_attachment_rid = $new_account_mail[
'attachment'] === []
121 : $new_account_mail[
'attachment'][0];
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(
130 $old_account_mail->deleteAttachmentTempFile();
133 $this->account_mail_repo->store(
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']),
146 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
152 $ff = $this->ui_factory->input()->field();
154 foreach ($this->
lng->getInstalledLanguages() as $lang_code) {
155 $account_mail = $this->account_mail_repo->getFor($lang_code);
157 $title = $this->
lng->txt(
'meta_l_' . $lang_code);
158 if ($lang_code === $this->
lng->getDefaultLanguage()) {
159 $title .=
' (' . $this->
lng->txt(
'default') .
')';
162 $inputs[$lang_code] = $ff->section(
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'))
184 $account_mail->getAttachmentRid() ===
null
186 : [$account_mail->getAttachmentRid()]
193 return $this->ui_factory->input()->container()->form()->standard(
194 $this->
ctrl->getFormActionByClass(self::class,
'save'),
197 $this->lng->txt(
'user_new_account_mail'),
198 $this->lng->txt(
'user_new_account_mail_desc')
205 return $this->
refinery->custom()->constraint(
206 function ($v):
bool {
208 $this->mail_template_engine_factory->getBasicEngine()->render($v, []);
210 }
catch (\Exception) {
214 $this->
lng->txt(
'mail_template_invalid_tpl_syntax')
220 return $this->
refinery->custom()->transformation(
221 static fn(
string $v) => str_replace([
'{{',
'}}'], [
'{{',
'}}'], $v)
227 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)
__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)
readonly Stakeholder $stakeholder
Class ilAccessHandler Checks access for ILIAS objects.
Class ilCtrl provides processing control methods.
Factory interface for creating template engine instances.
A constraint encodes some resrtictions on values.
An entity that renders components to a string output.