ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilMailFormGUI Class Reference

@ilCtrl_Calls ilMailFormGUI: ilMailAttachmentGUI, ilMailSearchGUI, ilMailSearchCoursesGUI, ilMailSearchGroupsGUI, ilMailingListsGUI, ilMailFormUploadHandlerGUI @ilCtrl_Calls ilMailFormGUI: ILIAS\User\Search\EndpointGUI More...

+ Collaboration diagram for ilMailFormGUI:

Public Member Functions

 executeCommand ()
 
 saveMessageToOutbox (array $form_values, Form $form)
 
 sendMessage ()
 
 saveDraft ()
 
 searchUsers (bool $save=true)
 
 searchCoursesTo ()
 
 searchGroupsTo ()
 
 search ()
 
 cancelSearch ()
 
 editAttachments ()
 
 returnFromAttachments ()
 
 searchResults ()
 
 mailUser ()
 
 mailRole ()
 
 replyMail ()
 
 mailAttachment ()
 
 showForm (?Form $form=null)
 
 lookupRecipientAsync ()
 
 cancelMail ()
 
 searchMailingListsTo ()
 

Data Fields

final const string MAIL_FORM_TYPE_ATTACH = 'attach'
 
final const string MAIL_FORM_TYPE_SEARCH_RESULT = 'search_res'
 
final const string MAIL_FORM_TYPE_NEW = 'new'
 
final const string MAIL_FORM_TYPE_ROLE = 'role'
 
final const string MAIL_FORM_TYPE_REPLY = 'reply'
 
final const string MAIL_FORM_TYPE_ADDRESS = 'address'
 
final const string MAIL_FORM_TYPE_FORWARD = 'forward'
 
final const string MAIL_FORM_TYPE_DRAFT = 'draft'
 
final const string MAIL_FORM_TYPE_OUTBOX = 'outbox'
 

Protected Member Functions

 decodeAttachmentFiles (array $files)
 
 getTemplateDataById ()
 
 saveMailBeforeSearch ()
 
 showSubmissionErrors (array $errors)
 
 buildForm (?array $mail_data=null)
 
 buildFormElements (?array $mail_data)
 
 addToolbarButtons ()
 

Protected Attributes

ilMailTemplateService $template_service
 

Private Member Functions

 getQueryParam (string $name, Transformation $trafo, $default=null)
 
 getBodyParam (string $name, Transformation $trafo, $default=null)
 
 getUserSearchConfigurator ()
 

Private Attributes

readonly ilGlobalTemplateInterface $tpl
 
readonly ilCtrlInterface $ctrl
 
readonly ilLanguage $lng
 
readonly ilObjUser $user
 
readonly ilTabsGUI $tabs
 
readonly ilToolbarGUI $toolbar
 
readonly ilFormatMail $umail
 
readonly ilMailbox $mbox
 
readonly ilFileDataMail $mfile
 
readonly GlobalHttpState $http
 
readonly Refinery $refinery
 
array $request_attachments = null
 
readonly ilMailBodyPurifier $purifier
 
string $mail_form_type = ''
 
readonly Factory $ui_factory
 
readonly Renderer $ui_renderer
 
readonly Psr Http Message ServerRequestInterface $request
 
readonly ArrayBasedRequestWrapper $post
 
readonly ArrayBasedRequestWrapper $query
 
readonly ilMailFormUploadHandlerGUI $upload_handler
 
readonly ilFileDataMail $fdm
 
readonly ILIAS ResourceStorage Services $storage
 
readonly ilSetting $settings
 
readonly ILIAS User Search Search $user_search
 
readonly ClockFactory $clock
 

Detailed Description

Member Function Documentation

◆ addToolbarButtons()

ilMailFormGUI::addToolbarButtons ( )
protected

Definition at line 1214 of file class.ilMailFormGUI.php.

1214 : void
1215 {
1216 $bf = $this->ui_factory->button();
1217
1218 $action = $this->ctrl->getFormAction($this, 'searchUsers');
1219 $btn = $bf->standard(
1220 $this->lng->txt('search_recipients'),
1221 ''
1222 )->withAdditionalOnLoadCode(
1223 function ($id) use ($action) {
1224 return "document.getElementById('{$id}').addEventListener('click', function (event) {
1225 let mailform = document.querySelector('form.c-form');
1226 let btn = mailform.querySelector('button');
1227 btn.formAction = '{$action}';
1228 mailform.requestSubmit(btn);
1229 });";
1230 }
1231 );
1232
1233 $this->toolbar->addComponent($btn);
1234
1235 $action = $this->ctrl->getFormAction($this, 'searchCoursesTo');
1236 $btn = $bf->standard(
1237 $this->lng->txt('mail_my_courses'),
1238 ''
1239 )->withAdditionalOnLoadCode(
1240 function ($id) use ($action) {
1241 return "document.getElementById('{$id}').addEventListener('click', function (event) {
1242 let mailform = document.querySelector('form.c-form');
1243 let btn = mailform.querySelector('button');
1244 btn.formAction = '{$action}';
1245 mailform.requestSubmit(btn);
1246 });";
1247 }
1248 );
1249 $this->toolbar->addComponent($btn);
1250
1251 $action = $this->ctrl->getFormAction($this, 'searchGroupsTo');
1252 $btn = $bf->standard(
1253 $this->lng->txt('mail_my_groups'),
1254 ''
1255 )->withAdditionalOnLoadCode(
1256 function ($id) use ($action) {
1257 return "document.getElementById('{$id}').addEventListener('click', function (event) {
1258 let mailform = document.querySelector('form.c-form');
1259 let btn = mailform.querySelector('button');
1260 btn.formAction = '{$action}';
1261 mailform.requestSubmit(btn);
1262 });";
1263 }
1264 );
1265 $this->toolbar->addComponent($btn);
1266
1267 if (count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0) {
1268 $action = $this->ctrl->getFormAction($this, 'searchMailingListsTo');
1269 $btn = $bf->standard(
1270 $this->lng->txt('mail_my_mailing_lists'),
1271 ''
1272 )->withAdditionalOnLoadCode(
1273 function ($id) use ($action) {
1274 return "document.getElementById('{$id}').addEventListener('click', function (event) {
1275 let mailform = document.querySelector('form.c-form');
1276 let btn = mailform.querySelector('button');
1277 btn.formAction = '{$action}';
1278 mailform.requestSubmit(btn);
1279 });";
1280 }
1281 );
1282 $this->toolbar->addComponent($btn);
1283 }
1284
1285 $action = $this->ctrl->getFormAction($this, 'editAttachments');
1286 $btn = $bf->standard(
1287 $this->lng->txt('edit_attachments'),
1288 ''
1289 )->withAdditionalOnLoadCode(
1290 function ($id) use ($action) {
1291 return "document.getElementById('{$id}').addEventListener('click', function (event) {
1292 let mailform = document.querySelector('form.c-form');
1293 let btn = mailform.querySelector('button');
1294 btn.formAction = '{$action}';
1295 mailform.requestSubmit(btn);
1296 });";
1297 }
1298 );
1299 $this->toolbar->addComponent($btn);
1300 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getInstanceByGlobalUser(?ilObjUser $user=null)

References $id, ILIAS\Repository\ctrl(), ilBuddyList\getInstanceByGlobalUser(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by showForm().

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

◆ buildForm()

ilMailFormGUI::buildForm ( ?array  $mail_data = null)
protected

Definition at line 963 of file class.ilMailFormGUI.php.

963 : Form
964 {
965 return $this->ui_factory->input()->container()->form()->standard(
966 $this->ctrl->getFormAction($this, 'sendMessage'),
967 $this->buildFormElements($mail_data)
969 $this->ctrl->getFormAction($this, 'saveDraft'),
970 $this->lng->txt('save_message')
971 )->withSubmitLabel($this->lng->txt('send_mail'));
972 }
This describes commonalities between all forms.
Definition: Form.php:34
withAdditionalFormAction(string $action, string $label)
Get a form container like this, but provide an additional form action which will be displayed as an a...

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\UI\Component\Input\Container\Form\Form\withAdditionalFormAction().

Referenced by saveDraft(), saveMailBeforeSearch(), sendMessage(), and showForm().

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

◆ buildFormElements()

ilMailFormGUI::buildFormElements ( ?array  $mail_data)
protected

Definition at line 979 of file class.ilMailFormGUI.php.

979 : array
980 {
981 $ff = $this->ui_factory->input()->field();
982
983 $rcp_to = $this->user_search->getInput(
984 $this->lng->txt('mail_to'),
985 $this->getUserSearchConfigurator()
986 )->withRequired(true, $this->refinery->logical()->sequential([
987 $this->refinery->logical()->not($this->refinery->null()),
988 $this->refinery->string()->hasMinLength(1)
989 ])->withProblemBuilder(function ($txt) {
990 return $txt('mail_add_recipient');
991 }));
992 $rcp_cc = $this->user_search->getInput(
993 $this->lng->txt('mail_cc'),
995 );
996 $rcp_bcc = $this->user_search->getInput(
997 $this->lng->txt('mail_bcc'),
999 );
1000
1001 if (!is_null($mail_data)) {
1002 if (isset($mail_data['rcp_to']) && $mail_data['rcp_to'] != '') {
1003 $rcp_to = $rcp_to->withValue(explode(',', $mail_data['rcp_to']) ?? (array) $mail_data['rcp_to']);
1004 }
1005 if (isset($mail_data['rcp_cc']) && $mail_data['rcp_cc'] != '') {
1006 $rcp_cc = $rcp_cc->withValue(explode(',', $mail_data['rcp_cc']) ?? (array) $mail_data['rcp_cc']);
1007 }
1008 if (isset($mail_data['rcp_bcc']) && $mail_data['rcp_bcc'] != '') {
1009 $rcp_bcc = $rcp_bcc->withValue(explode(',', $mail_data['rcp_bcc']) ?? (array) $mail_data['rcp_bcc']);
1010 }
1011 }
1012
1013 $has_files = !empty($mail_data['attachments']);
1014 $attachments = $ff->file(
1015 $this->upload_handler,
1016 $this->lng->txt('attachments')
1017 )->withMaxFiles(10);
1018
1019 if (isset($mail_data['attachments']) && $has_files) {
1020 if ($mail_data['attachments'] instanceof \ILIAS\ResourceStorage\Identification\ResourceCollectionIdentification) {
1021 $mail_data['attachments'] = $this->FilesFromIRSSToLegacy($mail_data['attachments']);
1022 }
1023 $attachments = $attachments->withValue($mail_data['attachments'] ?? []);
1024 }
1025
1026 $template_chb = null;
1027 $signal = null;
1029 $context_id = ilMailFormCall::getContextId();
1030
1031 try {
1033
1034 $templates = $this->template_service->loadTemplatesForContextId($context->getId());
1035 if (count($templates) > 0) {
1036 $options = [];
1037
1038 $tmpl_value = '';
1039 $signal_generator = new ILIAS\UI\Implementation\Component\SignalGenerator();
1040 $signal = $signal_generator->create();
1041 foreach ($templates as $template) {
1042 $options[$template->getTplId()] = $template->getTitle();
1043 $signal->addOption($template->getTplId() . '_subject', urlencode($template->getSubject()));
1044 $signal->addOption($template->getTplId() . '_message', urlencode($template->getMessage()));
1045
1046 if (!isset($mail_data['template_id']) && $template->isDefault()) {
1047 $tmpl_value = $template->getTplId();
1048 $mail_data['m_subject'] = $template->getSubject();
1049 $mail_data['m_message'] = $this->umail->appendSignature($template->getMessage());
1050 }
1051 }
1052 if (isset($mail_data['template_id'])) {
1053 $tmpl_value = (int) $mail_data['template_id'];
1054 }
1055 asort($options);
1056
1057 $template_chb = $ff
1058 ->select(
1059 $this->lng->txt('mail_template_client'),
1060 $options,
1061 $this->lng->txt('mail_template_client_info')
1062 )
1063 ->withValue($tmpl_value)
1064 ->withOnUpdate($signal);
1065 }
1066 } catch (Exception $e) {
1067 ilLoggerFactory::getLogger('mail')->error(sprintf(
1068 '%s has been called with invalid context id: %s.',
1069 __METHOD__,
1070 $context_id
1071 ));
1072 }
1073 } else {
1075 }
1076
1077 $m_subject = $ff
1078 ->text($this->lng->txt('subject'))
1079 ->withRequired(
1080 true,
1081 $this->refinery->logical()->sequential([
1082 $this->refinery->logical()->not($this->refinery->null()),
1083 $this->refinery->string()->hasMinLength(1)
1084 ])->withProblemBuilder(function ($txt) {
1085 return $txt('mail_add_subject');
1086 })
1087 )
1088 ->withMaxLength(200)
1089 ->withValue($mail_data['m_subject'] ?? '');
1090
1091 $m_message = $ff->markdown(
1093 $this->lng->txt('message_content')
1094 )->withValue($mail_data['m_message'] ?? '');
1095
1096 $use_placeholders = $ff->hidden()->withValue('0');
1097 $placeholders = [];
1098 foreach ($context->getPlaceholders() as $key => $value) {
1099 $placeholders[$value['placeholder']] = $value['label'];
1100 }
1101 if (count($placeholders) > 0) {
1102 $m_message = $m_message
1103 ->withMustacheVariables(
1104 $placeholders,
1105 $this->lng->txt('mail_nacc_use_placeholder') . '<br />'
1106 . sprintf($this->lng->txt('placeholders_advise'), '<br />')
1107 )
1108 ;
1109 $use_placeholders = $use_placeholders->withValue('1');
1110 }
1111 $use_placeholders = $use_placeholders->withAdditionalTransformation(
1112 $this->refinery->kindlyTo()->bool()
1113 );
1114
1115 if ($signal !== null) {
1116 $m_subject = $m_subject->withAdditionalOnLoadCode(
1117 function ($id) use ($signal) {
1118 return "
1119 $(document).on('{$signal}', function (event, signalData) {
1120 let subject = document.getElementById('{$id}');
1121 let child = subject.querySelector('.c-input__field input');
1122 let triggerer = signalData.triggerer[0];
1123 let tplId = triggerer.querySelector('select').value;
1124 if (tplId != '') {
1125 child.value = decodeURIComponent(signalData.options[tplId + '_subject'].replace(/\+/g, ' '));
1126 }
1127 });
1128 ";
1129 }
1130 );
1131 $m_message = $m_message->withAdditionalOnLoadCode(
1132 function ($id) use ($signal) {
1133 return "
1134 $(document).on('{$signal}', function (event, signalData) {
1135 let message = document.getElementById('{$id}');
1136 let child = message.querySelector('.c-input__field textarea');
1137 let triggerer = signalData.triggerer[0];
1138 let tplId = triggerer.querySelector('select').value;
1139 if (tplId != '') {
1140 message.value = decodeURIComponent(signalData.options[tplId + '_message'].replace(/\+/g, ' '));
1141 }
1142 });
1143 ";
1144 }
1145 );
1146 }
1147
1148 $elements = [
1149 'rcp_to' => $rcp_to,
1150 'rcp_cc' => $rcp_cc,
1151 'rcp_bcc' => $rcp_bcc,
1152 'm_subject' => $m_subject,
1153 'attachments' => $attachments
1154 ];
1155 if ($template_chb !== null) {
1156 $elements[] = $template_chb;
1157 }
1158 $elements['m_message'] = $m_message;
1159
1160 $schedule_date_time_value = null;
1161 $current_time = $this->clock->local(new DateTimeZone($this->user->getTimeZone()))->now();
1162 $schedule_date_time_input = $ff
1163 ->dateTime($this->lng->txt('mail_schedule_scheduled_datetime'))
1164 ->withUseTime(true)
1165 ->withTimezone($this->user->getTimezone())
1167 $this->refinery->custom()->constraint(
1168 function (DateTimeImmutable $v) use ($current_time) {
1169 return $v > $current_time;
1170 },
1171 $this->lng->txt('mail_schedule_error_past_datetime')
1172 )
1173 );
1174
1175 if (isset($mail_data['schedule_datetime'])) {
1176 $schedule_time = new DateTimeImmutable(
1177 (string) $mail_data['schedule_datetime'],
1178 new DateTimeZone($mail_data['schedule_timezone'] ?? '')
1179 );
1180 $schedule_time->setTimezone(new DateTimeZone($this->user->getTimeZone()));
1181 $schedule_date_time_value = $schedule_time > $current_time ? $schedule_time : null;
1182 }
1183
1184 $use_schedule_input = $ff->optionalGroup(
1185 ['m_schedule' => $schedule_date_time_input],
1186 $this->lng->txt('mail_message_scheduled')
1187 )->withAdditionalTransformation(
1188 $this->refinery->custom()->constraint(
1189 function (?array $v) {
1190 return $v === null || (isset($v['m_schedule']) && $v['m_schedule'] instanceof DateTimeImmutable);
1191 },
1192 $this->lng->txt('mail_schedule_error_no_datetime')
1193 )
1194 );
1195 if ($schedule_date_time_value !== null) {
1196 $use_schedule_input = $use_schedule_input->withValue(['m_schedule' => $schedule_date_time_value]);
1197 } else {
1198 $use_schedule_input = $use_schedule_input->withValue(null);
1199 }
1200
1201 $elements['use_schedule'] = $use_schedule_input;
1202
1203 $elements['use_placeholders'] = $use_placeholders;
1204 $section = $ff->section(
1205 $elements,
1206 $this->lng->txt('compose')
1207 );
1208
1209 return [
1210 $section
1211 ];
1212 }
static getLogger(string $a_component_id)
Get component logger.
withAdditionalTransformation(Transformation $trafo)
@inheritDoc
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$context
Definition: webdav.php:31

References $context, Vendor\Package\$e, $id, ILIAS\UI\Implementation\Component\Input\Field\$options, ilMailFormCall\getContextId(), ilLoggerFactory\getLogger(), ilMailTemplateContextService\getTemplateContextById(), getUserSearchConfigurator(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\user(), ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

+ Here is the call graph for this function:

◆ cancelMail()

ilMailFormGUI::cancelMail ( )

Definition at line 903 of file class.ilMailFormGUI.php.

903 : void
904 {
907 }
908
909 $this->showForm();
910 }
showForm(?Form $form=null)
static redirect(string $a_script)

References ilMailFormCall\getRefererRedirectUrl(), ilMailFormCall\isRefererStored(), ilUtil\redirect(), and showForm().

+ Here is the call graph for this function:

◆ cancelSearch()

ilMailFormGUI::cancelSearch ( )

Definition at line 557 of file class.ilMailFormGUI.php.

557 : void
558 {
559 ilSession::clear('mail_search');
560 $this->searchResults();
561 }
static clear(string $a_var)

References ilSession\clear(), and searchResults().

+ Here is the call graph for this function:

◆ decodeAttachmentFiles()

ilMailFormGUI::decodeAttachmentFiles ( array  $files)
protected
Parameters
list<string>$files
Returns
list<string>

Definition at line 214 of file class.ilMailFormGUI.php.

214 : array
215 {
216 $decoded_files = [];
217 foreach ($files as $value) {
218 if (is_file($this->mfile->getMailPath() . '/' . $this->user->getId() . '_' . urldecode($value))) {
219 $decoded_files[] = urldecode($value);
220 }
221 }
222
223 return $decoded_files;
224 }

◆ editAttachments()

ilMailFormGUI::editAttachments ( )

Definition at line 563 of file class.ilMailFormGUI.php.

563 : void
564 {
565 $this->saveMailBeforeSearch();
566
567 $this->ctrl->setParameterByClass(ilMailAttachmentGUI::class, 'ref', 'mail');
568 $this->ctrl->redirectByClass(ilMailAttachmentGUI::class);
569 }

References ILIAS\Repository\ctrl(), and saveMailBeforeSearch().

+ Here is the call graph for this function:

◆ executeCommand()

ilMailFormGUI::executeCommand ( )

Definition at line 158 of file class.ilMailFormGUI.php.

158 : void
159 {
160 $forward_class = $this->ctrl->getNextClass($this) ?? '';
161 switch (strtolower($forward_class)) {
162 case strtolower(ILIAS\User\Search\EndpointGUI::class):
163 $gui = $this->user_search->getEndpointGUI(
165 );
166 $this->ctrl->forwardCommand($gui);
167 break;
168
169 case strtolower(ilMailAttachmentGUI::class):
170 $this->ctrl->setReturn($this, 'returnFromAttachments');
171 $gui = new ilMailAttachmentGUI();
172 $gui->consume();
173 $this->ctrl->forwardCommand($gui);
174 break;
175
176 case strtolower(ilMailSearchGUI::class):
177 $this->ctrl->setReturn($this, 'searchResults');
178 $this->ctrl->forwardCommand(new ilMailSearchGUI());
179 break;
180
181 case strtolower(ilMailSearchCoursesGUI::class):
182 $this->ctrl->setReturn($this, 'searchResults');
183 $this->ctrl->forwardCommand(new ilMailSearchCoursesGUI());
184 break;
185
186 case strtolower(ilMailingListsGUI::class):
187 $this->ctrl->setReturn($this, 'searchResults');
188 $this->ctrl->forwardCommand(new ilMailingListsGUI());
189 break;
190
191 case strtolower(ilMailSearchGroupsGUI::class):
192 $this->ctrl->setReturn($this, 'searchResults');
193 $this->ctrl->forwardCommand(new ilMailSearchGroupsGUI());
194 break;
195
196 case strtolower(ilMailFormUploadHandlerGUI::class):
197 $this->ctrl->forwardCommand($this->upload_handler);
198 break;
199
200 default:
201 if (!($cmd = $this->ctrl->getCmd())) {
202 $cmd = 'showForm';
203 }
204
205 $this->$cmd();
206 break;
207 }
208 }
@phpstan-import-type AutoCompleteUserRecord from RecipientSearchProvider
Definition: Search.php:27

References ILIAS\Repository\ctrl(), and getUserSearchConfigurator().

+ Here is the call graph for this function:

◆ getBodyParam()

ilMailFormGUI::getBodyParam ( string  $name,
Transformation  $trafo,
  $default = null 
)
private

Definition at line 146 of file class.ilMailFormGUI.php.

147 {
148 if ($this->http->wrapper()->post()->has($name)) {
149 return $this->http->wrapper()->post()->retrieve(
150 $name,
151 $trafo
152 );
153 }
154
155 return $default;
156 }
static http()
Fetches the global http state from ILIAS.

References ILIAS\FileDelivery\http().

Referenced by lookupRecipientAsync(), saveDraft(), saveMessageToOutbox(), and search().

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

◆ getQueryParam()

ilMailFormGUI::getQueryParam ( string  $name,
Transformation  $trafo,
  $default = null 
)
private

Definition at line 134 of file class.ilMailFormGUI.php.

135 {
136 if ($this->http->wrapper()->query()->has($name)) {
137 return $this->http->wrapper()->query()->retrieve(
138 $name,
139 $trafo
140 );
141 }
142
143 return $default;
144 }

References ILIAS\FileDelivery\http().

Referenced by showForm().

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

◆ getTemplateDataById()

ilMailFormGUI::getTemplateDataById ( )
protected

Definition at line 607 of file class.ilMailFormGUI.php.

607 : void
608 {
609 if (!$this->http->wrapper()->query()->has('template_id')) {
610 $this->http->close();
611 }
612
613 try {
614 $template = $this->template_service->loadTemplateForId(
615 $this->http->wrapper()->query()->retrieve('template_id', $this->refinery->kindlyTo()->int())
616 );
618
619 $this->http->saveResponse(
620 $this->http->response()
621 ->withHeader(ResponseHeader::CONTENT_TYPE, 'application/json')
622 ->withBody(Streams::ofString(json_encode([
623 'm_subject' => $template->getSubject(),
624 'm_message' => $this->umail->appendSignature($template->getMessage()),
625 ], JSON_THROW_ON_ERROR)))
626 );
627 } catch (Exception) {
628 }
629
630 $this->http->sendResponse();
631 $this->http->close();
632 }

References ilMailTemplateContextService\getTemplateContextById(), and ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getUserSearchConfigurator()

ilMailFormGUI::getUserSearchConfigurator ( )
private

◆ lookupRecipientAsync()

ilMailFormGUI::lookupRecipientAsync ( )

Definition at line 862 of file class.ilMailFormGUI.php.

862 : void
863 {
864 $search = trim((string) $this->getBodyParam(
865 'term',
866 $this->refinery->kindlyTo()->string(),
867 $this->getQueryParam(
868 'term',
869 $this->refinery->kindlyTo()->string(),
870 ''
871 )
872 ));
873
874 $result = [];
875
876 if (ilStr::strLen($search) < 3) {
877 $this->http->saveResponse(
878 $this->http->response()
879 ->withHeader(ResponseHeader::CONTENT_TYPE, 'application/json')
880 ->withBody(Streams::ofString(json_encode($result, JSON_THROW_ON_ERROR)))
881 );
882
883 $this->http->sendResponse();
884 $this->http->close();
885 }
886
887 // #14768
888 $quoted = ilUtil::stripSlashes($search);
889 $quoted = str_replace(['%', '_'], ['\%', '\_'], $quoted);
890
891 $form = new ilMailForm();
892 $result = $form->getRecipientAsync('%' . $quoted . '%', ilUtil::stripSlashes($search));
893
894 $this->http->saveResponse(
895 $this->http->response()
896 ->withHeader(ResponseHeader::CONTENT_TYPE, 'application/json')
897 ->withBody(Streams::ofString(json_encode($result, JSON_THROW_ON_ERROR)))
898 );
899 $this->http->sendResponse();
900 $this->http->close();
901 }
getBodyParam(string $name, Transformation $trafo, $default=null)
static strLen(string $a_string)
Definition: class.ilStr.php:60
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References getBodyParam(), ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), ilUtil\stripSlashes(), and ilStr\strLen().

+ Here is the call graph for this function:

◆ mailAttachment()

ilMailFormGUI::mailAttachment ( )

Definition at line 601 of file class.ilMailFormGUI.php.

601 : void
602 {
603 $this->mail_form_type = self::MAIL_FORM_TYPE_ATTACH;
604 $this->showForm();
605 }
final const string MAIL_FORM_TYPE_ATTACH

References MAIL_FORM_TYPE_ATTACH, and showForm().

+ Here is the call graph for this function:

◆ mailRole()

ilMailFormGUI::mailRole ( )

Definition at line 589 of file class.ilMailFormGUI.php.

589 : void
590 {
591 $this->mail_form_type = self::MAIL_FORM_TYPE_ROLE;
592 $this->showForm();
593 }
final const string MAIL_FORM_TYPE_ROLE

References MAIL_FORM_TYPE_ROLE, and showForm().

+ Here is the call graph for this function:

◆ mailUser()

ilMailFormGUI::mailUser ( )

Definition at line 583 of file class.ilMailFormGUI.php.

583 : void
584 {
585 $this->mail_form_type = self::MAIL_FORM_TYPE_NEW;
586 $this->showForm();
587 }
final const string MAIL_FORM_TYPE_NEW

References MAIL_FORM_TYPE_NEW, and showForm().

+ Here is the call graph for this function:

◆ replyMail()

ilMailFormGUI::replyMail ( )

Definition at line 595 of file class.ilMailFormGUI.php.

595 : void
596 {
597 $this->mail_form_type = self::MAIL_FORM_TYPE_REPLY;
598 $this->showForm();
599 }
final const string MAIL_FORM_TYPE_REPLY

References MAIL_FORM_TYPE_REPLY, and showForm().

+ Here is the call graph for this function:

◆ returnFromAttachments()

ilMailFormGUI::returnFromAttachments ( )

Definition at line 571 of file class.ilMailFormGUI.php.

571 : void
572 {
573 $this->mail_form_type = self::MAIL_FORM_TYPE_ATTACH;
574 $this->showForm();
575 }

References MAIL_FORM_TYPE_ATTACH, and showForm().

+ Here is the call graph for this function:

◆ saveDraft()

ilMailFormGUI::saveDraft ( )

Definition at line 405 of file class.ilMailFormGUI.php.

405 : void
406 {
407 $form = $this->buildForm()->withRequest($this->request);
408 $result = $form->getInputGroup()->getContent();
409
410 if (!$result->isOK()) {
411 $this->showForm($form);
412 return;
413 }
414
415 $value = $result->value()[0];
416
417 if ($value['m_subject'] === '') {
418 $value['m_subject'] = $this->lng->txt('mail_no_subject');
419 }
420 $files = [];
421 if (count($value['attachments']) > 0) {
422 $files = $this->handleAttachments($value['attachments']);
423 }
424
425 $draft_folder_id = $this->mbox->getDraftsFolder();
426
427 $rcp_to = ilUtil::securePlainString($this->getBodyParam('rcp_to', $this->refinery->kindlyTo()->string(), ''));
428 $rcp_cc = ilUtil::securePlainString($this->getBodyParam('rcp_cc', $this->refinery->kindlyTo()->string(), ''));
429 $rcp_bcc = ilUtil::securePlainString($this->getBodyParam('rcp_bcc', $this->refinery->kindlyTo()->string(), ''));
430
431 if ($errors = $this->umail->validateRecipients(
432 $rcp_to,
433 $rcp_cc,
434 $rcp_bcc,
435 )) {
436 $this->request_attachments = $files;
437 $this->showSubmissionErrors($errors);
438 $this->showForm($form);
439 return;
440 }
441
442 if (ilSession::get('draft')) {
443 $draft_id = (int) ilSession::get('draft');
444 ilSession::clear('draft');
445 } else {
446 $draft_id = $this->umail->getNewDraftId($draft_folder_id);
447 }
448
449 $this->umail->updateDraft(
450 $draft_folder_id,
451 $files,
452 implode(',', $value['rcp_to']),
453 implode(',', $value['rcp_cc']),
454 implode(',', $value['rcp_bcc']),
455 ilUtil::securePlainString($value['m_subject']),
456 $value['m_message'],
457 $draft_id,
458 $value['use_schedule']['m_schedule'] ?? null,
459 $value['use_placeholders'],
462 );
463
464 if (ilSession::get('outbox')) {
465 $outbox_id = (int) ilSession::get('outbox');
466 ilSession::clear('outbox');
467 $this->umail->deleteMails([$outbox_id]);
468 }
469
470 $this->ctrl->setParameterByClass(ilMailFolderGUI::class, 'mobj_id', $draft_folder_id);
471 $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_saved'), true);
472
475 } else {
476 $this->ctrl->redirectByClass([ilMailGUI::class, ilMailFolderGUI::class]);
477 }
478
479 $this->showForm();
480 }
buildForm(?array $mail_data=null)
showSubmissionErrors(array $errors)
static get(string $a_var)
static securePlainString(string $a_str)

References buildForm(), ilSession\clear(), ILIAS\Repository\ctrl(), ilSession\get(), getBodyParam(), ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilMailFormCall\getRefererRedirectUrl(), ILIAS\Repository\int(), ilMailFormCall\isRefererStored(), ILIAS\Repository\lng(), ilUtil\redirect(), ILIAS\Repository\refinery(), ilUtil\securePlainString(), showForm(), and showSubmissionErrors().

+ Here is the call graph for this function:

◆ saveMailBeforeSearch()

ilMailFormGUI::saveMailBeforeSearch ( )
protected

Definition at line 912 of file class.ilMailFormGUI.php.

912 : void
913 {
914 $form = $this->buildForm()->withRequest($this->request);
915 $result = $form->getInputGroup()->getInputs()[0]->getInputs();
916
917 $resource_collection_id = null;
918 $attachments = $result['attachments']->getValue();
919 if (count($attachments) > 0) {
920 $files = $this->handleAttachments($result['attachments']->getValue());
921 $resource_collection_id = $this->getIdforCollection($files);
922 }
923
924 $rcp_to = implode(',', $result['rcp_to']->getValue() ?? []);
925 $rcp_cc = implode(',', $result['rcp_cc']->getValue() ?? []);
926 $rcp_bcc = implode(',', $result['rcp_bcc']->getValue() ?? []);
927
928 $this->umail->persistToStage(
929 $this->user->getId(),
930 $rcp_to,
931 $rcp_cc,
932 $rcp_bcc,
933 ilUtil::securePlainString($result['m_subject']->getValue()),
934 ilUtil::securePlainString($result['m_message']->getValue()),
935 $resource_collection_id,
936 (bool) $result['use_placeholders']->getValue(),
939 );
940 }
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:49

References buildForm(), ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ILIAS\UI\Implementation\Component\Input\getValue(), ilUtil\securePlainString(), and ILIAS\Repository\user().

Referenced by editAttachments(), searchCoursesTo(), searchGroupsTo(), searchMailingListsTo(), and searchUsers().

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

◆ saveMessageToOutbox()

ilMailFormGUI::saveMessageToOutbox ( array  $form_values,
Form  $form 
)

Definition at line 226 of file class.ilMailFormGUI.php.

226 : void
227 {
228 $files = [];
229 if (count($form_values['attachments']) > 0) {
230 $files = $this->handleAttachments($form_values['attachments']);
231 }
232
233 $rcp_to = '';
234 $rcp_cc = '';
235 $rcp_bcc = '';
236 if ($form_values['rcp_to'] !== []) {
237 $rcp_to = $form_values['rcp_to'][0];
238 }
239 if ($form_values['rcp_cc'] !== []) {
240 $rcp_cc = $form_values['rcp_cc'][0];
241 }
242 if ($form_values['rcp_bcc'] !== []) {
243 $rcp_bcc = $form_values['rcp_bcc'][0];
244 }
245
246 $errors = $this->umail->validateRecipients(
247 $rcp_to,
248 $rcp_cc,
249 $rcp_bcc,
250 );
251 if ($errors) {
252 $this->showSubmissionErrors($errors);
253 $this->showForm();
254 $this->http->close();
255 }
256
257 $message = ilUtil::securePlainString($this->getBodyParam('m_message', $this->refinery->kindlyTo()->string(), ''));
258 $mail_body = new ilMailBody($message, $this->purifier);
259 $sanitized_message = $mail_body->getContent();
260
261 $outbox_folder_id = $this->mbox->getOutboxFolder();
262 if (ilSession::get('outbox')) {
263 $outbox_id = (int) ilSession::get('outbox');
264 ilSession::clear('outbox');
265 }
266
267 $this->umail->scheduledMail(
268 $outbox_folder_id,
269 $this->user->getId(),
272 $rcp_to,
273 $rcp_cc,
274 $rcp_bcc,
275 ilUtil::securePlainString($form_values['m_subject'] ?? $this->lng->txt('mail_no_subject')),
276 $sanitized_message,
277 $files,
278 $form_values['use_placeholders'],
279 $outbox_id ?? null
280 ),
281 $form_values['use_schedule']['m_schedule']
282 ),
285 );
286
287 if (ilSession::get('draft')) {
288 $draft_id = (int) ilSession::get('draft');
289 ilSession::clear('draft');
290 $this->umail->deleteMails([$draft_id]);
291 }
292
293 $this->ctrl->setParameterByClass(ilMailFolderGUI::class, 'mobj_id', $outbox_folder_id);
294 $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_scheduled'), true);
295
298 } else {
299 $this->ctrl->redirectByClass([ilMailGUI::class, ilMailFolderGUI::class]);
300 }
301
302 $this->showForm();
303 }

References ilSession\clear(), ILIAS\Repository\ctrl(), ilSession\get(), getBodyParam(), ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilMailFormCall\getRefererRedirectUrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ilMailFormCall\isRefererStored(), ILIAS\Repository\lng(), ilUtil\redirect(), ILIAS\Repository\refinery(), ilUtil\securePlainString(), showForm(), showSubmissionErrors(), and ILIAS\Repository\user().

Referenced by sendMessage().

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

◆ search()

ilMailFormGUI::search ( )

Definition at line 533 of file class.ilMailFormGUI.php.

533 : void
534 {
536 'mail_search_search',
537 ilUtil::securePlainString($this->getBodyParam('search', $this->refinery->kindlyTo()->string(), ''))
538 );
539
540 if (trim(ilSession::get('mail_search_search') ?? '') === '') {
541 $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_insert_query'));
542 $this->searchUsers(false);
543 } elseif (strlen(trim(ilSession::get('mail_search_search') ?? '')) < 3) {
544 $this->lng->loadLanguageModule('search');
545 $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_minimum_three'));
546 $this->searchUsers(false);
547 } else {
548 $this->ctrl->setParameterByClass(
549 ilMailSearchGUI::class,
550 'search',
551 urlencode(ilSession::get('mail_search_search') ?? '')
552 );
553 $this->ctrl->redirectByClass(ilMailSearchGUI::class);
554 }
555 }
searchUsers(bool $save=true)
static set(string $a_var, $a_val)
Set a value.

References ILIAS\Repository\ctrl(), ilSession\get(), getBodyParam(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), searchUsers(), ilUtil\securePlainString(), and ilSession\set().

+ Here is the call graph for this function:

◆ searchCoursesTo()

ilMailFormGUI::searchCoursesTo ( )

Definition at line 513 of file class.ilMailFormGUI.php.

513 : void
514 {
515 $this->saveMailBeforeSearch();
516
517 if (ilSession::get('search_crs')) {
518 $this->ctrl->setParameterByClass('ilmailsearchcoursesgui', 'cmd', 'showMembers');
519 }
520
521 $this->ctrl->setParameterByClass(ilMailSearchCoursesGUI::class, 'ref', 'mail');
522 $this->ctrl->redirectByClass(ilMailSearchCoursesGUI::class);
523 }

References ILIAS\Repository\ctrl(), ilSession\get(), and saveMailBeforeSearch().

+ Here is the call graph for this function:

◆ searchGroupsTo()

ilMailFormGUI::searchGroupsTo ( )

Definition at line 525 of file class.ilMailFormGUI.php.

525 : void
526 {
527 $this->saveMailBeforeSearch();
528
529 $this->ctrl->setParameterByClass(ilMailSearchGroupsGUI::class, 'ref', 'mail');
530 $this->ctrl->redirectByClass(ilMailSearchGroupsGUI::class);
531 }

References ILIAS\Repository\ctrl(), and saveMailBeforeSearch().

+ Here is the call graph for this function:

◆ searchMailingListsTo()

ilMailFormGUI::searchMailingListsTo ( )

Definition at line 942 of file class.ilMailFormGUI.php.

942 : void
943 {
944 $this->saveMailBeforeSearch();
945
946 $this->ctrl->setParameterByClass(ilMailingListsGUI::class, 'ref', 'mail');
947 $this->ctrl->redirectByClass(ilMailingListsGUI::class);
948 }

References ILIAS\Repository\ctrl(), and saveMailBeforeSearch().

+ Here is the call graph for this function:

◆ searchResults()

ilMailFormGUI::searchResults ( )

Definition at line 577 of file class.ilMailFormGUI.php.

577 : void
578 {
579 $this->mail_form_type = self::MAIL_FORM_TYPE_SEARCH_RESULT;
580 $this->showForm();
581 }
final const string MAIL_FORM_TYPE_SEARCH_RESULT

References MAIL_FORM_TYPE_SEARCH_RESULT, and showForm().

Referenced by cancelSearch().

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

◆ searchUsers()

ilMailFormGUI::searchUsers ( bool  $save = true)

Definition at line 482 of file class.ilMailFormGUI.php.

482 : void
483 {
484 $this->tpl->setTitle($this->lng->txt('mail_new'));
485
486 if ($save) {
487 $this->saveMailBeforeSearch();
488 }
489
490 $form = new ilPropertyFormGUI();
491 $form->setId('search_rcp');
492 $form->setTitle($this->lng->txt('search_recipients'));
493 $form->setFormAction($this->ctrl->getFormAction($this, 'search'));
494
495 $inp = new ilTextInputGUI($this->lng->txt('search_for'), 'search');
496 $inp->setSize(30);
497 $data_source_url = $this->ctrl->getLinkTarget($this, 'lookupRecipientAsync', '', true);
498 $inp->setDataSource($data_source_url);
499
500 $search_query = trim((string) ilSession::get('mail_search_search'));
501 if ($search_query !== '') {
502 $inp->setValue(ilLegacyFormElementsUtil::prepareFormOutput($search_query, true));
503 }
504 $form->addItem($inp);
505
506 $form->addCommandButton('search', $this->lng->txt('search'));
507 $form->addCommandButton('cancelSearch', $this->lng->txt('cancel'));
508
509 $this->tpl->setContent($form->getHTML());
510 $this->tpl->printToStdout();
511 }
static prepareFormOutput($a_str, bool $a_strip=false)
This class represents a property form user interface.
This class represents a text property in a property form.

References ILIAS\Repository\ctrl(), ilSession\get(), ILIAS\Repository\lng(), ilLegacyFormElementsUtil\prepareFormOutput(), and saveMailBeforeSearch().

Referenced by search().

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

◆ sendMessage()

ilMailFormGUI::sendMessage ( )

Definition at line 305 of file class.ilMailFormGUI.php.

305 : void
306 {
307 $form = $this->buildForm()->withRequest($this->request);
308 $result = $form->getInputGroup()->getContent();
309
310 if (!$result->isOK()) {
311 $this->showForm($form);
312 return;
313 }
314
315 $value = $result->value()[0];
316
317 $schedule_date = $value['use_schedule']['m_schedule'] ?? null;
318 if (
319 $schedule_date instanceof DateTimeImmutable &&
320 $schedule_date > $this->clock->local(new DateTimeZone($this->user->getTimeZone()))->now()
321 ) {
322 $this->saveMessageToOutbox($value, $form);
323 return;
324 }
325
326 $files = [];
327 if (count($value['attachments']) > 0) {
328 $files = $this->handleAttachments($value['attachments']);
329 }
330
331 $mailer = $this->umail
332 ->withContextId(ilMailFormCall::getContextId() ?: '')
333 ->withContextParameters(ilMailFormCall::getContextParameters());
334
335 $mailer->setSaveInSentbox(true);
336
337 $mailer->autoresponder()->enableAutoresponder();
338
339 $rcp_to = '';
340 $rcp_cc = '';
341 $rcp_bcc = '';
342 if ($value['rcp_to'] != []) {
343 $rcp_to = $value['rcp_to'][0];
344 }
345 if ($value['rcp_cc'] != []) {
346 $rcp_cc = $value['rcp_cc'][0];
347 }
348 if ($value['rcp_bcc'] != []) {
349 $rcp_bcc = $value['rcp_bcc'][0];
350 }
351
352 if ($errors = $mailer->enqueue(
353 $rcp_to,
354 $rcp_cc,
355 $rcp_bcc,
356 ilUtil::securePlainString($value['m_subject']),
357 $value['m_message'],
358 $files,
359 $value['use_placeholders']
360 )
361 ) {
362 $this->showSubmissionErrors($errors);
363 $this->showForm($form);
364 $this->http->close();
365 } else {
366 $mailer->autoresponder()->disableAutoresponder();
367
368 $mailer->persistToStage(
369 $this->user->getId(),
370 '',
371 '',
372 '',
373 '',
374 '',
375 null
376 );
377
378 $mail_id = null;
379 if (ilSession::get('outbox')) {
380 $mail_id = (int) ilSession::get('outbox');
381 ilSession::clear('outbox');
382 } elseif (ilSession::get('draft')) {
383 $mail_id = (int) ilSession::get('draft');
384 ilSession::clear('draft');
385 }
386
387 if ($mail_id) {
388 $mailer->deleteMails([$mail_id]);
389 }
390
391 $this->ctrl->setParameterByClass(ilMailGUI::class, 'type', 'message_sent');
392
394 $this->tpl->setOnScreenMessage('success', $this->lng->txt('mail_message_send'), true);
395 $this->ctrl->redirectToURL(ilMailFormCall::getRefererRedirectUrl());
396 } else {
397 $this->ctrl->redirectByClass(ilMailGUI::class);
398 }
399 }
400 $mailer->autoresponder()->disableAutoresponder();
401
402 $this->showForm();
403 }
saveMessageToOutbox(array $form_values, Form $form)

References buildForm(), ilSession\clear(), ILIAS\Repository\ctrl(), ilSession\get(), ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilMailFormCall\getRefererRedirectUrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ilMailFormCall\isRefererStored(), ILIAS\Repository\lng(), saveMessageToOutbox(), ilUtil\securePlainString(), showForm(), showSubmissionErrors(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showForm()

ilMailFormGUI::showForm ( ?Form  $form = null)

Definition at line 634 of file class.ilMailFormGUI.php.

634 : void
635 {
636 $this->tpl->addBlockFile(
637 'ADM_CONTENT',
638 'adm_content',
639 'tpl.mail_new.html',
640 'components/ILIAS/Mail'
641 );
642 $this->tpl->setTitle($this->lng->txt('mail_new'));
643
644 $this->lng->loadLanguageModule('crs');
645
647 $this->tabs->setBackTarget(
648 $this->lng->txt('back'),
649 $this->ctrl->getLinkTarget($this, 'cancelMail')
650 );
651 }
652
653 $mail_data = [];
654 $mail_data['rcp_to'] = '';
655 $mail_data['rcp_cc'] = '';
656 $mail_data['rcp_bcc'] = '';
657 $mail_data['attachments'] = [];
658 $mail_data['m_subject'] = '';
659 $mail_data['m_message'] = '';
660
661 $mail_id = $this->getQueryParam('mail_id', $this->refinery->kindlyTo()->int(), 0);
662 $type = $this->getQueryParam('type', $this->refinery->kindlyTo()->string(), '');
663 if ($this->mail_form_type !== '') {
664 $type = $this->mail_form_type;
665 }
666
667 switch ($type) {
669 $mail_data = $this->umail->getMail($mail_id);
670
671 $mail_data['m_subject'] = $this->umail->formatReplySubject($mail_data['m_subject'] ?? '');
672 $mail_data['m_message'] = $this->umail->prependSignature(
673 $this->umail->formatReplyMessage($mail_data['m_message'] ?? '')
674 );
675 $mail_data['attachments'] = [];
676 $mail_data['rcp_cc'] = '';
677 $mail_data['rcp_to'] = $this->umail->formatReplyRecipient();
678 break;
679
681 $mail_data = $this->umail->retrieveFromStage();
682 if (ilSession::get('mail_search_results_to')) {
683 $mail_data = $this->umail->appendSearchResult(
684 $this->refinery->kindlyTo()->listOf(
685 $this->refinery->kindlyTo()->string()
686 )->transform(ilSession::get('mail_search_results_to')),
687 'to'
688 );
689 }
690 if (ilSession::get('mail_search_results_cc')) {
691 $mail_data = $this->umail->appendSearchResult(
692 $this->refinery->kindlyTo()->listOf(
693 $this->refinery->kindlyTo()->string()
694 )->transform(ilSession::get('mail_search_results_cc')),
695 'cc'
696 );
697 }
698 if (ilSession::get('mail_search_results_bcc')) {
699 $mail_data = $this->umail->appendSearchResult(
700 $this->refinery->kindlyTo()->listOf(
701 $this->refinery->kindlyTo()->string()
702 )->transform(ilSession::get('mail_search_results_bcc')),
703 'bc'
704 );
705 }
706
707 ilSession::clear('mail_search_results_to');
708 ilSession::clear('mail_search_results_cc');
709 ilSession::clear('mail_search_results_bcc');
710 break;
711
713 ilSession::set('draft', $mail_id);
714 $mail_data = $this->umail->getMail($mail_id);
715
716 if (!is_null($mail_data['attachments']) || !empty($mail_data['attachments'])) {
717 $mail_data['attachments'] = $this->filesFromLegacyToIRSS($mail_data);
718 }
719
720 ilMailFormCall::setContextId($mail_data['tpl_ctx_id']);
721 ilMailFormCall::setContextParameters($mail_data['tpl_ctx_params']);
722 break;
723
725 ilSession::set('outbox', $mail_id);
726 $mail_data = $this->umail->getMail($mail_id);
727 ilMailFormCall::setContextId($mail_data['tpl_ctx_id']);
728 ilMailFormCall::setContextParameters($mail_data['tpl_ctx_params']);
729 break;
730
732 $mail_data = $this->umail->getMail($mail_id);
733 $mail_data['rcp_to'] = $mail_data['rcp_cc'] = $mail_data['rcp_bcc'] = '';
734 $mail_data['m_subject'] = $this->umail->formatForwardSubject($mail_data['m_subject'] ?? '');
735 $mail_data['m_message'] = $this->umail->prependSignature($mail_data['m_message'] ?? '');
736 if (is_array($mail_data['attachments']) && count($mail_data['attachments']) && $error = $this->mfile->adoptAttachments(
737 $mail_data['attachments'],
738 $mail_id
739 )) {
740 $this->tpl->setOnScreenMessage('info', $error);
741 }
742
743 if (!is_null($mail_data['attachments']) || ($mail_data['attachments'] != '')) {
744 $mail_data['attachments'] = $this->filesFromLegacyToIRSS($mail_data);
745 }
746 break;
747
749 ilSession::clear('draft');
750 ilSession::clear('outbox');
751 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
752 $to = ilUtil::securePlainString($this->getQueryParam('rcp_to', $this->refinery->kindlyTo()->string(), ''));
753 if ($to === '' && ilSession::get('rcp_to')) {
754 $to = ilSession::get('rcp_to');
755 }
756 $mail_data['rcp_to'] = $to;
757
758 $cc = ilUtil::securePlainString($this->getQueryParam('rcp_cc', $this->refinery->kindlyTo()->string(), ''));
759 if ($cc === '' && ilSession::get('rcp_cc')) {
760 $cc = ilSession::get('rcp_cc');
761 }
762 $mail_data['rcp_cc'] = $cc;
763
764 $bcc = ilUtil::securePlainString($this->getQueryParam('rcp_bcc', $this->refinery->kindlyTo()->string(), ''));
765 if ($bcc === '' && ilSession::get('rcp_bcc')) {
766 $bcc = ilSession::get('rcp_bcc');
767 }
768 $mail_data['rcp_bcc'] = $bcc;
769
770 $mail_data['m_message'] = '';
771 if (($sig = ilMailFormCall::getSignature()) !== '') {
772 $mail_data['m_message'] = $sig;
773 $mail_data['m_message'] .= chr(13)
774 . chr(10)
775 . chr(13)
776 . chr(10);
777 }
778 $mail_data['m_message'] .= $this->umail->appendSignature('');
779
780 ilSession::set('rcp_to', '');
781 ilSession::set('rcp_cc', '');
782 ilSession::set('rcp_bcc', '');
783 break;
784
786 $roles = [];
787 if ($this->http->wrapper()->post()->has('roles')) {
788 $roles = $this->http->wrapper()->post()->retrieve(
789 'roles',
790 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
791 );
792 } elseif (is_array(ilSession::get('mail_roles'))) {
793 $roles = $this->refinery->kindlyTo()->listOf(
794 $this->refinery->kindlyTo()->string()
795 )->transform(ilSession::get('mail_roles'));
796 }
797
798 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
799 $mail_data['rcp_to'] = ilUtil::securePlainString(
800 implode(',', $roles)
801 );
802
803 $mail_data['m_message'] = '';
804 if (($sig = ilMailFormCall::getSignature()) !== '') {
805 $mail_data['m_message'] = $sig;
806 $mail_data['m_message'] .= chr(13)
807 . chr(10)
808 . chr(13)
809 . chr(10);
810 }
811
812 $additional_msg_text = '';
813 if ($this->http->wrapper()->post()->has('additional_message_text')) {
814 $additional_msg_text = ilUtil::securePlainString($this->http->wrapper()->post()->retrieve(
815 'additional_message_text',
816 $this->refinery->kindlyTo()->string()
817 ));
818 }
819
820 $mail_data['m_message'] .= $additional_msg_text
821 . chr(13)
822 . chr(10)
823 . $this->umail->appendSignature('');
824 ilSession::set('mail_roles', []);
825 break;
826
828 $rcp = '';
829 if ($this->http->wrapper()->query()->has('rcp')) {
830 $rcp = $this->http->wrapper()->query()->retrieve('rcp', $this->refinery->kindlyTo()->string());
831 }
832 $mail_data['rcp_to'] = urldecode((string) $rcp);
833 break;
835 $mail_data = $this->umail->retrieveFromStage();
836 break;
837 default:
838 $mail_data = $this->http->request()->getParsedBody();
839 foreach ($mail_data as $key => $value) {
840 if (is_string($value)) {
841 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
842 $mail_data[$key] = ilUtil::securePlainString($value);
843 }
844 }
845
846 if ($this->request_attachments) {
847 $mail_data['attachments'] = $this->request_attachments;
848 }
849 break;
850 }
851
852 $this->tpl->parseCurrentBlock();
853 $this->addToolbarButtons();
854 if ($form === null) {
855 $form = $this->buildForm($mail_data);
856 }
857 $this->tpl->setVariable('FORM', $this->ui_renderer->render($form));
858 $this->tpl->addJavaScript('assets/js/ilMailComposeFunctions.js');
859 $this->tpl->printToStdout();
860 }
static setContextId(?string $id)
static setContextParameters(array $parameters)
final const string MAIL_FORM_TYPE_DRAFT
final const string MAIL_FORM_TYPE_ADDRESS
final const string MAIL_FORM_TYPE_FORWARD
getQueryParam(string $name, Transformation $trafo, $default=null)
final const string MAIL_FORM_TYPE_OUTBOX

References $mail_form_type, $request_attachments, addToolbarButtons(), buildForm(), ilSession\clear(), ilSession\get(), getQueryParam(), ilMailFormCall\getSignature(), ILIAS\FileDelivery\http(), ilMailFormCall\isRefererStored(), ILIAS\Repository\lng(), MAIL_FORM_TYPE_ADDRESS, MAIL_FORM_TYPE_ATTACH, MAIL_FORM_TYPE_DRAFT, MAIL_FORM_TYPE_FORWARD, MAIL_FORM_TYPE_NEW, MAIL_FORM_TYPE_OUTBOX, MAIL_FORM_TYPE_REPLY, MAIL_FORM_TYPE_ROLE, MAIL_FORM_TYPE_SEARCH_RESULT, ILIAS\Repository\refinery(), ilUtil\securePlainString(), ilSession\set(), ilMailFormCall\setContextId(), ilMailFormCall\setContextParameters(), and ILIAS\Repository\tabs().

Referenced by cancelMail(), mailAttachment(), mailRole(), mailUser(), replyMail(), returnFromAttachments(), saveDraft(), saveMessageToOutbox(), searchResults(), and sendMessage().

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

◆ showSubmissionErrors()

ilMailFormGUI::showSubmissionErrors ( array  $errors)
protected
Parameters
list<ilMailError>$errors

Definition at line 953 of file class.ilMailFormGUI.php.

953 : void
954 {
955 $formatter = new ilMailErrorFormatter($this->lng);
956 $formatted_errors = $formatter->format($errors);
957
958 if ($formatted_errors !== '') {
959 $this->tpl->setOnScreenMessage('failure', $formatted_errors);
960 }
961 }

References ILIAS\Repository\lng().

Referenced by saveDraft(), saveMessageToOutbox(), and sendMessage().

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

Field Documentation

◆ $clock

readonly ClockFactory ilMailFormGUI::$clock
private

Definition at line 82 of file class.ilMailFormGUI.php.

◆ $ctrl

readonly ilCtrlInterface ilMailFormGUI::$ctrl
private

Definition at line 58 of file class.ilMailFormGUI.php.

◆ $fdm

readonly ilFileDataMail ilMailFormGUI::$fdm
private

Definition at line 78 of file class.ilMailFormGUI.php.

◆ $http

readonly GlobalHttpState ilMailFormGUI::$http
private

Definition at line 66 of file class.ilMailFormGUI.php.

◆ $lng

readonly ilLanguage ilMailFormGUI::$lng
private

Definition at line 59 of file class.ilMailFormGUI.php.

◆ $mail_form_type

string ilMailFormGUI::$mail_form_type = ''
private

Definition at line 71 of file class.ilMailFormGUI.php.

Referenced by showForm().

◆ $mbox

readonly ilMailbox ilMailFormGUI::$mbox
private

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

◆ $mfile

readonly ilFileDataMail ilMailFormGUI::$mfile
private

Definition at line 65 of file class.ilMailFormGUI.php.

◆ $post

readonly ArrayBasedRequestWrapper ilMailFormGUI::$post
private

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

◆ $purifier

readonly ilMailBodyPurifier ilMailFormGUI::$purifier
private

Definition at line 70 of file class.ilMailFormGUI.php.

◆ $query

readonly ArrayBasedRequestWrapper ilMailFormGUI::$query
private

Definition at line 76 of file class.ilMailFormGUI.php.

◆ $refinery

readonly Refinery ilMailFormGUI::$refinery
private

Definition at line 67 of file class.ilMailFormGUI.php.

◆ $request

readonly Psr Http Message ServerRequestInterface ilMailFormGUI::$request
private

Definition at line 74 of file class.ilMailFormGUI.php.

◆ $request_attachments

array ilMailFormGUI::$request_attachments = null
private

Definition at line 68 of file class.ilMailFormGUI.php.

Referenced by showForm().

◆ $settings

readonly ilSetting ilMailFormGUI::$settings
private

Definition at line 80 of file class.ilMailFormGUI.php.

◆ $storage

readonly ILIAS ResourceStorage Services ilMailFormGUI::$storage
private

Definition at line 79 of file class.ilMailFormGUI.php.

◆ $tabs

readonly ilTabsGUI ilMailFormGUI::$tabs
private

Definition at line 61 of file class.ilMailFormGUI.php.

◆ $template_service

ilMailTemplateService ilMailFormGUI::$template_service
protected

Definition at line 69 of file class.ilMailFormGUI.php.

◆ $toolbar

readonly ilToolbarGUI ilMailFormGUI::$toolbar
private

Definition at line 62 of file class.ilMailFormGUI.php.

◆ $tpl

readonly ilGlobalTemplateInterface ilMailFormGUI::$tpl
private

Definition at line 57 of file class.ilMailFormGUI.php.

◆ $ui_factory

readonly Factory ilMailFormGUI::$ui_factory
private

Definition at line 72 of file class.ilMailFormGUI.php.

◆ $ui_renderer

readonly Renderer ilMailFormGUI::$ui_renderer
private

Definition at line 73 of file class.ilMailFormGUI.php.

◆ $umail

readonly ilFormatMail ilMailFormGUI::$umail
private

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

◆ $upload_handler

readonly ilMailFormUploadHandlerGUI ilMailFormGUI::$upload_handler
private

Definition at line 77 of file class.ilMailFormGUI.php.

◆ $user

readonly ilObjUser ilMailFormGUI::$user
private

Definition at line 60 of file class.ilMailFormGUI.php.

◆ $user_search

readonly ILIAS User Search Search ilMailFormGUI::$user_search
private

Definition at line 81 of file class.ilMailFormGUI.php.

◆ MAIL_FORM_TYPE_ADDRESS

final const string ilMailFormGUI::MAIL_FORM_TYPE_ADDRESS = 'address'

Definition at line 52 of file class.ilMailFormGUI.php.

Referenced by showForm().

◆ MAIL_FORM_TYPE_ATTACH

final const string ilMailFormGUI::MAIL_FORM_TYPE_ATTACH = 'attach'

◆ MAIL_FORM_TYPE_DRAFT

final const string ilMailFormGUI::MAIL_FORM_TYPE_DRAFT = 'draft'

Definition at line 54 of file class.ilMailFormGUI.php.

Referenced by ilMailFolderGUI\executeTableAction(), and showForm().

◆ MAIL_FORM_TYPE_FORWARD

final const string ilMailFormGUI::MAIL_FORM_TYPE_FORWARD = 'forward'

Definition at line 53 of file class.ilMailFormGUI.php.

Referenced by ilMailFolderGUI\executeTableAction(), and showForm().

◆ MAIL_FORM_TYPE_NEW

◆ MAIL_FORM_TYPE_OUTBOX

final const string ilMailFormGUI::MAIL_FORM_TYPE_OUTBOX = 'outbox'

Definition at line 55 of file class.ilMailFormGUI.php.

Referenced by showForm().

◆ MAIL_FORM_TYPE_REPLY

final const string ilMailFormGUI::MAIL_FORM_TYPE_REPLY = 'reply'

◆ MAIL_FORM_TYPE_ROLE

final const string ilMailFormGUI::MAIL_FORM_TYPE_ROLE = 'role'

◆ MAIL_FORM_TYPE_SEARCH_RESULT

final const string ilMailFormGUI::MAIL_FORM_TYPE_SEARCH_RESULT = 'search_res'

Definition at line 48 of file class.ilMailFormGUI.php.

Referenced by ilMailGUI\executeCommand(), searchResults(), and showForm().


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