ILIAS  release_8 Revision v8.24
ilMailRoleAddressType Class Reference

Class ilMailRoleAddressType. More...

+ Inheritance diagram for ilMailRoleAddressType:
+ Collaboration diagram for ilMailRoleAddressType:

Public Member Functions

 __construct (ilMailAddressTypeHelper $typeHelper, ilMailAddress $address, ilRoleMailboxSearch $roleMailboxSearch, ilLogger $logger, ilRbacSystem $rbacsystem, ilRbacReview $rbacreview)
 
 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

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

Protected Attributes

ilRbacSystem $rbacsystem
 
ilRbacReview $rbacreview
 
ilRoleMailboxSearch $roleMailboxSearch
 
- Protected Attributes inherited from ilBaseMailAddressType
ilMailAddressTypeHelper $typeHelper
 
ilMailAddress $address
 
ilLogger $logger
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailRoleAddressType::__construct ( ilMailAddressTypeHelper  $typeHelper,
ilMailAddress  $address,
ilRoleMailboxSearch  $roleMailboxSearch,
ilLogger  $logger,
ilRbacSystem  $rbacsystem,
ilRbacReview  $rbacreview 
)

Definition at line 31 of file class.ilMailRoleAddressType.php.

38 {
40
41 $this->roleMailboxSearch = $roleMailboxSearch;
42 $this->rbacsystem = $rbacsystem;
43 $this->rbacreview = $rbacreview;
44 }
ilMailAddressTypeHelper $typeHelper
ilRoleMailboxSearch $roleMailboxSearch
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ilBaseMailAddressType\$address, ilBaseMailAddressType\$logger, $rbacreview, $rbacsystem, $roleMailboxSearch, ilBaseMailAddressType\$typeHelper, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getRoleIdsByAddress()

ilMailRoleAddressType::getRoleIdsByAddress ( ilMailAddress  $address)
protected
Returns
int[]

Definition at line 49 of file class.ilMailRoleAddressType.php.

49 : array
50 {
51 $combinedAddress = (string) $address;
52
53 $roleIds = $this->roleMailboxSearch->searchRoleIdsByAddressString($combinedAddress);
54
55 return $roleIds;
56 }

References ilBaseMailAddressType\$address.

Referenced by isValid(), and resolve().

+ Here is the caller graph for this function:

◆ isValid()

ilMailRoleAddressType::isValid ( int  $senderId)
protected

Reimplemented from ilBaseMailAddressType.

Definition at line 73 of file class.ilMailRoleAddressType.php.

73 : bool
74 {
75 $roleIds = $this->getRoleIdsByAddress($this->address);
76 if (!$this->maySendToGlobalRole($senderId)) {
77 foreach ($roleIds as $roleId) {
78 if ($this->rbacreview->isGlobalRole($roleId)) {
79 $this->pushError('mail_to_global_roles_not_allowed', [$this->address->getMailbox()]);
80 return false;
81 }
82 }
83 }
84
85 if ($roleIds === []) {
86 $this->pushError('mail_recipient_not_found', [$this->address->getMailbox()]);
87 return false;
88 }
89
90 if (count($roleIds) > 1) {
91 $this->pushError('mail_multiple_role_recipients_found', [
92 $this->address->getMailbox(),
93 implode(',', $roleIds),
94 ]);
95 return false;
96 }
97
98 return true;
99 }
pushError(string $languageVariable, array $placeHolderValues=[])
getRoleIdsByAddress(ilMailAddress $address)

References getRoleIdsByAddress(), maySendToGlobalRole(), and ilBaseMailAddressType\pushError().

+ Here is the call graph for this function:

◆ maySendToGlobalRole()

ilMailRoleAddressType::maySendToGlobalRole ( int  $senderId)
protected

Definition at line 58 of file class.ilMailRoleAddressType.php.

58 : bool
59 {
60 if ($senderId === ANONYMOUS_USER_ID) {
61 return true;
62 }
63
64 $maySendToGlobalRoles = $this->rbacsystem->checkAccessOfUser(
65 $senderId,
66 'mail_to_global_roles',
67 $this->typeHelper->getGlobalMailSystemId()
68 );
69
70 return $maySendToGlobalRoles;
71 }
const ANONYMOUS_USER_ID
Definition: constants.php:27

References ANONYMOUS_USER_ID.

Referenced by isValid().

+ Here is the caller graph for this function:

◆ resolve()

ilMailRoleAddressType::resolve ( )

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

Returns
int[]

Implements ilMailAddressType.

Definition at line 101 of file class.ilMailRoleAddressType.php.

101 : array
102 {
103 $usrIds = [];
104
105 $roleIds = $this->getRoleIdsByAddress($this->address);
106
107 if (count($roleIds) > 0) {
108 $this->logger->debug(sprintf(
109 "Found the following role ids for address '%s': %s",
110 $this->address,
111 implode(', ', array_unique($roleIds))
112 ));
113
114 foreach ($roleIds as $roleId) {
115 foreach ($this->rbacreview->assignedUsers($roleId) as $usrId) {
116 $usrIds[] = $usrId;
117 }
118 }
119
120 if (count($usrIds) > 0) {
121 $this->logger->debug(sprintf(
122 "Found the following user ids for roles determined by address '%s': %s",
123 $this->address,
124 implode(', ', array_unique($usrIds))
125 ));
126 } else {
127 $this->logger->debug(sprintf(
128 "Did not find any assigned users for roles determined by '%s'",
129 $this->address
130 ));
131 }
132 } else {
133 $this->logger->debug(sprintf(
134 "Did not find any role (and user ids) for address '%s'",
135 $this->address
136 ));
137 }
138
139 return array_unique($usrIds);
140 }

References getRoleIdsByAddress(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Field Documentation

◆ $rbacreview

ilRbacReview ilMailRoleAddressType::$rbacreview
protected

Definition at line 28 of file class.ilMailRoleAddressType.php.

Referenced by __construct().

◆ $rbacsystem

ilRbacSystem ilMailRoleAddressType::$rbacsystem
protected

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

Referenced by __construct().

◆ $roleMailboxSearch

ilRoleMailboxSearch ilMailRoleAddressType::$roleMailboxSearch
protected

Definition at line 29 of file class.ilMailRoleAddressType.php.

Referenced by __construct().


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