19 declare(strict_types=1);
37 bool $localize =
true,
48 $db = $DIC->database();
53 $lng = $DIC->language();
57 if (null === $parserFactory) {
124 $query =
"SELECT rdat.title role_title,odat.title object_title, " .
125 " oref.ref_id object_ref " .
126 "FROM object_data rdat " .
127 "JOIN rbac_fa fa ON fa.rol_id = rdat.obj_id " .
128 "JOIN tree rtree ON rtree.child = fa.parent " .
129 "JOIN object_reference oref ON oref.ref_id = rtree.child " .
130 "JOIN object_data odat ON odat.obj_id = oref.obj_id " .
131 "WHERE rdat.obj_id = " . $this->db->quote($this->roleId,
'integer') .
" " .
132 "AND fa.assign = 'y' ";
134 if (!$row = $this->db->fetchObject(
$res)) {
138 $object_title = $row->object_title;
139 $object_ref = (
int) $row->object_ref;
140 $role_title = $row->role_title;
145 $domain = $object_title;
146 $local_part = $role_title;
149 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count " .
150 "FROM object_data dat " .
151 "JOIN object_reference ref ON ref.obj_id = dat.obj_id " .
152 "JOIN tree ON tree.child = ref.ref_id " .
153 "WHERE title = " . $this->db->quote($object_title,
'text') .
" " .
154 "AND tree.tree = 1 ";
155 $res = $this->db->query($q);
156 $row = $this->db->fetchObject(
$res);
159 if ($row->count > 1) {
167 if ($domain !== null && preg_match(
'/[\[\]\\]|[\x00-\x1f]|[\x28-\x29]|[;]/', $domain)) {
173 if ($domain !== null &&
174 (preg_match(
'/[()<>@,;:\\".\[\]]/', $domain) ||
175 preg_match(
'/[^\x21-\x8f]/', $domain))
177 $domain =
'[' . $domain .
']';
183 if ($domain !== null && strpos($role_title,
'il_') === 0) {
184 $unambiguous_role_title = $role_title;
186 $pos = strpos($role_title,
'_', 3) + 1;
187 $local_part = substr(
190 strrpos($role_title,
'_') - $pos
200 if ($domain === null) {
201 $q =
"SELECT COUNT(DISTINCT dat.obj_id) count " .
202 "FROM object_data dat " .
203 "JOIN object_reference ref ON ref.obj_id = dat.obj_id " .
204 "JOIN tree ON tree.child = ref.ref_id " .
205 "WHERE title = " . $this->db->quote($local_part,
'text') .
" " .
206 "AND tree.tree = 1 ";
208 $q =
"SELECT COUNT(rd.obj_id) count " .
209 "FROM object_data rd " .
210 "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id " .
211 "JOIN tree t ON t.child = fa.parent " .
212 "WHERE fa.assign = 'y' " .
213 "AND t.child = " . $this->db->quote($object_ref,
'integer') .
" " .
214 "AND rd.title LIKE " . $this->db->quote(
215 '%' . preg_replace(
'/([_%])/',
'\\\\$1', $local_part) .
'%',
220 $res = $this->db->query($q);
221 $row = $this->db->fetchObject(
$res);
225 if ($row->count > 1) {
226 $local_part = $unambiguous_role_title;
233 if (preg_match(
'/[\\"\x00-\x1f]/', $local_part)) {
234 $local_part = $unambiguous_role_title;
235 } elseif (!preg_match(
'/^[\\x00-\\x7E]+$/i', $local_part)) {
237 $local_part = $unambiguous_role_title;
242 $local_part =
'#' . $local_part;
245 if (preg_match(
'/[()<>@,;:.\[\]\x20]/', $local_part)) {
246 $local_part =
'"' . $local_part .
'"';
249 $mailbox = ($domain === null) ?
251 $local_part .
'@' . $domain;
253 if ($this->localize) {
254 if (strpos($role_title,
'il_') === 0) {
255 $phrase = $this->
lng->txt(substr($role_title, 0, strrpos($role_title,
'_')));
257 $phrase = $role_title;
264 $phrase = preg_replace(
'/\s\s+/',
' ', $phrase);
265 $phrase = preg_replace(
'/[()<>@,;:\\".\[\]]/',
'', $phrase);
267 $mailbox = $phrase .
' <' . $mailbox .
'>';
272 $parser = $this->parserFactory->getParser($mailbox);
277 $res = $this->db->query(
"SELECT title FROM object_data WHERE obj_id = " . $this->db->quote(
281 if ($row = $this->db->fetchObject(
$res)) {
282 return '#' . $row->title;
value()
Returns the mailbox address of a role.
Class ilRoleMailboxAddress.
Class ilMailRfc822AddressParserFactory.
ilMailRfc822AddressParserFactory $parserFactory
__construct(int $roleId, bool $localize=true, ilMailRfc822AddressParserFactory $parserFactory=null, ilDBInterface $db=null, ilLanguage $lng=null)