ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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)
 ilMailRoleAddressType 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

 getRoleIdsByAddress (ilMailAddress $address)
 
 maySendToGlobalRole (int $senderId)
 
 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
 
 $rbacreview
 
 $roleMailboxSearch
 
- Protected Attributes inherited from ilBaseMailAddressType
 $typeHelper
 
 $address
 
 $logger
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ getRoleIdsByAddress()

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

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

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

References ilBaseMailAddressType\$address.

Referenced by isValid(), and resolve().

+ Here is the caller graph for this function:

◆ isValid()

ilMailRoleAddressType::isValid ( int  $senderId)
protected

Parameters
$senderIdinteger
Returns
bool

Reimplemented from ilBaseMailAddressType.

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

78 : bool
79 {
80 $roleIds = $this->getRoleIdsByAddress($this->address);
81 if (!$this->maySendToGlobalRole($senderId)) {
82 foreach ($roleIds as $roleId) {
83 if ($this->rbacreview->isGlobalRole($roleId)) {
84 $this->pushError('mail_to_global_roles_not_allowed', [$this->address->getMailbox()]);
85 return false;
86 }
87 }
88 }
89
90 if (count($roleIds) == 0) {
91 $this->pushError('mail_recipient_not_found', [$this->address->getMailbox()]);
92 return false;
93 } elseif (count($roleIds) > 1) {
94 $this->pushError('mail_multiple_role_recipients_found', [
95 $this->address->getMailbox(),
96 implode(',', $roleIds),
97 ]);
98 return false;
99 }
100
101 return true;
102 }
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
Parameters
int$senderId
Returns
bool

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

60 : bool
61 {
62 if ($senderId == ANONYMOUS_USER_ID) {
63 return true;
64 }
65
66 $maySendToGlobalRoles = $this->rbacsystem->checkAccessOfUser(
67 $senderId,
68 'mail_to_global_roles',
69 $this->typeHelper->getGlobalMailSystemId()
70 );
71
72 return $maySendToGlobalRoles;
73 }

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 107 of file class.ilMailRoleAddressType.php.

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

References getRoleIdsByAddress().

+ Here is the call graph for this function:

Field Documentation

◆ $rbacreview

ilMailRoleAddressType::$rbacreview
protected

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

Referenced by __construct().

◆ $rbacsystem

ilMailRoleAddressType::$rbacsystem
protected

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

Referenced by __construct().

◆ $roleMailboxSearch

ilMailRoleAddressType::$roleMailboxSearch
protected

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

Referenced by __construct().


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