ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMailTransportSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public function __construct(private readonly ilMailOptions $mail_options)
24 {
25 }
26
27 public function adjust(string $first_mail, string $second_mail, bool $persist = true): void
28 {
29 if ($this->mail_options->getIncomingType() === ilMailOptions::INCOMING_LOCAL) {
30 return;
31 }
32
33 $has_first_email = $first_mail !== '';
34 $has_second_email = $second_mail !== '';
35
36 if (!$has_first_email && !$has_second_email) {
37 $this->mail_options->setIncomingType(ilMailOptions::INCOMING_LOCAL);
38 if ($persist) {
39 $this->mail_options->updateOptions();
40 }
41 return;
42 }
43
44 if (!$has_first_email && $this->mail_options->getEmailAddressMode() !== ilMailOptions::SECOND_EMAIL) {
45 $this->mail_options->setEmailAddressmode(ilMailOptions::SECOND_EMAIL);
46 if ($persist) {
47 $this->mail_options->updateOptions();
48 }
49 return;
50 }
51
52 if (!$has_second_email && $this->mail_options->getEmailAddressMode() !== ilMailOptions::FIRST_EMAIL) {
53 $this->mail_options->setEmailAddressmode(ilMailOptions::FIRST_EMAIL);
54 if ($persist) {
55 $this->mail_options->updateOptions();
56 }
57 }
58 }
59}
final const int FIRST_EMAIL
final const int INCOMING_LOCAL
final const int SECOND_EMAIL
__construct(private readonly ilMailOptions $mail_options)
adjust(string $first_mail, string $second_mail, bool $persist=true)