ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMailTransportSettings.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
11  private $mailOptions;
12 
18  {
19  $this->mailOptions = $mailOptions;
20  }
21 
27  public function adjust(string $firstMail, string $secondMail) : void
28  {
29  if ($this->mailOptions->getIncomingType() === ilMailOptions::INCOMING_LOCAL) {
30  return;
31  }
32 
33  $hasFirstEmail = strlen($firstMail) > 0;
34  $hasSecondEmail = strlen($secondMail) > 0;
35 
36  if (!$hasFirstEmail && !$hasSecondEmail) {
37  $this->mailOptions->setIncomingType(ilMailOptions::INCOMING_LOCAL);
38  $this->mailOptions->updateOptions();
39  return;
40  }
41 
42  if (!$hasFirstEmail && $this->mailOptions->getEmailAddressMode() !== ilMailOptions::SECOND_EMAIL) {
43  $this->mailOptions->setEmailAddressMode(ilMailOptions::SECOND_EMAIL);
44  $this->mailOptions->updateOptions();
45  return;
46  }
47 
48  if (!$hasSecondEmail && $this->mailOptions->getEmailAddressMode() !== ilMailOptions::FIRST_EMAIL) {
49  $this->mailOptions->setEmailAddressMode(ilMailOptions::FIRST_EMAIL);
50  $this->mailOptions->updateOptions();
51  return;
52  }
53  }
54 }
Class ilMailOptions this class handles user mails.
adjust(string $firstMail, string $secondMail)
Validates the current instance settings and eventually adjusts these.
__construct(ilMailOptions $mailOptions)
ilMailTransportSettings constructor.