ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
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)
 
 resolve ()
 Returns an array of resolved user ids based on an address instance. More...
 
- Public Member Functions inherited from ilBaseMailAddressType
 __construct (ilMailAddressTypeHelper $typeHelper, ilMailAddress $address, 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...
 
 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)
 
- Protected Member Functions inherited from ilBaseMailAddressType
 isValid (int $senderId)
 
 pushError (string $languageVariable, array $placeHolderValues=[])
 

Protected Attributes

ilRbacSystem $rbacsystem
 
- Protected Attributes inherited from ilBaseMailAddressType
ilMailAddressTypeHelper $typeHelper
 
ilMailAddress $address
 
ilLogger $logger
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ isValid()

ilMailLoginOrEmailAddressAddressType::isValid ( int  $senderId)
protected

Reimplemented from ilBaseMailAddressType.

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

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

References ILIAS\Repository\logger(), and 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 74 of file class.ilMailLoginOrEmailAddressAddressType.php.

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

References ilBaseMailAddressType\$address, ilMailAddress\getMailbox(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Field Documentation

◆ $rbacsystem

ilRbacSystem ilMailLoginOrEmailAddressAddressType::$rbacsystem
protected

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

Referenced by __construct().


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