ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilMailTransportSettings.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  public function __construct(private readonly ilMailOptions $mailOptions)
27  {
28  }
29 
30  public function adjust(string $firstMail, string $secondMail, bool $persist = true): void
31  {
32  if ($this->mailOptions->getIncomingType() === ilMailOptions::INCOMING_LOCAL) {
33  return;
34  }
35 
36  $hasFirstEmail = $firstMail !== '';
37  $hasSecondEmail = $secondMail !== '';
38 
39  if (!$hasFirstEmail && !$hasSecondEmail) {
40  $this->mailOptions->setIncomingType(ilMailOptions::INCOMING_LOCAL);
41  if ($persist) {
42  $this->mailOptions->updateOptions();
43  }
44  return;
45  }
46 
47  if (!$hasFirstEmail && $this->mailOptions->getEmailAddressMode() !== ilMailOptions::SECOND_EMAIL) {
48  $this->mailOptions->setEmailAddressMode(ilMailOptions::SECOND_EMAIL);
49  if ($persist) {
50  $this->mailOptions->updateOptions();
51  }
52  return;
53  }
54 
55  if (!$hasSecondEmail && $this->mailOptions->getEmailAddressMode() !== ilMailOptions::FIRST_EMAIL) {
56  $this->mailOptions->setEmailAddressMode(ilMailOptions::FIRST_EMAIL);
57  if ($persist) {
58  $this->mailOptions->updateOptions();
59  }
60  }
61  }
62 }
__construct(private readonly ilMailOptions $mailOptions)
final const SECOND_EMAIL
final const INCOMING_LOCAL
final const FIRST_EMAIL
adjust(string $firstMail, string $secondMail, bool $persist=true)