19 declare(strict_types=1);
42 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference)
48 $this->
tabs = $DIC->tabs();
49 $this->mustache_factory = $DIC->mail()->mustacheFactory();
50 $this->mail_signature_service = $DIC->mail()->signature();
52 $this->
lng->loadLanguageModule(
'mail');
57 $next_class = $this->
ctrl->getNextClass($this) ??
'';
58 $cmd = $this->
ctrl->getCmd();
61 switch (strtolower($next_class)) {
62 case strtolower(ilPermissionGUI::class):
64 $this->
ctrl->forwardCommand($perm_gui);
67 case strtolower(ilMailTemplateGUI::class):
69 $this->
ilias->raiseError(
70 $this->
lng->txt(
'msg_no_perm_write'),
71 $this->
ilias->error_obj->WARNING
90 return $this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
95 return $this->rbac_system->checkAccess(
'read', $this->
object->getRefId());
100 return $this->rbac_system->checkAccess(
'edit_permission', $this->
object->getRefId());
111 $this->
tabs->addTarget(
113 $this->
ctrl->getLinkTarget($this,
'view'),
118 'showExternalSettingsForm',
119 'saveExternalSettingsForm',
121 'sendTestSystemMail',
127 $this->
tabs->addTarget(
129 $this->
ctrl->getLinkTargetByClass(ilMailTemplateGUI::class,
'showTemplates'),
131 ilMailTemplateGUI::class
136 $this->
tabs->addTarget(
138 $this->
ctrl->getLinkTargetByClass([static::class, ilPermissionGUI::class],
'perm'),
139 [
'perm',
'info',
'owner'],
140 ilPermissionGUI::class
148 $this->
tabs->addSubTab(
149 self::SETTINGS_SUB_TAB_ID_GENERAL,
150 $this->
lng->txt(
'mail_settings_general_tab'),
151 $this->
ctrl->getLinkTarget($this,
'view')
154 if ($this->
settings->get(
'mail_allow_external',
'0')) {
155 $this->
tabs->addSubTab(
156 self::SETTINGS_SUB_TAB_ID_EXTERNAL,
157 $this->
lng->txt(
'mail_settings_external_tab'),
158 $this->
ctrl->getLinkTarget($this,
'showExternalSettingsForm')
162 $this->
tabs->activateSubTab($activeSubTab);
174 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
179 if ($form ===
null) {
184 $this->tpl->setContent($form->getHTML());
191 $form->setFormAction($this->
ctrl->getFormAction($this,
'save'));
192 $form->setTitle($this->
lng->txt(
'general_settings'));
195 $cb->setInfo($this->
lng->txt(
'mail_allow_external_info'));
201 $this->
lng->txt(
'mail_incoming'),
205 $this->
ctrl->setParameterByClass(ilObjUserFolderGUI::class,
'ref_id',
USER_FOLDER_ID);
206 $incoming_mail_gui->setInfo(sprintf(
207 $this->
lng->txt(
'mail_settings_incoming_type_see_also'),
208 $this->
ctrl->getLinkTargetByClass(ilObjUserFolderGUI::class,
'settings')
210 $this->
ctrl->clearParametersByClass(ilObjUserFolderGUI::class);
211 $form->addItem($incoming_mail_gui);
214 $this->
lng->txt(
'show_mail_settings'),
217 $show_mail_settings_gui->setInfo($this->
lng->txt(
'show_mail_settings_info'));
218 $show_mail_settings_gui->setValue(
'1');
219 $form->addItem($show_mail_settings_gui);
223 $ti->setInfo($this->
lng->txt(
'mail_max_size_attachments_total'));
224 $ti->setMaxLength(10);
230 $mn->setTitle($this->
lng->txt(
'mail_member_notification'));
234 $this->
lng->txt(
'cron_mail_notification'),
238 0 => $this->
lng->txt(
'cron_mail_notification_never'),
239 1 => $this->
lng->txt(
'cron_mail_notification_cron'),
242 $cron_mail->setInfo(sprintf(
243 $this->
lng->txt(
'cron_mail_notification_desc'),
244 $this->
lng->txt(
'mail_allow_external')
247 $form->addItem($cron_mail);
256 $mn->setTitle($this->
lng->txt(
'mail_auto_responder'));
259 $input =
new ilNumberInputGUI($this->
lng->txt(
'mail_auto_responder_idle_time'),
'mail_auto_responder_idle_time');
261 $input->allowDecimals(
false);
262 $input->setInfo($this->
lng->txt(
'mail_auto_responder_idle_time_info'));
263 $input->setSuffix($this->
lng->txt(
'days'));
266 $form->addItem($input);
269 $form->addCommandButton(
'save', $this->
lng->txt(
'save'));
278 'mail_allow_external' => (
bool) $this->
settings->get(
'mail_allow_external',
'0'),
279 'incoming_type' => (string) $this->
settings->get(
'mail_incoming_mail',
'0'),
280 'mail_address_option' => $this->
settings->get(
'mail_address_option',
'') !==
'' ?
281 $this->
settings->get(
'mail_address_option') :
283 'mail_address_option_both' => $this->
settings->get(
'mail_address_option',
'') !==
'' ?
284 $this->
settings->get(
'mail_address_option') :
286 'show_mail_settings' => (
bool) $this->
settings->get(
'show_mail_settings',
'1'),
287 'mail_maxsize_attach' => $this->
settings->get(
'mail_maxsize_attach',
''),
288 'mail_notification' => $this->
settings->get(
'mail_notification',
''),
289 'mail_auto_responder_idle_time' => is_numeric($this->
settings->get(
'mail_auto_responder_idle_time', (
string) AutoresponderService::AUTO_RESPONDER_DEFAULT_IDLE_TIME)) ?
290 (
string) $this->
settings->get(
'mail_auto_responder_idle_time',
'3') :
298 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
302 if ($form->checkInput()) {
303 $incoming_type = (
int) $form->getInput(
'incoming_type');
307 $mail_address_option = (
int) $form->getInput(
'mail_address_option');
309 $mail_address_option = (
int) $form->getInput(
'mail_address_option_both');
312 $this->
settings->set(
'mail_allow_external', (
string) ((
int) $form->getInput(
'mail_allow_external')));
313 $this->
settings->set(
'mail_incoming_mail', (
string) $incoming_type);
314 $this->
settings->set(
'show_mail_settings', (
string) ((
int) $form->getInput(
'show_mail_settings')));
315 $this->
settings->set(
'mail_address_option', (
string) $mail_address_option);
316 $this->
settings->set(
'mail_maxsize_attach', (
string) $form->getInput(
'mail_maxsize_attach'));
317 $this->
settings->set(
'mail_notification', (
string) ((
int) $form->getInput(
'mail_notification')));
318 $this->
settings->set(
'mail_auto_responder_idle_time', (
string) $form->getInput(
'mail_auto_responder_idle_time'));
320 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
321 $this->
ctrl->redirect($this);
324 $form->setValuesByPost();
331 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
336 if ($form ===
null) {
341 if ($this->
user->getEmail() !==
'') {
342 $this->
toolbar->addComponent($this->ui_factory->button()->standard(
343 $this->
lng->txt(
'mail_external_send_test_usr'),
344 $this->
ctrl->getLinkTarget($this,
'sendTestUserMail')
346 $this->
toolbar->addComponent($this->ui_factory->button()->standard(
347 $this->
lng->txt(
'mail_external_send_test_sys'),
348 $this->
ctrl->getLinkTarget($this,
'sendTestSystemMail')
352 $this->tpl->setContent($form->getHTML());
368 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
371 if ($this->
user->getEmail() ===
'') {
382 $mail->setSaveInSentbox(
false);
383 $mail->appendInstallationSignature(!$isManualMail);
385 $lngVariablePrefix =
'sys';
387 $lngVariablePrefix =
'usr';
391 $this->
user->getEmail(),
394 $this->
lng->txt(
'mail_email_' . $lngVariablePrefix .
'_subject'),
395 $this->
lng->txt(
'mail_email_' . $lngVariablePrefix .
'_body'),
399 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_external_test_sent'));
407 $form->setFormAction($this->
ctrl->getFormAction($this,
'saveExternalSettingsForm'));
408 $form->setTitle($this->
lng->txt(
'mail_settings_external_frm_head'));
411 $smtp->setInfo($this->
lng->txt(
'mail_smtp_status_info'));
412 $smtp->setValue(
'1');
414 $form->addItem($smtp);
417 $host->setInfo($this->
lng->txt(
'mail_smtp_host_info'));
418 $host->setRequired(
true);
420 $smtp->addSubItem($host);
423 $port->
setInfo($this->
lng->txt(
'mail_smtp_port_info'));
424 $port->allowDecimals(
false);
425 $port->setMinValue(0);
426 $port->setMinValue(0);
427 $port->setRequired(
true);
429 $smtp->addSubItem($port);
432 $this->
lng->txt(
'mail_smtp_encryption'),
433 'mail_smtp_encryption' 435 $encryptionOptions = [
436 '' => $this->
lng->txt(
'please_choose'),
437 'tls' => $this->
lng->txt(
'mail_smtp_encryption_tls'),
438 'ssl' => $this->
lng->txt(
'mail_smtp_encryption_ssl'),
443 $smtp->addSubItem($encryption);
447 $user->setDisableHtmlAutoComplete(
true);
448 $smtp->addSubItem(
$user);
451 $this->
lng->txt(
'mail_smtp_password'),
455 $password->setSkipSyntaxCheck(
true);
457 $password->setDisableHtmlAutoComplete(
true);
458 $smtp->addSubItem($password);
460 $pre =
new ilTextInputGUI($this->
lng->txt(
'mail_subject_prefix'),
'mail_subject_prefix');
462 $pre->setMaxLength(32);
463 $pre->setInfo($this->
lng->txt(
'mail_subject_prefix_info'));
465 $form->addItem($pre);
468 $send_html->setInfo($this->
lng->txt(
'mail_send_html_info'));
469 $send_html->setValue(
'1');
471 $form->addItem($send_html);
474 $sh->setTitle($this->
lng->txt(
'mail_settings_user_frm_head'));
478 $this->
lng->txt(
'mail_system_usr_from_addr'),
479 'mail_system_usr_from_addr' 481 $user_from_address->
setInfo($this->
lng->txt(
'mail_system_usr_from_addr_info'));
482 $user_from_address->setRequired(
true);
484 $form->addItem($user_from_address);
487 $this->
lng->txt(
'mail_use_global_reply_to_addr'),
488 'use_global_reply_to_addr' 490 $useGlobalReplyToAddress->setInfo($this->
lng->txt(
'mail_use_global_reply_to_addr_info'));
491 $useGlobalReplyToAddress->setValue(
'1');
493 $form->addItem($useGlobalReplyToAddress);
495 $this->
lng->txt(
'mail_global_reply_to_addr'),
496 'global_reply_to_addr' 498 $globalReplyTo->
setInfo($this->
lng->txt(
'mail_global_reply_to_addr_info'));
499 $globalReplyTo->setRequired(
true);
501 $useGlobalReplyToAddress->addSubItem($globalReplyTo);
504 $this->
lng->txt(
'mail_system_usr_from_name'),
505 'mail_system_usr_from_name' 507 $user_from_name->setInfo($this->
lng->txt(
'mail_system_usr_from_name_info'));
508 $user_from_name->setRequired(
true);
510 $form->addItem($user_from_name);
513 $this->
lng->txt(
'mail_system_usr_env_from_addr'),
514 'mail_system_usr_env_from_addr' 516 $user_envelope_from_addr->
setInfo($this->
lng->txt(
'mail_system_usr_env_from_addr_info'));
518 $form->addItem($user_envelope_from_addr);
520 [$user_signature_inputs, $installation_signature_inputs] =
array_map(
524 foreach ($user_signature_inputs as $user_signature_input) {
525 $form->addItem($user_signature_input);
529 $sh->setTitle($this->
lng->txt(
'mail_settings_system_frm_head'));
533 $this->
lng->txt(
'mail_system_sys_from_addr'),
534 'mail_system_sys_from_addr' 536 $system_from_addr->
setInfo($this->
lng->txt(
'mail_system_sys_from_addr_info'));
537 $system_from_addr->setRequired(
true);
539 $form->addItem($system_from_addr);
542 $this->
lng->txt(
'mail_system_sys_from_name'),
543 'mail_system_sys_from_name' 545 $system_from_name->setRequired(
true);
547 $form->addItem($system_from_name);
550 $this->
lng->txt(
'mail_system_sys_reply_to_addr'),
551 'mail_system_sys_reply_to_addr' 555 $form->addItem($system_reply_to_addr);
558 $this->
lng->txt(
'mail_system_sys_env_from_addr'),
559 'mail_system_sys_env_from_addr' 561 $system_return_path->
setInfo($this->
lng->txt(
'mail_system_sys_env_from_addr_info'));
563 $form->addItem($system_return_path);
565 foreach ($installation_signature_inputs as $installation_signature_input) {
566 $form->addItem($installation_signature_input);
570 $form->addCommandButton(
'saveExternalSettingsForm', $this->
lng->txt(
'save'));
589 $this->
lng->txt(
'mail_form_placeholders_label'),
595 $placeholder = $this->mail_signature_service->getPlaceholder();
597 if ($signature->
supports($placeholder)) {
598 $placeholder_input->addPlaceholder($placeholder->getId(), $placeholder->getLabel());
600 }
while ($placeholder = $placeholder->getNext());
602 return [$signature_input, $placeholder_input];
607 $subjectPrefix = $this->
settings->get(
'mail_subject_prefix');
608 if (
null === $subjectPrefix) {
615 'mail_smtp_status' => (
bool) $this->
settings->get(
'mail_smtp_status',
'0'),
616 'mail_smtp_host' => $this->
settings->get(
'mail_smtp_host',
''),
617 'mail_smtp_port' => $this->
settings->get(
'mail_smtp_port',
''),
618 'mail_smtp_user' => $this->
settings->get(
'mail_smtp_user',
''),
619 'mail_smtp_password' => $this->
settings->get(
'mail_smtp_password') !==
'' ?
620 self::PASSWORD_PLACE_HOLDER :
622 'mail_smtp_encryption' => $this->
settings->get(
'mail_smtp_encryption',
''),
623 'mail_subject_prefix' => $subjectPrefix,
624 'mail_send_html' => (bool) $this->
settings->get(
'mail_send_html',
'0'),
625 'mail_system_usr_from_addr' => $this->
settings->get(
'mail_system_usr_from_addr',
''),
626 'mail_system_usr_from_name' => $this->
settings->get(
'mail_system_usr_from_name',
''),
627 'mail_system_usr_env_from_addr' => $this->
settings->get(
'mail_system_usr_env_from_addr',
''),
628 'mail_system_sys_from_addr' => $this->
settings->get(
'mail_system_sys_from_addr',
''),
629 'mail_system_sys_from_name' => $this->
settings->get(
'mail_system_sys_from_name',
''),
630 $user_signature->getPersistenceIdentifier() => $this->
settings->get($user_signature->getPersistenceIdentifier(),
''),
631 'mail_system_sys_reply_to_addr' => $this->
settings->get(
'mail_system_sys_reply_to_addr',
''),
632 'mail_system_sys_env_from_addr' => $this->
settings->get(
'mail_system_sys_env_from_addr',
''),
633 $installation_signature->getPersistenceIdentifier() => $this->
settings->get($installation_signature->getPersistenceIdentifier(),
''),
634 'use_global_reply_to_addr' => (
bool) $this->
settings->get(
'use_global_reply_to_addr',
'0'),
635 'global_reply_to_addr' => $this->
settings->get(
'global_reply_to_addr',
''),
642 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
646 $isFormValid = $form->checkInput();
649 $form->setValuesByPost();
654 $isSmtpEnabled = (bool) $form->getInput(
'mail_smtp_status');
655 if ($isSmtpEnabled && $form->getInput(
'mail_smtp_user') &&
656 !$form->getInput(
'mail_smtp_password')
658 $form->getItemByPostVar(
'mail_smtp_password')->setRequired(
true);
659 $form->getItemByPostVar(
'mail_smtp_password')
660 ->setAlert($this->
lng->txt(
'mail_smtp_password_req'));
661 $form->setValuesByPost();
667 $is_valid_template_syntax = $this->
refinery->custom()->constraint(
function ($value):
bool {
669 $this->mustache_factory->getBasicEngine()->render((
string) $value, []);
674 }, $this->
lng->txt(
'mail_template_invalid_tpl_syntax'));
676 $valid_templates =
true;
682 [
'mail_system_usr_from_name', ...$availabe_signatures] as $template
685 $is_valid_template_syntax->check((
string) $form->getInput($template));
687 $form->getItemByPostVar($template)->setAlert(
688 $is_valid_template_syntax->problemWith((
string) $form->getInput($template))
690 $valid_templates =
false;
693 if (!$valid_templates) {
694 $form->setValuesByPost();
699 $this->
settings->set(
'mail_smtp_status', (
string) ((
int) $form->getInput(
'mail_smtp_status')));
700 $this->
settings->set(
'mail_smtp_host', (
string) $form->getInput(
'mail_smtp_host'));
701 $this->
settings->set(
'mail_smtp_port', (
string) ((
int) $form->getInput(
'mail_smtp_port')));
702 $this->
settings->set(
'mail_smtp_user', (
string) $form->getInput(
'mail_smtp_user'));
703 if ($form->getInput(
'mail_smtp_password') !== self::PASSWORD_PLACE_HOLDER) {
704 $this->
settings->set(
'mail_smtp_password', (
string) $form->getInput(
'mail_smtp_password'));
706 $this->
settings->set(
'mail_smtp_encryption', (
string) $form->getInput(
'mail_smtp_encryption'));
707 $this->
settings->set(
'mail_send_html', (
string) $form->getInput(
'mail_send_html'));
708 $this->
settings->set(
'mail_subject_prefix', (
string) $form->getInput(
'mail_subject_prefix'));
709 $this->
settings->set(
'mail_system_usr_from_addr', (
string) $form->getInput(
'mail_system_usr_from_addr'));
710 $this->
settings->set(
'mail_system_usr_from_name', (
string) $form->getInput(
'mail_system_usr_from_name'));
712 'mail_system_usr_env_from_addr',
713 (
string) $form->getInput(
'mail_system_usr_env_from_addr')
716 'mail_system_sys_from_addr',
717 (
string) $form->getInput(
'mail_system_sys_from_addr')
719 $this->
settings->set(
'mail_system_sys_from_name', (
string) $form->getInput(
'mail_system_sys_from_name'));
721 'mail_system_sys_reply_to_addr',
722 (
string) $form->getInput(
'mail_system_sys_reply_to_addr')
725 'mail_system_sys_env_from_addr',
726 (
string) $form->getInput(
'mail_system_sys_env_from_addr')
728 $this->
settings->set(
'use_global_reply_to_addr', (
string) ((
int) $form->getInput(
'use_global_reply_to_addr')));
729 $this->
settings->set(
'global_reply_to_addr', (
string) $form->getInput(
'global_reply_to_addr'));
731 foreach ($availabe_signatures as $availabe_signature) {
734 (
string) $form->getInput($availabe_signature)
738 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
739 $this->
ctrl->redirect($this,
'showExternalSettingsForm');
742 public static function _goto(
string $target): void
745 $main_tpl = $DIC->ui()->mainTemplate();
747 $mail =
new ilMail($DIC->user()->getId());
749 if ($DIC->rbac()->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
750 $DIC->ctrl()->redirectToURL(
'ilias.php?baseClass=ilMailGUI');
751 } elseif ($DIC->access()->checkAccess(
'read',
'',
ROOT_FOLDER_ID)) {
752 $main_tpl->setOnScreenMessage(
'failure', sprintf(
753 $DIC->language()->txt(
'msg_no_perm_read_item'),
757 $DIC->ctrl()->setTargetScript(
'ilias.php');
758 $DIC->ctrl()->setParameterByClass(ilRepositoryGUI::class,
'ref_id',
ROOT_FOLDER_ID);
759 $DIC->ctrl()->redirectByClass(ilRepositoryGUI::class);
762 $DIC[
'ilErr']->raiseError($DIC->language()->txt(
'msg_no_perm_read'), $DIC[
'ilErr']->FATAL);
showGeneralSettingsForm(?ilPropertyFormGUI $form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
sendTestMail(bool $isManualMail=false)
populateGeneralSettingsForm(ilPropertyFormGUI $form)
prepareOutput(bool $show_sub_objects=true)
readonly ilMustacheFactory $mustache_factory
isPermissionChangeAllowed()
supports(Placeholder $placeholder)
const PASSWORD_PLACE_HOLDER
static _goto(string $target)
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const SETTINGS_SUB_TAB_ID_EXTERNAL
buildSignaturePlaceholderInputs(Signature $signature)
sendTestSystemMailObject()
saveExternalSettingsFormObject()
final const INCOMING_EMAIL
__construct($a_data, int $a_id, bool $a_call_by_reference)
static _lookupTitle(int $obj_id)
Class ilObjectGUI Basic methods of all Output classes.
showExternalSettingsFormObject(?ilPropertyFormGUI $form=null)
Class ilObjForumAdministration.
readonly MailSignatureService $mail_signature_service
const SETTINGS_SUB_TAB_ID_GENERAL
__construct(Container $dic, ilPlugin $plugin)
getPersistenceIdentifier()
This class represents a text area property in a property form.
final const INCOMING_BOTH
final const MAIL_SUBJECT_PREFIX
buildSettingsSubTabs(string $activeSubTab)
getExternalSettingsForm()
populateExternalSettingsForm(ilPropertyFormGUI $form)