ILIAS  release_7 Revision v7.30-3-g800a261c036
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, bool $persist = true) : 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  if ($persist) {
39  $this->mailOptions->updateOptions();
40  }
41  return;
42  }
43 
44  if (!$hasFirstEmail && $this->mailOptions->getEmailAddressMode() !== ilMailOptions::SECOND_EMAIL) {
45  $this->mailOptions->setEmailAddressMode(ilMailOptions::SECOND_EMAIL);
46  if ($persist) {
47  $this->mailOptions->updateOptions();
48  }
49  return;
50  }
51 
52  if (!$hasSecondEmail && $this->mailOptions->getEmailAddressMode() !== ilMailOptions::FIRST_EMAIL) {
53  $this->mailOptions->setEmailAddressMode(ilMailOptions::FIRST_EMAIL);
54  if ($persist) {
55  $this->mailOptions->updateOptions();
56  }
57  return;
58  }
59  }
60 }
Class ilMailOptions this class handles user mails.
__construct(ilMailOptions $mailOptions)
ilMailTransportSettings constructor.
adjust(string $firstMail, string $secondMail, bool $persist=true)
Validates the current instance settings and eventually adjusts these.