ILIAS  trunk Revision v12.0_alpha-399-g579a087ced2
ilMailLoginOrEmailAddressAddressType Class Reference
+ Inheritance diagram for ilMailLoginOrEmailAddressAddressType:
+ Collaboration diagram for ilMailLoginOrEmailAddressAddressType:

Public Member Functions

 __construct (ilMailAddressTypeHelper $type_helper, 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 $type_helper, protected ilMailAddress $address, protected ilLogger $logger)
 
 validate (int $sender_id)
 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 $sender_id)
 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 $sender_id)
 
- Protected Member Functions inherited from ilBaseMailAddressType
 isValid (int $sender_id)
 
 pushError (string $language_variable, array $place_holder_values=[])
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

28 {
29 parent::__construct($type_helper, $address, $logger);
30 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ isValid()

ilMailLoginOrEmailAddressAddressType::isValid ( int  $sender_id)
protected

Reimplemented from ilBaseMailAddressType.

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

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

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
list<int>

Implements ilMailAddressType.

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

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

References ILIAS\Repository\logger().

+ Here is the call graph for this function:

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