ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilMailRoleAddressType Class Reference
+ Inheritance diagram for ilMailRoleAddressType:
+ Collaboration diagram for ilMailRoleAddressType:

Public Member Functions

 __construct (ilMailAddressTypeHelper $type_helper, ilMailAddress $address, protected ilRoleMailboxSearch $role_mailbox_search, 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 $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...
 

Protected Member Functions

 getRoleIdsByAddress (ilMailAddress $address)
 
 maySendToGlobalRole (int $sender_id)
 
 isValid (int $sender_id)
 
- Protected Member Functions inherited from ilBaseMailAddressType
 isValid (int $sender_id)
 
 pushError (string $language_variable, array $place_holder_values=[])
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References ILIAS\GlobalScreen\Provider\__construct().

30  {
31  parent::__construct($type_helper, $address, $logger);
32  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getRoleIdsByAddress()

ilMailRoleAddressType::getRoleIdsByAddress ( ilMailAddress  $address)
protected
Returns
list<int>

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

Referenced by isValid(), and resolve().

37  : array
38  {
39  $combined_address = (string) $address;
40 
41  return $this->role_mailbox_search->searchRoleIdsByAddressString($combined_address);
42  }
+ Here is the caller graph for this function:

◆ isValid()

ilMailRoleAddressType::isValid ( int  $sender_id)
protected

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

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

57  : bool
58  {
59  $role_ids = $this->getRoleIdsByAddress($this->address);
60  if (!$this->maySendToGlobalRole($sender_id)) {
61  foreach ($role_ids as $role_id) {
62  if ($this->rbacreview->isGlobalRole($role_id)) {
63  $this->pushError('mail_to_global_roles_not_allowed', [$this->address->getMailbox()]);
64  return false;
65  }
66  }
67  }
68 
69  if ($role_ids === []) {
70  $this->pushError('mail_recipient_not_found', [$this->address->getMailbox()]);
71  return false;
72  }
73 
74  if (count($role_ids) > 1) {
75  $this->pushError('mail_multiple_role_recipients_found', [
76  $this->address->getMailbox(),
77  implode(',', $role_ids),
78  ]);
79  return false;
80  }
81 
82  return true;
83  }
getRoleIdsByAddress(ilMailAddress $address)
pushError(string $language_variable, array $place_holder_values=[])
+ Here is the call graph for this function:

◆ maySendToGlobalRole()

ilMailRoleAddressType::maySendToGlobalRole ( int  $sender_id)
protected

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

References ANONYMOUS_USER_ID.

Referenced by isValid().

44  : bool
45  {
46  if ($sender_id === ANONYMOUS_USER_ID) {
47  return true;
48  }
49 
50  return $this->rbacsystem->checkAccessOfUser(
51  $sender_id,
52  'mail_to_global_roles',
53  $this->type_helper->getGlobalMailSystemId()
54  );
55  }
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
list<int>

Implements ilMailAddressType.

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

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

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

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