ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMailTransportSettings.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
27 
28  public function __construct(ilMailOptions $mailOptions)
29  {
30  $this->mailOptions = $mailOptions;
31  }
32 
33  public function adjust(string $firstMail, string $secondMail, bool $persist = true): void
34  {
35  if ($this->mailOptions->getIncomingType() === ilMailOptions::INCOMING_LOCAL) {
36  return;
37  }
38 
39  $hasFirstEmail = $firstMail !== '';
40  $hasSecondEmail = $secondMail !== '';
41 
42  if (!$hasFirstEmail && !$hasSecondEmail) {
43  $this->mailOptions->setIncomingType(ilMailOptions::INCOMING_LOCAL);
44  if ($persist) {
45  $this->mailOptions->updateOptions();
46  }
47  return;
48  }
49 
50  if (!$hasFirstEmail && $this->mailOptions->getEmailAddressMode() !== ilMailOptions::SECOND_EMAIL) {
51  $this->mailOptions->setEmailAddressMode(ilMailOptions::SECOND_EMAIL);
52  if ($persist) {
53  $this->mailOptions->updateOptions();
54  }
55  return;
56  }
57 
58  if (!$hasSecondEmail && $this->mailOptions->getEmailAddressMode() !== ilMailOptions::FIRST_EMAIL) {
59  $this->mailOptions->setEmailAddressMode(ilMailOptions::FIRST_EMAIL);
60  if ($persist) {
61  $this->mailOptions->updateOptions();
62  }
63  return;
64  }
65  }
66 }
Class ilMailOptions this class handles user mails.
__construct(ilMailOptions $mailOptions)
adjust(string $firstMail, string $secondMail, bool $persist=true)