ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMailLoginOrEmailAddressAddressType Class Reference

Class ilMailLoginOrEmailAddressAddressType. More...

+ Inheritance diagram for ilMailLoginOrEmailAddressAddressType:
+ Collaboration diagram for ilMailLoginOrEmailAddressAddressType:

Public Member Functions

 __construct (ilMailAddressTypeHelper $typeHelper, ilMailAddress $address, ilLogger $logger, protected ilRbacSystem $rbacsystem)
 
 resolve ()
 Returns an array of resolved user ids based on an address instance. More...
 
- Public Member Functions inherited from ilBaseMailAddressType
 __construct (protected ilMailAddressTypeHelper $typeHelper, protected ilMailAddress $address, protected ilLogger $logger)
 
 validate (int $senderId)
 Validates the parsed recipients and set errors accordingly. More...
 
 getErrors ()
 Returns a list of errors determined in the validation process. More...
 
 getAddress ()
 The address instance used for validation and user id lookup. More...
 

Protected Member Functions

 isValid (int $senderId)
 
- Protected Member Functions inherited from ilBaseMailAddressType
 isValid (int $senderId)
 
 pushError (string $languageVariable, array $placeHolderValues=[])
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailLoginOrEmailAddressAddressType::__construct ( ilMailAddressTypeHelper  $typeHelper,
ilMailAddress  $address,
ilLogger  $logger,
protected ilRbacSystem  $rbacsystem 
)

Definition at line 27 of file class.ilMailLoginOrEmailAddressAddressType.php.

References ILIAS\MetaData\Repository\Validation\Data\__construct().

32  {
33  parent::__construct($typeHelper, $address, $logger);
34  }
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ isValid()

ilMailLoginOrEmailAddressAddressType::isValid ( int  $senderId)
protected

Definition at line 36 of file class.ilMailLoginOrEmailAddressAddressType.php.

References ILIAS\Repository\logger(), and ilBaseMailAddressType\pushError().

36  : bool
37  {
38  if ($this->address->getHost() === $this->typeHelper->getInstallationHost()) {
39  $usrId = $this->typeHelper->getUserIdByLogin($this->address->getMailbox());
40  } else {
41  $usrId = false;
42  }
43 
44  if (!$usrId && $this->address->getHost() === $this->typeHelper->getInstallationHost()) {
45  $this->pushError('mail_recipient_not_found', [$this->address->getMailbox()]);
46  return false;
47  }
48 
49  if (
50  $usrId &&
51  $this->typeHelper->receivesInternalMailsOnly($usrId) &&
52  !$this->rbacsystem->checkAccessOfUser(
53  $usrId,
54  'internal_mail',
55  $this->typeHelper->getGlobalMailSystemId()
56  )
57  ) {
58  $this->logger->debug(sprintf(
59  "Address '%s' not valid. Found id %s, " .
60  "but user can't use mail system and wants to receive emails only internally.",
61  $this->address->getMailbox(),
62  $usrId
63  ));
64  $this->pushError('user_cant_receive_mail', [$this->address->getMailbox()]);
65  return false;
66  }
67 
68  return true;
69  }
pushError(string $languageVariable, array $placeHolderValues=[])
+ Here is the call graph for this function:

◆ resolve()

ilMailLoginOrEmailAddressAddressType::resolve ( )

Returns an array of resolved user ids based on an address instance.

Returns
int[]

Implements ilMailAddressType.

Definition at line 71 of file class.ilMailLoginOrEmailAddressAddressType.php.

References ILIAS\Repository\logger().

71  : array
72  {
73  if ($this->address->getHost() === $this->typeHelper->getInstallationHost()) {
74  $address = $this->address->getMailbox();
75  } else {
76  $address = (string) $this->address;
77  }
78 
79  $usrIds = array_filter([
80  $this->typeHelper->getUserIdByLogin($address),
81  ]);
82 
83  if ($usrIds !== []) {
84  $this->logger->debug(sprintf(
85  "Found the following user ids for address (login) '%s': %s",
86  $address,
87  implode(', ', array_unique($usrIds))
88  ));
89  } elseif ($address !== '') {
90  $this->logger->debug(sprintf(
91  "Did not find any user account for address (login) '%s'",
92  $address
93  ));
94  }
95 
96  return $usrIds;
97  }
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: