ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMailLoginOrEmailAddressAddressType Class Reference

Class ilMailLoginOrEmailAddressAddressType. More...

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

Public Member Functions

 __construct (ilMailAddressTypeHelper $typeHelper, ilMailAddress $address, ilLogger $logger, ilRbacSystem $rbacsystem)
 ilMailMailingListAddressType constructor. More...
 
 resolve ()
 Returns an array of resolved user ids based on an address instance.
Returns
int[]
More...
 
- Public Member Functions inherited from ilBaseMailAddressType
 __construct (ilMailAddressTypeHelper $typeHelper, ilMailAddress $address, ilLogger $logger)
 ilBaseMailAddressType constructor. More...
 
 validate (int $senderId)
 Validates the parsed recipients and set errors accordingly.
Parameters
$senderIdinteger The id of the acting ILIAS user, can be used for permission checks etc.
Returns
bool
See also
ilMailAddressType::getErrors
More...
 
 getErrors ()
 Returns a list of errors determined in the validation process.The errors should be reset everytime the validation is triggered.

Returns
ilMailError[]
See also
ilMailAddressType::validate
More...
 
 getAddress ()
 The address instance used for validation and user id lookup.
Returns
ilMailAddress
More...
 
 resolve ()
 Returns an array of resolved user ids based on an address instance. More...
 
 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)
 
Parameters
$senderIdinteger
Returns
bool
More...
 
- Protected Member Functions inherited from ilBaseMailAddressType
 isValid (int $senderId)
 
 pushError (string $languageVariable, array $placeHolderValues=[])
 

Protected Attributes

 $rbacsystem
 
- Protected Attributes inherited from ilBaseMailAddressType
 $typeHelper
 
 $address
 
 $logger
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ isValid()

ilMailLoginOrEmailAddressAddressType::isValid ( int  $senderId)
protected

Parameters
$senderIdinteger
Returns
bool

Reimplemented from ilBaseMailAddressType.

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

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

References ilBaseMailAddressType\pushError().

+ 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 68 of file class.ilMailLoginOrEmailAddressAddressType.php.

68 : array
69 {
70 if ($this->address->getHost() == $this->typeHelper->getInstallationHost()) {
71 $address = $this->address->getMailbox();
72 } else {
73 $address = (string) $this->address;
74 }
75
76 $usrIds = array_filter([
77 $this->typeHelper->getUserIdByLogin($address)
78 ]);
79
80 if (count($usrIds) > 0) {
81 $this->logger->debug(sprintf(
82 "Found the following user ids for address (login) '%s': %s",
84 implode(', ', array_unique($usrIds))
85 ));
86 } elseif (strlen($address) > 0) {
87 $this->logger->debug(sprintf(
88 "Did not find any user account for address (login) '%s'",
90 ));
91 }
92
93 return $usrIds;
94 }

References ilBaseMailAddressType\$address.

Field Documentation

◆ $rbacsystem

ilMailLoginOrEmailAddressAddressType::$rbacsystem
protected

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

Referenced by __construct().


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