71 static $parser =
null;
72 static $availableUsersList =
null;
77 $newRightsNameList = [];
80 empty(
$params[
'destinationList'])
81 || !is_array(
$params[
'destinationList'])
87 $currentUserExtranet = (
92 $availableUsersList ===
null
93 && Loader::includeModule(
'extranet')
96 $availableUsersList = ($currentUserExtranet ? \CExtranet::getMyGroupsUsers(SITE_ID) : []);
99 foreach (
$params[
'destinationList'] as $destinationCode)
101 $hiddenDestination = (
102 isset(
$params[
'hiddenDestinationList'])
103 && is_array(
$params[
'hiddenDestinationList'])
104 && in_array($destinationCode,
$params[
'hiddenDestinationList'])
115 if (preg_match(
'/^(SG|U||UA|DR)(\d*)$/', $destinationCode, $matches))
117 $entityType = $matches[1];
118 $entityId = ($matches[2] ??
false);
119 $hiddenEntity = $renderParts =
false;
130 && $entityType ===
'U'
135 && !in_array($entityId, $availableUsersList)
138 $hiddenEntity =
true;
149 $renderParts =
false;
152 $entityDataFormatted = ($renderParts ? $renderParts->getData((
int)$entityId) :
false);
156 && isset($entityDataFormatted[
'name'])
157 && $entityDataFormatted[
'name'] <>
''
160 $newRightsNameList[] = (
161 isset($entityDataFormatted[
'link'])
162 && $entityDataFormatted[
'link'] <>
''
167 && (
int)$entityId > 0
168 ?
'[USER=' . $entityId .
']' . htmlspecialcharsback($entityDataFormatted[
'name']) .
'[/USER]'
169 :
'[URL=' . $entityDataFormatted[
'link'] .
']' . htmlspecialcharsback($entityDataFormatted[
'name']) .
'[/URL]'
171 : htmlspecialcharsback($entityDataFormatted[
'name'])
174 elseif ($hiddenEntity)
176 $newRightsNameList[] =
Loc::getMessage(
'SONET_COMMENTAUX_SHARE_HIDDEN');
182 $newRightsNameList[] =
Loc::getMessage(
'SONET_COMMENTAUX_SHARE_HIDDEN');
186 if (empty($newRightsNameList))
191 $result .=
Loc::getMessage(count(
$params[
'destinationList']) > 1 ?
'SONET_COMMENTAUX_SHARE_TEXT_1' :
'SONET_COMMENTAUX_SHARE_TEXT', [
192 '#SHARE_LIST#' => implode(
', ', $newRightsNameList)
195 if ($parser ===
null)
197 $parser = new \CTextParser();
206 !empty(
$params[
'pathEntityType'])
207 && !empty(
$params[
'pathEntityId'])
210 $parser->pathToUserEntityType =
$params[
'pathEntityType'];
211 $parser->pathToUserEntityId = (int)
$params[
'pathEntityId'];
215 $parser->pathToUserEntityType =
false;
216 $parser->pathToUserEntityId =
false;
219 return $parser->convertText($result);