ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilMailTransportSettings.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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 }
adjust(string $first_mail, string $second_mail, bool $persist=true)
final const int SECOND_EMAIL
final const int INCOMING_LOCAL
__construct(private readonly ilMailOptions $mail_options)
final const int FIRST_EMAIL