ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.
See also
::getErrors
Parameters
$senderIdinteger The id of the acting ILIAS user, can be used for permission checks etc.
Returns
bool
More...
 
 getErrors ()
 Returns a list of errors determined in the validation process.The errors should be reset everytime the validation is triggered.

See also
::validate
Returns
More...
 
 getAddress ()
 The address instance used for validation and user id lookup.
Returns
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

 $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 
)

ilMailRoleAddressType constructor.

Parameters
\ilMailAddressTypeHelper$typeHelper
\ilMailAddress$address
\ilRoleMailboxSearch$roleMailboxSearch
\ilLogger$logger
\ilRbacSystem$rbacsystem
\ilRbacReview$rbacreview

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

References $rbacreview, $rbacsystem, and $roleMailboxSearch.

Member Function Documentation

◆ getRoleIdsByAddress()

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

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

Referenced by isValid(), and resolve().

47  : array
48  {
49  $combinedAddress = (string) $address;
50 
51  $roleIds = $this->roleMailboxSearch->searchRoleIdsByAddressString($combinedAddress);
52 
53  return $roleIds;
54  }
+ Here is the caller graph for this function:

◆ isValid()

ilMailRoleAddressType::isValid ( int  $senderId)
protected

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

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

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  } else {
94  if (count($roleIds) > 1) {
95  $this->pushError('mail_multiple_role_recipients_found', [
96  $this->address->getMailbox(),
97  implode(',', $roleIds),
98  ]);
99  return false;
100  }
101  }
102 
103  return true;
104  }
pushError(string $languageVariable, array $placeHolderValues=[])
getRoleIdsByAddress(\ilMailAddress $address)
+ 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.

Referenced by isValid().

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  }
+ 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 109 of file class.ilMailRoleAddressType.php.

References getRoleIdsByAddress().

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