19 declare(strict_types=1);
33 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference)
39 $this->
tabs = $DIC->tabs();
41 $this->
lng->loadLanguageModule(
'mail');
46 $next_class = $this->
ctrl->getNextClass($this);
47 $cmd = $this->
ctrl->getCmd();
50 switch (strtolower($next_class)) {
51 case strtolower(ilPermissionGUI::class):
53 $this->
ctrl->forwardCommand($perm_gui);
56 case strtolower(ilMailTemplateGUI::class):
58 $this->
ilias->raiseError(
59 $this->
lng->txt(
'msg_no_perm_write'),
60 $this->
ilias->error_obj->WARNING
79 return $this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
84 return $this->rbac_system->checkAccess(
'read', $this->
object->getRefId());
89 return $this->rbac_system->checkAccess(
'edit_permission', $this->
object->getRefId());
100 $this->
tabs->addTarget(
102 $this->
ctrl->getLinkTarget($this,
'view'),
107 'showExternalSettingsForm',
108 'saveExternalSettingsForm',
110 'sendTestSystemMail',
116 $this->
tabs->addTarget(
118 $this->
ctrl->getLinkTargetByClass(ilMailTemplateGUI::class,
'showTemplates'),
120 ilMailTemplateGUI::class
125 $this->
tabs->addTarget(
127 $this->
ctrl->getLinkTargetByClass([get_class($this), ilPermissionGUI::class],
'perm'),
128 [
'perm',
'info',
'owner'],
129 ilPermissionGUI::class
137 $this->
tabs->addSubTab(
138 self::SETTINGS_SUB_TAB_ID_GENERAL,
139 $this->
lng->txt(
'mail_settings_general_tab'),
140 $this->
ctrl->getLinkTarget($this,
'view')
143 if ($this->
settings->get(
'mail_allow_external',
'0')) {
144 $this->
tabs->addSubTab(
145 self::SETTINGS_SUB_TAB_ID_EXTERNAL,
146 $this->
lng->txt(
'mail_settings_external_tab'),
147 $this->
ctrl->getLinkTarget($this,
'showExternalSettingsForm')
151 $this->
tabs->activateSubTab($activeSubTab);
163 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
168 if ($form === null) {
173 $this->tpl->setContent($form->getHTML());
180 $form->setFormAction($this->
ctrl->getFormAction($this,
'save'));
181 $form->setTitle($this->
lng->txt(
'general_settings'));
184 $cb->
setInfo($this->
lng->txt(
'mail_allow_external_info'));
190 $this->
lng->txt(
'mail_incoming'),
194 $this->
ctrl->setParameterByClass(ilObjUserFolderGUI::class,
'ref_id',
USER_FOLDER_ID);
195 $incoming_mail_gui->setInfo(sprintf(
196 $this->
lng->txt(
'mail_settings_incoming_type_see_also'),
197 $this->
ctrl->getLinkTargetByClass(ilObjUserFolderGUI::class,
'settings')
199 $this->
ctrl->clearParametersByClass(ilObjUserFolderGUI::class);
200 $form->addItem($incoming_mail_gui);
203 $this->
lng->txt(
'show_mail_settings'),
206 $show_mail_settings_gui->
setInfo($this->
lng->txt(
'show_mail_settings_info'));
207 $show_mail_settings_gui->setValue(
'1');
208 $form->addItem($show_mail_settings_gui);
212 $ti->setInfo($this->
lng->txt(
'mail_max_size_attachments_total'));
213 $ti->setMaxLength(10);
219 $mn->setTitle($this->
lng->txt(
'mail_member_notification'));
223 $this->
lng->txt(
'cron_mail_notification'),
227 0 => $this->
lng->txt(
'cron_mail_notification_never'),
228 1 => $this->
lng->txt(
'cron_mail_notification_cron'),
230 $cron_mail->setOptions($cron_options);
231 $cron_mail->setInfo(sprintf(
232 $this->
lng->txt(
'cron_mail_notification_desc'),
233 $this->
lng->txt(
'mail_allow_external')
236 $form->addItem($cron_mail);
245 $form->addCommandButton(
'save', $this->
lng->txt(
'save'));
254 'mail_allow_external' => (
bool) $this->
settings->get(
'mail_allow_external',
'0'),
255 'incoming_type' => (string) $this->
settings->get(
'mail_incoming_mail',
'0'),
256 'mail_address_option' => $this->
settings->get(
'mail_address_option',
'') !==
'' ?
257 $this->
settings->get(
'mail_address_option') :
259 'mail_address_option_both' => $this->
settings->get(
'mail_address_option',
'') !==
'' ?
260 $this->
settings->get(
'mail_address_option') :
262 'show_mail_settings' => (
bool) $this->
settings->get(
'show_mail_settings',
'1'),
263 'mail_maxsize_attach' => $this->
settings->get(
'mail_maxsize_attach',
''),
264 'mail_notification' => $this->
settings->get(
'mail_notification',
''),
271 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
275 if ($form->checkInput()) {
276 $incoming_type = (
int) $form->getInput(
'incoming_type');
280 $mail_address_option = (
int) $form->getInput(
'mail_address_option');
282 $mail_address_option = (
int) $form->getInput(
'mail_address_option_both');
285 $this->
settings->set(
'mail_allow_external', (
string) ((
int) $form->getInput(
'mail_allow_external')));
286 $this->
settings->set(
'mail_incoming_mail', (
string) $incoming_type);
287 $this->
settings->set(
'show_mail_settings', (
string) ((
int) $form->getInput(
'show_mail_settings')));
288 $this->
settings->set(
'mail_address_option', (
string) $mail_address_option);
289 $this->
settings->set(
'mail_maxsize_attach', (
string) $form->getInput(
'mail_maxsize_attach'));
290 $this->
settings->set(
'mail_notification', (
string) ((
int) $form->getInput(
'mail_notification')));
292 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
293 $this->
ctrl->redirect($this);
296 $form->setValuesByPost();
303 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
308 if ($form === null) {
313 if ($this->
user->getEmail() !==
'') {
315 $btn->setUrl($this->
ctrl->getLinkTarget($this,
'sendTestUserMail'));
316 $btn->setCaption(
'mail_external_send_test_usr');
317 $this->
toolbar->addButtonInstance($btn);
320 $btn->setUrl($this->
ctrl->getLinkTarget($this,
'sendTestSystemMail'));
321 $btn->setCaption(
'mail_external_send_test_sys');
322 $this->
toolbar->addButtonInstance($btn);
325 $this->tpl->setContent($form->getHTML());
341 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
344 if ($this->
user->getEmail() ===
'') {
355 $mail->setSaveInSentbox(
false);
356 $mail->appendInstallationSignature(
true);
358 $lngVariablePrefix =
'sys';
360 $lngVariablePrefix =
'usr';
364 $this->
user->getEmail(),
367 $this->
lng->txt(
'mail_email_' . $lngVariablePrefix .
'_subject'),
368 $this->
lng->txt(
'mail_email_' . $lngVariablePrefix .
'_body'),
372 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_external_test_sent'));
380 $form->setFormAction($this->
ctrl->getFormAction($this,
'saveExternalSettingsForm'));
381 $form->setTitle($this->
lng->txt(
'mail_settings_external_frm_head'));
384 $smtp->
setInfo($this->
lng->txt(
'mail_smtp_status_info'));
385 $smtp->setValue(
'1');
387 $form->addItem($smtp);
390 $host->setInfo($this->
lng->txt(
'mail_smtp_host_info'));
391 $host->setRequired(
true);
393 $smtp->addSubItem($host);
396 $port->
setInfo($this->
lng->txt(
'mail_smtp_port_info'));
397 $port->allowDecimals(
false);
398 $port->setMinValue(0);
399 $port->setMinValue(0);
400 $port->setRequired(
true);
402 $smtp->addSubItem($port);
405 $this->
lng->txt(
'mail_smtp_encryption'),
406 'mail_smtp_encryption' 408 $encryptionOptions = [
409 '' => $this->
lng->txt(
'please_choose'),
410 'tls' => $this->
lng->txt(
'mail_smtp_encryption_tls'),
411 'ssl' => $this->
lng->txt(
'mail_smtp_encryption_ssl'),
414 $encryption->setOptions($encryptionOptions);
416 $smtp->addSubItem($encryption);
420 $user->setDisableHtmlAutoComplete(
true);
421 $smtp->addSubItem(
$user);
424 $this->
lng->txt(
'mail_smtp_password'),
428 $password->setSkipSyntaxCheck(
true);
430 $password->setDisableHtmlAutoComplete(
true);
431 $smtp->addSubItem($password);
433 $pre =
new ilTextInputGUI($this->
lng->txt(
'mail_subject_prefix'),
'mail_subject_prefix');
435 $pre->setMaxLength(32);
436 $pre->setInfo($this->
lng->txt(
'mail_subject_prefix_info'));
438 $form->addItem($pre);
441 $send_html->
setInfo($this->
lng->txt(
'mail_send_html_info'));
442 $send_html->setValue(
'1');
444 $form->addItem($send_html);
447 $sh->setTitle($this->
lng->txt(
'mail_settings_user_frm_head'));
451 $this->
lng->txt(
'mail_system_usr_from_addr'),
452 'mail_system_usr_from_addr' 454 $user_from_address->
setInfo($this->
lng->txt(
'mail_system_usr_from_addr_info'));
455 $user_from_address->setRequired(
true);
457 $form->addItem($user_from_address);
460 $this->
lng->txt(
'mail_use_global_reply_to_addr'),
461 'use_global_reply_to_addr' 463 $useGlobalReplyToAddress->
setInfo($this->
lng->txt(
'mail_use_global_reply_to_addr_info'));
464 $useGlobalReplyToAddress->setValue(
'1');
466 $form->addItem($useGlobalReplyToAddress);
468 $this->
lng->txt(
'mail_global_reply_to_addr'),
469 'global_reply_to_addr' 471 $globalReplyTo->
setInfo($this->
lng->txt(
'mail_global_reply_to_addr_info'));
472 $globalReplyTo->setRequired(
true);
474 $useGlobalReplyToAddress->addSubItem($globalReplyTo);
477 $this->
lng->txt(
'mail_system_usr_from_name'),
478 'mail_system_usr_from_name' 480 $user_from_name->setInfo($this->
lng->txt(
'mail_system_usr_from_name_info'));
481 $user_from_name->setRequired(
true);
483 $form->addItem($user_from_name);
486 $this->
lng->txt(
'mail_system_usr_env_from_addr'),
487 'mail_system_usr_env_from_addr' 489 $user_envelope_from_addr->
setInfo($this->
lng->txt(
'mail_system_usr_env_from_addr_info'));
491 $form->addItem($user_envelope_from_addr);
494 $sh->setTitle($this->
lng->txt(
'mail_settings_system_frm_head'));
498 $this->
lng->txt(
'mail_system_sys_from_addr'),
499 'mail_system_sys_from_addr' 501 $system_from_addr->
setInfo($this->
lng->txt(
'mail_system_sys_from_addr_info'));
502 $system_from_addr->setRequired(
true);
504 $form->addItem($system_from_addr);
507 $this->
lng->txt(
'mail_system_sys_from_name'),
508 'mail_system_sys_from_name' 510 $system_from_name->setRequired(
true);
512 $form->addItem($system_from_name);
515 $this->
lng->txt(
'mail_system_sys_reply_to_addr'),
516 'mail_system_sys_reply_to_addr' 520 $form->addItem($system_reply_to_addr);
523 $this->
lng->txt(
'mail_system_sys_env_from_addr'),
524 'mail_system_sys_env_from_addr' 526 $system_return_path->
setInfo($this->
lng->txt(
'mail_system_sys_env_from_addr_info'));
528 $form->addItem($system_return_path);
531 $this->
lng->txt(
'mail_system_sys_signature'),
532 'mail_system_sys_signature' 536 $form->addItem($signature);
539 $this->
lng->txt(
'mail_form_placeholders_label'),
540 'mail_system_sys_signature' 542 $placeholder_list = [
543 [
'placeholder' =>
'INSTALLATION_NAME',
'label' => $this->
lng->txt(
'mail_nacc_installation_name')],
544 [
'placeholder' =>
'INSTALLATION_DESC',
'label' => $this->
lng->txt(
'mail_nacc_installation_desc')],
545 [
'placeholder' =>
'ILIAS_URL',
'label' => $this->
lng->txt(
'mail_nacc_ilias_url')],
547 foreach ($placeholder_list as $value) {
548 $placeholders->
addPlaceholder($value[
'placeholder'], $value[
'label']);
551 $form->addItem($placeholders);
554 $form->addCommandButton(
'saveExternalSettingsForm', $this->
lng->txt(
'save'));
562 $subjectPrefix = $this->
settings->get(
'mail_subject_prefix');
563 if (null === $subjectPrefix) {
568 'mail_smtp_status' => (
bool) $this->
settings->get(
'mail_smtp_status',
'0'),
569 'mail_smtp_host' => $this->
settings->get(
'mail_smtp_host',
''),
570 'mail_smtp_port' => $this->
settings->get(
'mail_smtp_port',
''),
571 'mail_smtp_user' => $this->
settings->get(
'mail_smtp_user',
''),
572 'mail_smtp_password' => $this->
settings->get(
'mail_smtp_password') !==
'' ?
573 self::PASSWORD_PLACE_HOLDER :
575 'mail_smtp_encryption' => $this->
settings->get(
'mail_smtp_encryption',
''),
576 'mail_subject_prefix' => $subjectPrefix,
577 'mail_send_html' => (bool) $this->
settings->get(
'mail_send_html',
'0'),
578 'mail_system_usr_from_addr' => $this->
settings->get(
'mail_system_usr_from_addr',
''),
579 'mail_system_usr_from_name' => $this->
settings->get(
'mail_system_usr_from_name',
''),
580 'mail_system_usr_env_from_addr' => $this->
settings->get(
'mail_system_usr_env_from_addr',
''),
581 'mail_system_sys_from_addr' => $this->
settings->get(
'mail_system_sys_from_addr',
''),
582 'mail_system_sys_from_name' => $this->
settings->get(
'mail_system_sys_from_name',
''),
583 'mail_system_sys_reply_to_addr' => $this->
settings->get(
'mail_system_sys_reply_to_addr',
''),
584 'mail_system_sys_env_from_addr' => $this->
settings->get(
'mail_system_sys_env_from_addr',
''),
585 'mail_system_sys_signature' => $this->
settings->get(
'mail_system_sys_signature',
''),
586 'use_global_reply_to_addr' => (bool) $this->
settings->get(
'use_global_reply_to_addr',
'0'),
587 'global_reply_to_addr' => $this->
settings->get(
'global_reply_to_addr',
''),
594 $this->
ilias->raiseError($this->
lng->txt(
'msg_no_perm_write'), $this->
ilias->error_obj->WARNING);
598 $isFormValid = $form->checkInput();
601 $form->setValuesByPost();
606 $isSmtpEnabled = (bool) $form->getInput(
'mail_smtp_status');
607 if ($isSmtpEnabled && $form->getInput(
'mail_smtp_user') &&
608 !$form->getInput(
'mail_smtp_password')
610 $form->getItemByPostVar(
'mail_smtp_password')->setRequired(
true);
611 $form->getItemByPostVar(
'mail_smtp_password')
612 ->setAlert($this->
lng->txt(
'mail_smtp_password_req'));
613 $form->setValuesByPost();
618 $this->
settings->set(
'mail_smtp_status', (
string) ((
int) $form->getInput(
'mail_smtp_status')));
619 $this->
settings->set(
'mail_smtp_host', (
string) $form->getInput(
'mail_smtp_host'));
620 $this->
settings->set(
'mail_smtp_port', (
string) ((
int) $form->getInput(
'mail_smtp_port')));
621 $this->
settings->set(
'mail_smtp_user', (
string) $form->getInput(
'mail_smtp_user'));
622 if ($form->getInput(
'mail_smtp_password') !== self::PASSWORD_PLACE_HOLDER) {
623 $this->
settings->set(
'mail_smtp_password', (
string) $form->getInput(
'mail_smtp_password'));
625 $this->
settings->set(
'mail_smtp_encryption', (
string) $form->getInput(
'mail_smtp_encryption'));
626 $this->
settings->set(
'mail_send_html', (
string) $form->getInput(
'mail_send_html'));
627 $this->
settings->set(
'mail_subject_prefix', (
string) $form->getInput(
'mail_subject_prefix'));
628 $this->
settings->set(
'mail_system_usr_from_addr', (
string) $form->getInput(
'mail_system_usr_from_addr'));
629 $this->
settings->set(
'mail_system_usr_from_name', (
string) $form->getInput(
'mail_system_usr_from_name'));
631 'mail_system_usr_env_from_addr',
632 (
string) $form->getInput(
'mail_system_usr_env_from_addr')
635 'mail_system_sys_from_addr',
636 (
string) $form->getInput(
'mail_system_sys_from_addr')
638 $this->
settings->set(
'mail_system_sys_from_name', (
string) $form->getInput(
'mail_system_sys_from_name'));
640 'mail_system_sys_reply_to_addr',
641 (
string) $form->getInput(
'mail_system_sys_reply_to_addr')
644 'mail_system_sys_env_from_addr',
645 (
string) $form->getInput(
'mail_system_sys_env_from_addr')
647 $this->
settings->set(
'use_global_reply_to_addr', (
string) ((
int) $form->getInput(
'use_global_reply_to_addr')));
648 $this->
settings->set(
'global_reply_to_addr', (
string) $form->getInput(
'global_reply_to_addr'));
649 $this->
settings->set(
'mail_system_sys_signature', (
string) $form->getInput(
'mail_system_sys_signature'));
651 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
652 $this->
ctrl->redirect($this,
'showExternalSettingsForm');
655 public static function _goto(
string $target): void
658 $main_tpl = $DIC->ui()->mainTemplate();
660 $mail =
new ilMail($DIC->user()->getId());
663 if ($DIC->rbac()->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
664 $DIC->ctrl()->redirectToURL(
'ilias.php?baseClass=ilMailGUI');
665 } elseif ($DIC->access()->checkAccess(
'read',
'',
ROOT_FOLDER_ID)) {
666 $main_tpl->setOnScreenMessage(
'failure', sprintf(
667 $DIC->language()->txt(
'msg_no_perm_read_item'),
671 $DIC->ctrl()->setTargetScript(
'ilias.php');
672 $DIC->ctrl()->setParameterByClass(ilRepositoryGUI::class,
'ref_id',
ROOT_FOLDER_ID);
673 $DIC->ctrl()->redirectByClass(ilRepositoryGUI::class);
676 $DIC[
'ilErr']->raiseError($DIC->language()->txt(
'msg_no_perm_read'), $DIC[
'ilErr']->FATAL);
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)
isPermissionChangeAllowed()
const PASSWORD_PLACE_HOLDER
static _goto(string $target)
static _lookupObjId(int $ref_id)
const SETTINGS_SUB_TAB_ID_EXTERNAL
sendTestSystemMailObject()
saveExternalSettingsFormObject()
__construct($a_data, int $a_id, bool $a_call_by_reference)
showExternalSettingsFormObject(ilPropertyFormGUI $form=null)
static _lookupTitle(int $obj_id)
ServerRequestInterface $request
Class ilObjectGUI Basic methods of all Output classes.
header include for all ilias files.
showGeneralSettingsForm(ilPropertyFormGUI $form=null)
const SETTINGS_SUB_TAB_ID_GENERAL
const MAIL_SUBJECT_PREFIX
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
buildSettingsSubTabs(string $activeSubTab)
getExternalSettingsForm()
populateExternalSettingsForm(ilPropertyFormGUI $form)