ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailRoleAddressType Class Reference

Class ilMailRoleAddressType. More...

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

Public Member Functions

 __construct (ilMailAddressTypeHelper $typeHelper, ilMailAddress $address, protected ilRoleMailboxSearch $roleMailboxSearch, ilLogger $logger, protected ilRbacSystem $rbacsystem, protected ilRbacReview $rbacreview)
 
 resolve ()
 Returns an array of resolved user ids based on an address instance. More...
 
- Public Member Functions inherited from ilBaseMailAddressType
 __construct (protected ilMailAddressTypeHelper $typeHelper, protected ilMailAddress $address, protected 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...
 

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=[])
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References ILIAS\GlobalScreen\Provider\__construct().

34  {
35  parent::__construct($typeHelper, $address, $logger);
36  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getRoleIdsByAddress()

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

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

Referenced by isValid(), and resolve().

41  : array
42  {
43  $combinedAddress = (string) $address;
44 
45  return $this->roleMailboxSearch->searchRoleIdsByAddressString($combinedAddress);
46  }
+ Here is the caller graph for this function:

◆ isValid()

ilMailRoleAddressType::isValid ( int  $senderId)
protected

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

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

61  : bool
62  {
63  $roleIds = $this->getRoleIdsByAddress($this->address);
64  if (!$this->maySendToGlobalRole($senderId)) {
65  foreach ($roleIds as $roleId) {
66  if ($this->rbacreview->isGlobalRole($roleId)) {
67  $this->pushError('mail_to_global_roles_not_allowed', [$this->address->getMailbox()]);
68  return false;
69  }
70  }
71  }
72 
73  if ($roleIds === []) {
74  $this->pushError('mail_recipient_not_found', [$this->address->getMailbox()]);
75  return false;
76  }
77 
78  if (count($roleIds) > 1) {
79  $this->pushError('mail_multiple_role_recipients_found', [
80  $this->address->getMailbox(),
81  implode(',', $roleIds),
82  ]);
83  return false;
84  }
85 
86  return true;
87  }
getRoleIdsByAddress(ilMailAddress $address)
pushError(string $languageVariable, array $placeHolderValues=[])
+ Here is the call graph for this function:

◆ maySendToGlobalRole()

ilMailRoleAddressType::maySendToGlobalRole ( int  $senderId)
protected

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

References ANONYMOUS_USER_ID.

Referenced by isValid().

48  : bool
49  {
50  if ($senderId === ANONYMOUS_USER_ID) {
51  return true;
52  }
53 
54  return $this->rbacsystem->checkAccessOfUser(
55  $senderId,
56  'mail_to_global_roles',
57  $this->typeHelper->getGlobalMailSystemId()
58  );
59  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ 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 89 of file class.ilMailRoleAddressType.php.

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

89  : array
90  {
91  $usrIds = [];
92 
93  $roleIds = $this->getRoleIdsByAddress($this->address);
94 
95  if ($roleIds !== []) {
96  $this->logger->debug(sprintf(
97  "Found the following role ids for address '%s': %s",
98  $this->address,
99  implode(', ', array_unique($roleIds))
100  ));
101 
102  foreach ($roleIds as $roleId) {
103  foreach ($this->rbacreview->assignedUsers($roleId) as $usrId) {
104  $usrIds[] = $usrId;
105  }
106  }
107 
108  if ($usrIds !== []) {
109  $this->logger->debug(sprintf(
110  "Found the following user ids for roles determined by address '%s': %s",
111  $this->address,
112  implode(', ', array_unique($usrIds))
113  ));
114  } else {
115  $this->logger->debug(sprintf(
116  "Did not find any assigned users for roles determined by '%s'",
117  $this->address
118  ));
119  }
120  } else {
121  $this->logger->debug(sprintf(
122  "Did not find any role (and user ids) for address '%s'",
123  $this->address
124  ));
125  }
126 
127  return array_unique($usrIds);
128  }
getRoleIdsByAddress(ilMailAddress $address)
+ Here is the call graph for this function:

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