51 global $USER_FIELD_MANAGER;
53 if (isset(self::$postsCache[$postId]))
55 $result = self::$postsCache[$postId];
59 if (!Loader::includeModule(
'blog'))
64 $res = \CBlogPost::getList(
71 [
'ID',
'BLOG_GROUP_ID',
'BLOG_GROUP_SITE_ID',
'BLOG_ID',
'PUBLISH_STATUS',
'TITLE',
'AUTHOR_ID',
'ENABLE_COMMENTS',
'NUM_COMMENTS',
'VIEWS',
'CODE',
'MICRO',
'DETAIL_TEXT',
'DATE_PUBLISH',
'CATEGORY_ID',
'HAS_SOCNET_ALL',
'HAS_TAGS',
'HAS_IMAGES',
'HAS_PROPS',
'HAS_COMMENT_IMAGES' ]
74 if ($result = $res->fetch())
76 if (!empty($result[
'DETAIL_TEXT']))
78 $result[
'DETAIL_TEXT'] = \Bitrix\Main\Text\Emoji::decode($result[
'DETAIL_TEXT']);
81 $result[
"ATTACHMENTS"] = [];
83 if($result[
"HAS_PROPS"] !==
"N")
85 $userFields = $USER_FIELD_MANAGER->getUserFields(
"BLOG_POST", $postId, $languageId);
86 $postUf = [
'UF_BLOG_POST_FILE' ];
87 foreach ($userFields as $fieldName => $userField)
89 if (!in_array($fieldName, $postUf))
91 unset($userFields[$fieldName]);
96 !empty($userFields[
"UF_BLOG_POST_FILE"])
97 && !empty($userFields[
"UF_BLOG_POST_FILE"][
"VALUE"])
100 $result[
"ATTACHMENTS"] =
self::getAttachmentsData($userFields[
"UF_BLOG_POST_FILE"][
"VALUE"], $result[
"BLOG_GROUP_SITE_ID"]);
105 $result[
"DETAIL_TEXT"],
108 $result[
"AUTHOR_ID"],
109 $result[
"ATTACHMENTS"]
112 $result[
"DETAIL_TEXT_FORMATTED"] = preg_replace(
114 '|\[DISK\sFILE\sID=[n]*\d+\]|',
115 '|\[DOCUMENT\sID=[n]*\d+\]|'
118 $result[
"DETAIL_TEXT"]
121 $result[
'DETAIL_TEXT_FORMATTED'] =
Mention::clear($result[
'DETAIL_TEXT_FORMATTED']);
123 $p = new \blogTextParser();
124 $p->arUserfields = [];
127 $allow = [
'IMAGE' =>
'Y' ];
128 $parserParameters = [];
130 $result[
"DETAIL_TEXT_FORMATTED"] = $p->convert($result[
"DETAIL_TEXT_FORMATTED"],
false, $images, $allow, $parserParameters);
133 $result[
"MICRO"] ===
"Y"
134 ? \blogTextParser::killAllTags($result[
"DETAIL_TEXT_FORMATTED"])
135 : htmlspecialcharsEx($result[
"TITLE"])
138 $title = preg_replace(
139 '|\[MAIL\sDISK\sFILE\sID=[n]*\d+\]|',
144 $title = str_replace([
"\r\n",
"\n",
"\r" ],
" ", $title);
145 $result[
"TITLE_FORMATTED"] = \TruncateText($title, 100);
149 self::$postsCache[$postId] = $result;
165 if (isset(self::$destinationsCache[$postId]))
167 $result = self::$destinationsCache[$postId];
173 if (!Loader::includeModule(
'blog'))
178 $sonetPermission = \CBlogPost::getSocnetPermsName($postId);
179 if (!empty($sonetPermission))
181 foreach ($sonetPermission as $typeCode => $type)
183 foreach ($type as $destination)
187 if ($typeCode ===
"SG")
189 if ($sonetGroup = \CSocNetGroup::getByID($destination[
"ENTITY_ID"]))
191 $name = $sonetGroup[
"NAME"];
194 elseif ($typeCode ===
"U")
196 if(in_array(
"US" . $destination[
"ENTITY_ID"], $destination[
"ENTITY"],
true))
199 Loader::includeModule(
'intranet');
203 $name = \CUser::formatName(
204 \CSite::getNameFormat(
false),
206 "NAME" => $destination[
"~U_NAME"],
207 "LAST_NAME" => $destination[
"~U_LAST_NAME"],
208 "SECOND_NAME" => $destination[
"~U_SECOND_NAME"],
209 "LOGIN" => $destination[
"~U_LOGIN"]
215 elseif ($typeCode ===
"DR")
217 $name = $destination[
"EL_NAME"];
228 self::$destinationsCache[$postId] = $result;
245 if (isset(self::$authorsCache[$authorId]))
247 $result = self::$authorsCache[$authorId];
251 if (!Loader::includeModule(
'blog'))
256 $result = \CBlogUser::getUserInfo(
261 isset($params[
"AVATAR_SIZE"])
262 && (
int)$params[
"AVATAR_SIZE"] > 0
263 ? (
int)$params[
"AVATAR_SIZE"]
266 "AVATAR_SIZE_COMMENT" => (
267 isset($params[
"AVATAR_SIZE_COMMENT"])
268 && (int)$params[
"AVATAR_SIZE_COMMENT"] > 0
269 ? (
int)$params[
"AVATAR_SIZE_COMMENT"]
272 "RESIZE_IMMEDIATE" =>
"Y"
276 $result[
"NAME_FORMATTED"] = \CUser::formatName(
277 \CSite::getNameFormat(
false),
279 "NAME" => $result[
"~NAME"],
280 "LAST_NAME" => $result[
"~LAST_NAME"],
281 "SECOND_NAME" => $result[
"~SECOND_NAME"],
282 "LOGIN" => $result[
"~LOGIN"]
287 self::$authorsCache[$authorId] = $result;
306 if (isset(self::$commentListsCache[$postId]))
308 $result = self::$commentListsCache[$postId];
314 if (!Loader::includeModule(
'blog'))
319 $p = new \blogTextParser();
321 $selectedFields = [
'ID',
'BLOG_GROUP_ID',
'BLOG_GROUP_SITE_ID',
'BLOG_ID',
'POST_ID',
'AUTHOR_ID',
'AUTHOR_NAME',
'AUTHOR_EMAIL',
'POST_TEXT',
'DATE_CREATE',
'PUBLISH_STATUS',
'HAS_PROPS',
'SHARE_DEST' ];
324 if ($connection instanceof \
Bitrix\Main\DB\MysqlCommonConnection)
326 $selectedFields[] =
"DATE_CREATE_TS";
329 $res = \CBlogComment::getList(
332 "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH,
337 "nTopCount" => $params[
"COMMENTS_COUNT"]
342 while ($comment = $res->fetch())
344 self::processCommentData($comment, $languageId, $p, [
"MAIL" => (isset($params[
"MAIL"]) && $params[
"MAIL"] ===
"Y" ?
"Y" :
"N") ]);
346 $result[] = $comment;
348 if (!in_array((
int)$comment[
"AUTHOR_ID"], $authorIdList,
true))
350 $authorIdList[] = (int)$comment[
"AUTHOR_ID"];
356 $result = array_reverse($result);
359 self::$commentListsCache[$postId] = $result;
375 if (isset(self::$commentCountCache[$postId]))
377 $result = self::$commentCountCache[$postId];
381 if (!Loader::includeModule(
'blog'))
386 $selectedFields = [
'ID' ];
388 $result = \CBlogComment::getList(
391 "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH,
392 "POST_ID" => $postId,
399 self::$commentCountCache[$postId] = $result;
417 if (isset(self::$commentsCache[$commentId]))
419 $result = self::$commentsCache[$commentId];
423 $selectedFields = [
"ID",
"BLOG_GROUP_ID",
"BLOG_GROUP_SITE_ID",
"BLOG_ID",
"POST_ID",
"AUTHOR_ID",
"AUTHOR_NAME",
"AUTHOR_EMAIL",
"POST_TEXT",
"DATE_CREATE",
"PUBLISH_STATUS",
"HAS_PROPS",
"SHARE_DEST" ];
426 if ($connection instanceof \
Bitrix\Main\DB\MysqlCommonConnection)
428 $selectedFields[] =
"DATE_CREATE_TS";
431 $res = \CBlogComment::getList(
441 if ($comment = $res->fetch())
443 $p = new \blogTextParser();
445 self::processCommentData($comment, $languageId, $p);
450 self::$commentsCache[$commentId] = $result;
463 private static function processCommentData(&$comment, $languageId, $p, $params = []): void
465 global $USER_FIELD_MANAGER;
469 && isset($params[
"MAIL"])
470 && $params[
"MAIL"] ===
'Y'
473 $comment[
"ATTACHMENTS"] = $comment[
"PROPS"] = [];
475 if ($commentAuxProvider = \
Bitrix\Socialnetwork\CommentAux\Base::findProvider(
478 "mobile" => (isset($params[
"MOBILE"]) && $params[
"MOBILE"] ===
"Y"),
479 "mail" => (isset($params[
"MAIL"]) && $params[
"MAIL"] ===
"Y"),
484 $comment[
"POST_TEXT_FORMATTED"] = $commentAuxProvider->getText();
485 $arComment[
"AUX_TYPE"] = $commentAuxProvider->getType();
489 if($comment[
"HAS_PROPS"] !==
"N")
491 $userFields = $comment[
"PROPS"] = $USER_FIELD_MANAGER->getUserFields(
"BLOG_COMMENT", $comment[
"ID"], $languageId);
492 $commentUf = [
'UF_BLOG_COMMENT_FILE' ];
493 foreach ($userFields as $fieldName => $userField)
495 if (!in_array($fieldName, $commentUf,
true))
497 unset($userFields[$fieldName]);
502 !empty($userFields[
"UF_BLOG_COMMENT_FILE"])
503 && !empty($userFields[
"UF_BLOG_COMMENT_FILE"][
"VALUE"])
506 $comment[
"ATTACHMENTS"] =
self::getAttachmentsData($userFields[
"UF_BLOG_COMMENT_FILE"][
"VALUE"], $comment[
"BLOG_GROUP_SITE_ID"]);
511 && isset($comment[
"PROPS"][
"UF_BLOG_COMM_URL_PRV"])
514 unset($comment[
"PROPS"][
"UF_BLOG_COMM_URL_PRV"]);
519 $comment[
"POST_TEXT"],
522 $comment[
"AUTHOR_ID"],
523 $comment[
"ATTACHMENTS"]
526 $comment[
"POST_TEXT_FORMATTED"] = preg_replace(
528 '|\[DISK\sFILE\sID=[n]*\d+\]|',
529 '|\[DOCUMENT\sID=[n]*\d+\]|'
532 $comment[
"POST_TEXT"]
535 $comment[
'POST_TEXT_FORMATTED'] =
Mention::clear($comment[
'POST_TEXT_FORMATTED']);
539 $p->arUserfields = [];
542 $allow = [
'IMAGE' =>
'Y' ];
543 $parserParameters = [];
545 $comment[
"POST_TEXT_FORMATTED"] = $p->convert($comment[
"POST_TEXT_FORMATTED"],
false, $images, $allow, $parserParameters);
562 public static function getReplyToUrl($url, $userId, $entityType, $entityId, $siteId, $backUrl =
null)
567 $userId = (int)$userId;
568 $entityType = (string)$entityType;
569 $entityId = (int)$entityId;
570 $siteId = (string)$siteId;
575 || $entityType ===
''
578 || !Loader::includeModule(
'mail')
584 $urlRes = \Bitrix\Mail\User::getReplyTo(
592 if (is_array($urlRes))
594 [ , $backUrl ] = $urlRes;
617 if (!Loader::includeModule(
'disk'))
624 || (
string)$siteId ===
''
630 foreach ($valueList as $value)
632 $attachedObject = AttachedObject::loadById($value, [
'OBJECT' ]);
635 || !$attachedObject->getFile()
641 $attachedObjectUrl = \Bitrix\Disk\UrlManager::getUrlUfController(
'show', [
'attachedId' => $value ]);
645 "OBJECT_ID" => $attachedObject->getFile()->getId(),
646 "NAME" => $attachedObject->getFile()->getName(),
647 "SIZE" => \CFile::formatSize($attachedObject->getFile()->getSize()),
648 "URL" => $attachedObjectUrl,
649 "IS_IMAGE" => TypeFile::isImage($attachedObject->getFile())
667 public static function getAttachmentUrlList($valueList = [], $entityType =
'', $entityId = 0, $authorId = 0, $attachmentList = []): array
673 || empty($attachmentList)
674 || (
int)$authorId <= 0
675 || (
int)$entityId <= 0
676 || !Loader::includeModule(
'disk')
682 $userFieldManager = Driver::getInstance()->getUserFieldManager();
683 [ $connectorClass, $moduleId ] = $userFieldManager->getConnectorDataByEntityType($entityType);
685 foreach($valueList as $value)
687 $attachedFileId =
false;
688 $attachedObject =
false;
690 [ $type, $realValue ] = FileUserType::detectType($value);
691 if ($type === FileUserType::TYPE_NEW_OBJECT)
693 $attachedObject = AttachedObject::load([
694 '=ENTITY_TYPE' => $connectorClass,
695 'ENTITY_ID' => $entityId,
696 '=MODULE_ID' => $moduleId,
697 'OBJECT_ID'=> $realValue
702 $attachedFileId = $attachedObject->getId();
707 $attachedFileId = $realValue;
711 (
int)$attachedFileId > 0
712 && !empty($attachmentList[$attachedFileId])
715 if (!$attachmentList[$attachedFileId][
"IS_IMAGE"])
719 'URL' => $attachmentList[$attachedFileId][
"URL"]
724 if (!$attachedObject)
726 $attachedObject = AttachedObject::loadById($attachedFileId, [
'OBJECT' ]);
731 $file = $attachedObject->getFile();
733 $extLinks = $file->getExternalLinks([
735 'OBJECT_ID' => $file->getId(),
736 'CREATED_BY' => $authorId,
737 'TYPE' => \
Bitrix\Disk\Internals\ExternalLinkTable::TYPE_MANUAL,
738 'IS_EXPIRED' =>
false,
743 if (empty($extLinks))
745 $externalLink = $file->addExternalLink([
746 'CREATED_BY' => $authorId,
747 'TYPE' => \
Bitrix\Disk\Internals\ExternalLinkTable::TYPE_MANUAL,
753 $externalLink = reset($extLinks);
758 $originalFile = $file->getFile();
762 'URL' => Driver::getInstance()->getUrlManager()->getUrlExternalLink(
764 'hash' => $externalLink->getHash(),
765 'action' =>
'showFile'
769 'WIDTH' => (int)$originalFile[
"WIDTH"],
770 'HEIGHT' => (
int)$originalFile[
"HEIGHT"]
790 if (preg_match_all(
'|\[MAIL\sDISK\sFILE\sID=([n]*\d+)\]|', $text, $matches))
792 foreach($matches[1] as $inlineFileId)
794 $attachmentId =
false;
795 if (mb_strpos($inlineFileId,
'n') === 0)
798 foreach($attachmentList as $attachmentId => $attachment)
801 isset($attachment[
"OBJECT_ID"])
802 && (
int)$attachment[
"OBJECT_ID"] === (
int)mb_substr($inlineFileId, 1)
811 $attachmentId =
false;
816 $attachmentId = $inlineFileId;
819 if ((
int)$attachmentId > 0)
821 $text = preg_replace(
822 '|\[MAIL\sDISK\sFILE\sID='.$inlineFileId.
'\]|',
823 '[URL='.$attachmentList[$attachmentId][
"URL"].
']['.$attachmentList[$attachmentId][
"NAME"].
'][/URL]',
829 $p = new \CTextParser();
830 $p->allow = [
'HTML' =>
'Y',
'ANCHOR' =>
'Y' ];
831 $text = $p->convertText($text);
849 $text = trim((
string)$text);
850 $authorId = (int)$authorId;
851 $entityType = (string)$entityType;
852 $entityId = (int)$entityId;
856 || empty($attachmentList)
858 || $entityType ===
''
865 if (preg_match_all(
'|\[DISK\sFILE\sID=([n]*\d+)\]|', $text, $matches))
867 $attachmentUrlList = self::getAttachmentUrlList(
875 foreach($matches[1] as $inlineFileId)
877 if (!empty($attachmentUrlList[$inlineFileId]))
879 $needCreatePicture =
false;
880 $sizeSource = $sizeDestination = [];
882 $attachmentUrlList[$inlineFileId][
'WIDTH'], $attachmentUrlList[$inlineFileId][
'HEIGHT'],
883 [
'width' => 400,
'height' => 1000 ], BX_RESIZE_IMAGE_PROPORTIONAL,
884 $needCreatePicture, $sizeSource, $sizeDestination
888 $attachmentUrlList[$inlineFileId][
"TYPE"] ===
'image'
889 ?
'[IMG WIDTH='.(int)$sizeDestination[
'width'].
' HEIGHT='.(
int)$sizeDestination[
'height'].
']'.\htmlspecialcharsBack($attachmentUrlList[$inlineFileId][
"URL"]).
'[/IMG]'
890 :
'[MAIL DISK FILE ID='.$inlineFileId.
']'
892 $text = preg_replace(
893 '|\[DISK\sFILE\sID='.$inlineFileId.
'\]|',
916 preg_match_all(
"#\\[disk file id=(n?\\d+)\\]#is".BX_UTF_PCRE_MODIFIER, $text, $matches)
917 && Loader::includeModule(
'disk')
920 $userFieldManager = Driver::getInstance()->getUserFieldManager();
922 foreach ($matches[1] as $id)
925 [ $type, $realValue ] = FileUserType::detectType($id);
927 if ($type === FileUserType::TYPE_NEW_OBJECT)
929 $fileModel = File::loadById($realValue);
937 $attachedModel = $userFieldManager->getAttachedObjectById($realValue);
943 $attachedModel->setOperableEntity([
944 'ENTITY_ID' => $ufData[
'ENTITY_ID'],
945 'ENTITY_VALUE_ID' => $ufData[
'ENTITY_VALUE_ID']
947 $fileModel = $attachedModel->getFile();
950 if(TypeFile::isImage($fileModel))
970 if (empty($dateTimeSource))
975 $serverTs = \MakeTimeStamp($dateTimeSource) - \CTimeZone::getOffset();
976 $serverGMTOffset = (int)date(
'Z');
977 $authorOffset = (int)\CTimeZone::getOffset($authorId);
979 $authorGMTOffset = $serverGMTOffset + $authorOffset;
980 $authorGMTOffsetFormatted =
'GMT';
981 if ($authorGMTOffset !== 0)
983 $authorGMTOffsetFormatted .= ($authorGMTOffset >= 0 ?
'+' :
'-').sprintf(
'%02d', floor($authorGMTOffset / 3600)).
':'.sprintf(
'%02u', ($authorGMTOffset % 3600) / 60);
987 preg_replace(
'/[\/.,\s:][s]/',
'', \
Bitrix\Main\
Type\Date::convertFormatToPhp(FORMAT_DATETIME)),
988 ($serverTs + $authorOffset)
989 ).
' ('.$authorGMTOffsetFormatted.
')';
1002 if (!Loader::includeModule(
'blog'))
1007 $cacheTtl = 3153600;
1008 $cacheId =
'blog_group_list_'.md5(serialize($params));
1009 $cacheDir =
'/blog/group/';
1010 $cache = new \CPHPCache;
1012 if($cache->initCache($cacheTtl, $cacheId, $cacheDir))
1014 $result = $cache->getVars();
1018 $cache->startDataCache();
1020 $ideaBlogGroupIdList = array();
1021 if (ModuleManager::isModuleInstalled(
"idea"))
1023 $res = \CSite::getList(
"sort",
"desc", Array(
"ACTIVE" =>
"Y"));
1024 while ($site = $res->fetch())
1026 $val = Option::get(
"idea",
"blog_group_id",
false, $site[
"LID"]);
1029 $ideaBlogGroupIdList[] = $val;
1035 if (!empty($params[
"SITE_ID"]))
1037 $filter[
'SITE_ID'] = $params[
"SITE_ID"];
1039 if (!empty($ideaBlogGroupIdList))
1041 $filter[
'!@ID'] = $ideaBlogGroupIdList;
1044 $res = \CBlogGroup::getList(array(), $filter,
false,
false, array(
"ID"));
1045 while($blogGroup = $res->fetch())
1047 $result[] = $blogGroup[
"ID"];
1050 $cache->endDataCache($result);
1069 if (!Loader::includeModule(
'blog'))
1075 !isset($params[
"BLOG_GROUP_ID"], $params[
"USER_ID"], $params[
"SITE_ID"])
1076 || (
int)$params[
"BLOG_GROUP_ID"] <= 0
1077 || (
int)$params[
"USER_ID"] <= 0
1078 || (
string)$params[
"SITE_ID"] ===
''
1085 !isset($params[
"PATH_TO_BLOG"])
1086 || $params[
"PATH_TO_BLOG"] ==
''
1089 $params[
"PATH_TO_BLOG"] =
"";
1093 $helper = $connection->getSqlHelper();
1096 "=DATE_UPDATE" => $helper->getCurrentDateTimeFunction(),
1097 "=DATE_CREATE" => $helper->getCurrentDateTimeFunction(),
1098 "GROUP_ID" => (
int)$params[
"BLOG_GROUP_ID"],
1100 "OWNER_ID" => (
int)$params[
"USER_ID"],
1101 "ENABLE_COMMENTS" =>
"Y",
1102 "ENABLE_IMG_VERIF" =>
"Y",
1103 "EMAIL_NOTIFY" =>
"Y",
1104 "ENABLE_RSS" =>
"Y",
1105 "ALLOW_HTML" =>
"N",
1106 "ENABLE_TRACKBACK" =>
"N",
1107 "SEARCH_INDEX" =>
"Y",
1108 "USE_SOCNET" =>
"Y",
1109 "PERMS_POST" => Array(
1113 "PERMS_COMMENT" => Array(
1119 $res = \Bitrix\Main\UserTable::getList(array(
1122 "ID" => $params[
"USER_ID"]
1124 'select' => array(
"NAME",
"LAST_NAME",
"LOGIN")
1127 if ($user = $res->fetch())
1130 $user[
"NAME"].
"".$user[
"LAST_NAME"] ===
''
1132 : $user[
"NAME"].
" ".$user[
"LAST_NAME"]
1135 $fields[
"URL"] = str_replace(
" ",
"_", $user[
"LOGIN"]).
"-blog-".$params[
"SITE_ID"];
1136 $urlCheck = preg_replace(
"/[^a-zA-Z0-9_-]/i",
"", $fields[
"URL"]);
1137 if ($urlCheck !== $fields[
"URL"])
1139 $fields[
"URL"] =
"u".$params[
"USER_ID"].
"-blog-".$params[
"SITE_ID"];
1142 if(\CBlog::getByUrl($fields[
"URL"]))
1148 $fields[
"URL"] .= $uind;
1150 while (\CBlog::getByUrl($fields[
"URL"]));
1153 $fields[
"PATH"] = \CComponentEngine::makePathFromTemplate(
1154 $params[
"PATH_TO_BLOG"],
1156 "blog" => $fields[
"URL"],
1157 "user_id" => $fields[
"OWNER_ID"]
1161 if ($blogID = \CBlog::add($fields))
1163 BXClearCache(
true,
"/blog/form/blog/");
1165 $rightsFound =
false;
1167 $featureOperationPerms = \CSocNetFeaturesPerms::getOperationPerm(
1169 $fields[
"OWNER_ID"],
1174 if ($featureOperationPerms === SONET_RELATIONS_TYPE_ALL)
1176 $rightsFound =
true;
1181 \CBlog::addSocnetRead($blogID);
1184 $result = \CBlog::getByID($blogID);
1201 static $parser =
false;
1211 $parser = new \CTextParser();
1216 $text = $parser->convertHtmlToBB($text);
1219 preg_match_all(
"/\[url\s*=\s*([^\]]*)\](.+?)\[\/url\]/is".BX_UTF_PCRE_MODIFIER, $text, $res);
1228 ? \Bitrix\Main\Text\Encoding::convertEncoding($res[1][0],
'UTF-8', \
Bitrix\Main\
Context::getCurrent()->getCulture()->getCharset())
1232 $metaData = UrlPreview::getMetadataAndHtmlByUrl($url,
true,
false);
1235 && !empty($metaData[
"ID"])
1236 && (
int)$metaData[
"ID"] > 0
1239 $signer = new \Bitrix\Main\Security\Sign\Signer();
1240 $value = $signer->sign($metaData[
"ID"].
'', UrlPreview::SIGN_SALT);
1256 global $APPLICATION;
1259 if ($uf[
"USER_TYPE"][
"USER_TYPE_ID"] !==
'url_preview')
1266 $APPLICATION->includeComponent(
1267 "bitrix:system.field.view",
1268 $uf[
"USER_TYPE"][
"USER_TYPE_ID"],
1270 "LAZYLOAD" => (isset($params[
"LAZYLOAD"]) && $params[
"LAZYLOAD"] ===
"Y" ?
"Y" :
"N"),
1271 "MOBILE" => (isset($params[
"MOBILE"]) && $params[
"MOBILE"] ===
"Y" ?
"Y" :
"N"),
1272 "arUserField" => $uf,
1273 "arAddField" => array(
1274 "NAME_TEMPLATE" => ($params[
"NAME_TEMPLATE"] ??
false),
1275 "PATH_TO_USER" => ($params[
"PATH_TO_USER"] ??
'')
1277 ),
null, array(
"HIDE_ICONS"=>
"Y")
1280 $res = ob_get_clean();
1287 static $result =
false;
1288 global $CACHE_MANAGER;
1290 if ($result ===
false)
1294 if (!ModuleManager::isModuleInstalled(
'extranet'))
1299 $ttl = (defined(
"BX_COMP_MANAGED_CACHE") ? 2592000 : 600);
1300 $cacheId =
'sonet_ex_userid';
1301 $cache = new \CPHPCache;
1302 $cacheDir =
'/bitrix/sonet/user_ex';
1304 if($cache->initCache($ttl, $cacheId, $cacheDir))
1306 $tmpVal = $cache->getVars();
1307 $result = $tmpVal[
'EX_USER_ID'];
1312 if (defined(
"BX_COMP_MANAGED_CACHE"))
1314 $CACHE_MANAGER->startTagCache($cacheDir);
1318 'UF_DEPARTMENT_SINGLE' =>
false
1322 if (!empty($externalAuthIdList))
1324 $filter[
'!=EXTERNAL_AUTH_ID'] = $externalAuthIdList;
1327 $res = \Bitrix\Main\UserTable::getList(array(
1329 'filter' => $filter,
1330 'select' => array(
'ID')
1333 while($user = $res->fetch())
1335 $result[] = $user[
"ID"];
1339 $res = \Bitrix\Main\UserGroupTable::getList(array(
1344 'select' => [
'USER_ID' ]
1346 while($relationFields = $res->fetch())
1348 $adminList[] = $relationFields[
"USER_ID"];
1350 $result = array_diff($result, $adminList);
1352 if (defined(
"BX_COMP_MANAGED_CACHE"))
1354 $CACHE_MANAGER->registerTag(
'sonet_user2group');
1355 $CACHE_MANAGER->registerTag(
'sonet_extranet_user_list');
1356 $CACHE_MANAGER->endTagCache();
1359 if($cache->startDataCache())
1361 $cache->endDataCache(array(
1362 'EX_USER_ID' => $result
1373 global $CACHE_MANAGER;
1378 !ModuleManager::isModuleInstalled(
'mail')
1379 || !ModuleManager::isModuleInstalled(
'intranet')
1385 $ttl = (defined(
"BX_COMP_MANAGED_CACHE") ? 2592000 : 600);
1386 $cacheId =
'sonet_email_userid';
1387 $cache = new \CPHPCache;
1388 $cacheDir =
'/bitrix/sonet/user_email';
1390 if($cache->initCache($ttl, $cacheId, $cacheDir))
1392 $tmpVal = $cache->getVars();
1393 $result = $tmpVal[
'EMAIL_USER_ID'];
1398 if (defined(
"BX_COMP_MANAGED_CACHE"))
1400 $CACHE_MANAGER->startTagCache($cacheDir);
1403 $res = \Bitrix\Main\UserTable::getList(array(
1406 '=EXTERNAL_AUTH_ID' =>
'email'
1408 'select' => array(
'ID')
1411 while($user = $res->fetch())
1413 $result[] = $user[
"ID"];
1416 if (defined(
"BX_COMP_MANAGED_CACHE"))
1418 $CACHE_MANAGER->registerTag(
'USER_CARD');
1419 $CACHE_MANAGER->endTagCache();
1422 if($cache->startDataCache())
1424 $cache->endDataCache(array(
1425 'EMAIL_USER_ID' => $result
1437 $ttl = (defined(
"BX_COMP_MANAGED_CACHE") ? 2592000 : 600);
1438 $cacheId =
'sonet_ex_groupid';
1439 $cache = new \CPHPCache;
1440 $cacheDir =
'/bitrix/sonet/group_ex';
1442 if($cache->initCache($ttl, $cacheId, $cacheDir))
1444 $tmpVal = $cache->getVars();
1445 $result = $tmpVal[
'EX_GROUP_ID'];
1448 elseif (Loader::includeModule(
'extranet'))
1450 global $CACHE_MANAGER;
1451 if (defined(
"BX_COMP_MANAGED_CACHE"))
1453 $CACHE_MANAGER->startTagCache($cacheDir);
1456 $res = WorkgroupTable::getList(array(
1459 "=WorkgroupSite:GROUP.SITE_ID" => \CExtranet::getExtranetSiteID()
1461 'select' => array(
'ID')
1464 while($sonetGroup = $res->fetch())
1466 $result[] = $sonetGroup[
"ID"];
1467 if (defined(
"BX_COMP_MANAGED_CACHE"))
1469 $CACHE_MANAGER->registerTag(
'sonet_group_'.$sonetGroup[
"ID"]);
1473 if (defined(
"BX_COMP_MANAGED_CACHE"))
1475 $CACHE_MANAGER->registerTag(
'sonet_group');
1476 $CACHE_MANAGER->endTagCache();
1479 if($cache->startDataCache())
1481 $cache->endDataCache(array(
1482 'EX_GROUP_ID' => $result
1494 if (empty($params[
"LOG_EVENT_ID"]))
1499 $commentEvent = \CSocNetLogTools::findLogCommentEventByLogEventID($params[
"LOG_EVENT_ID"]);
1502 isset($commentEvent[
"DELETE_CALLBACK"])
1503 && $commentEvent[
"DELETE_CALLBACK"] !==
"NO_SOURCE"
1507 $commentEvent[
"EVENT_ID"] ===
"crm_activity_add_comment"
1508 && isset($params[
"LOG_ENTITY_ID"])
1509 && (
int)$params[
"LOG_ENTITY_ID"] > 0
1510 && Loader::includeModule(
'crm')
1513 $result = \CCrmActivity::getList(
1516 'ID' => (
int)$params[
"LOG_ENTITY_ID"],
1517 'CHECK_PERMISSIONS' =>
'N'
1521 if ($activity = $result->fetch())
1523 $res = ((int)$activity[
'TYPE_ID'] === \CCrmActivityType::Task);
1538 $postId = (int)$fields[
"POST_ID"];
1539 $blogId = (int)$fields[
"BLOG_ID"];
1540 $siteId = $fields[
"SITE_ID"];
1541 $sonetRights = $fields[
"SONET_RIGHTS"];
1542 $newRights = $fields[
"NEW_RIGHTS"];
1543 $userId = (int)$fields[
"USER_ID"];
1545 $clearCommentsCache = (!isset($params[
'CLEAR_COMMENTS_CACHE']) || $params[
'CLEAR_COMMENTS_CACHE'] !==
'N');
1551 Loader::includeModule(
'blog')
1552 && \CBlogPost::update($postId, array(
"SOCNET_RIGHTS" => $sonetRights,
"HAS_SOCNET_ALL" =>
"N"))
1555 BXClearCache(
true, self::getBlogPostCacheDir(array(
1557 'POST_ID' => $postId
1559 BXClearCache(
true, self::getBlogPostCacheDir(array(
1560 'TYPE' =>
'post_general',
1561 'POST_ID' => $postId
1563 BXClearCache(True, self::getBlogPostCacheDir(array(
1564 'TYPE' =>
'posts_popular',
1565 'SITE_ID' => $siteId
1568 $logSiteListNew = array();
1569 $user2NotifyList = array();
1570 $sonetPermissionList = \CBlogPost::getSocnetPermsName($postId);
1571 $extranet = Loader::includeModule(
"extranet");
1572 $extranetSite = ($extranet ? \CExtranet::getExtranetSiteID() :
false);
1573 $tzOffset = \CTimeZone::getOffset();
1575 $res = \CBlogPost::getList(
1577 array(
"ID" => $postId),
1580 array(
"ID",
"BLOG_ID",
"PUBLISH_STATUS",
"TITLE",
"AUTHOR_ID",
"ENABLE_COMMENTS",
"NUM_COMMENTS",
"VIEWS",
"CODE",
"MICRO",
"DETAIL_TEXT",
"DATE_PUBLISH",
"CATEGORY_ID",
"HAS_SOCNET_ALL",
"HAS_TAGS",
"HAS_IMAGES",
"HAS_PROPS",
"HAS_COMMENT_IMAGES")
1582 $post = $res->fetch();
1588 if (!empty($post[
'DETAIL_TEXT']))
1590 $post[
'DETAIL_TEXT'] = \Bitrix\Main\Text\Emoji::decode($post[
'DETAIL_TEXT']);
1593 $intranetUserIdList = ($extranet ? \CExtranet::getIntranetUsers() :
false);
1594 $auxLiveParamList = array();
1595 $sharedToIntranetUser =
false;
1597 foreach ($sonetPermissionList as $type => $v)
1603 && in_array($type . $vv[
"ENTITY_ID"], $newRights,
true)
1607 $renderData = $renderParts->getData($vv[
"ENTITY_ID"]);
1609 if($sonetGroup = \CSocNetGroup::getByID($vv[
"ENTITY_ID"]))
1611 $res = \CSocNetGroup::getSite($vv[
"ENTITY_ID"]);
1612 while ($groupSiteList = $res->fetch())
1614 $logSiteListNew[] = $groupSiteList[
"LID"];
1617 $auxLiveParamList[] = array(
1618 "ENTITY_TYPE" =>
'SG',
1619 "ENTITY_ID" => $renderData[
'id'],
1620 "NAME" => $renderData[
'name'],
1621 "LINK" => $renderData[
'link'],
1622 "VISIBILITY" => ($sonetGroup[
"VISIBLE"] ===
"Y" ?
"all" :
"group_members")
1626 elseif ($type ===
"U")
1629 in_array(
"US" . $vv[
"ENTITY_ID"], $vv[
"ENTITY"],
true)
1630 && in_array(
"UA", $newRights,
true)
1634 $renderData = $renderParts->getData(0);
1636 $auxLiveParamList[] = array(
1637 "ENTITY_TYPE" =>
'UA',
1638 "ENTITY_ID" =>
'UA',
1639 "NAME" => $renderData[
'name'],
1640 "LINK" => $renderData[
'link'],
1641 "VISIBILITY" =>
'all'
1644 elseif (in_array($type . $vv[
"ENTITY_ID"], $newRights,
true))
1647 $renderData = $renderParts->getData($vv[
"ENTITY_ID"]);
1649 $user2NotifyList[] = $vv[
"ENTITY_ID"];
1653 && is_array($intranetUserIdList)
1654 && !in_array($vv[
"ENTITY_ID"], $intranetUserIdList)
1657 $logSiteListNew[] = $extranetSite;
1658 $visibility =
'extranet';
1662 $sharedToIntranetUser =
true;
1663 $visibility =
'intranet';
1666 $auxLiveParamList[] = array(
1667 "ENTITY_TYPE" =>
'U',
1668 "ENTITY_ID" => $renderData[
'id'],
1669 "NAME" => $renderData[
'name'],
1670 "LINK" => $renderData[
'link'],
1671 "VISIBILITY" => $visibility
1677 && in_array($type.$vv[
"ENTITY_ID"], $newRights)
1681 $renderData = $renderParts->getData($vv[
"ENTITY_ID"]);
1683 $auxLiveParamList[] = array(
1684 "ENTITY_TYPE" =>
'DR',
1685 "ENTITY_ID" => $renderData[
'id'],
1686 "NAME" => $renderData[
'name'],
1687 "LINK" => $renderData[
'link'],
1688 "VISIBILITY" =>
'intranet'
1694 $userIP = \CBlogUser::getUserIP();
1695 $auxText = CommentAux\Share::getPostText();
1697 isset($params[
"MENTION"])
1698 && $params[
"MENTION"] ===
"Y"
1701 $commentFields = Array(
1702 "POST_ID" => $postId,
1703 "BLOG_ID" => $blogId,
1704 "POST_TEXT" => $auxText,
1705 "DATE_CREATE" => convertTimeStamp(time() + $tzOffset,
"FULL"),
1706 "AUTHOR_IP" => $userIP[0],
1707 "AUTHOR_IP1" => $userIP[1],
1708 "PARENT_ID" =>
false,
1709 "AUTHOR_ID" => $userId,
1710 "SHARE_DEST" => implode(
",", $newRights).($mention ?
'|mention' :
''),
1715 if($commentId = \CBlogComment::add($commentFields,
false))
1717 if ($clearCommentsCache)
1719 BXClearCache(
true, self::getBlogPostCacheDir(array(
1720 'TYPE' =>
'post_comments',
1721 'POST_ID' => $postId
1725 if ((
int)$post[
"AUTHOR_ID"] !== $userId)
1729 "TITLE" => htmlspecialcharsback($post[
"TITLE"]),
1730 "URL" => \CComponentEngine::makePathFromTemplate(
1731 htmlspecialcharsBack($params[
"PATH_TO_POST"]),
1733 "post_id" => $postId,
1734 "user_id" => $post[
"AUTHOR_ID"]
1738 "FROM_USER_ID" => $userId,
1739 "TO_USER_ID" => array($post[
"AUTHOR_ID"]),
1741 \CBlogPost::notifyIm($fieldsIM);
1742 $userIdSent[] = array_merge($userIdSent, $fieldsIM[
"TO_USER_ID"]);
1745 if(!empty($user2NotifyList))
1748 "TYPE" =>
"SHARE2USERS",
1749 "TITLE" => htmlspecialcharsback($post[
"TITLE"]),
1750 "URL" => \CComponentEngine::makePathFromTemplate(
1751 htmlspecialcharsBack($params[
"PATH_TO_POST"]),
1753 "post_id" => $postId,
1754 "user_id" => $post[
"AUTHOR_ID"]
1757 "FROM_USER_ID" => $userId,
1758 "TO_USER_ID" => $user2NotifyList,
1760 \CBlogPost::notifyIm($fieldsIM);
1761 $userIdSent[] = array_merge($userIdSent, $fieldsIM[
"TO_USER_ID"]);
1763 \CBlogPost::notifyMail(array(
1764 "type" =>
"POST_SHARE",
1765 "siteId" => $siteId,
1766 "userId" => $user2NotifyList,
1767 "authorId" => $userId,
1768 "postId" => $post[
"ID"],
1769 "postUrl" => \CComponentEngine::makePathFromTemplate(
1770 '/pub/post.php?post_id=#post_id#',
1772 "post_id"=> $post[
"ID"]
1779 $blogPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\BlogPost;
1782 $res = \CSocNetLog::getList(
1783 array(
"ID" =>
"DESC"),
1785 "EVENT_ID" => $blogPostLivefeedProvider->getEventId(),
1786 "SOURCE_ID" => $postId
1790 array(
"ID",
"ENTITY_TYPE",
"ENTITY_ID",
"USER_ID",
"EVENT_ID")
1792 if ($logEntry = $res->fetch())
1794 $logId = $logEntry[
"ID"];
1795 $logSiteList = array();
1796 $res = \CSocNetLog::getSite($logId);
1797 while ($logSite = $res->fetch())
1799 $logSiteList[] = $logSite[
"LID"];
1801 $logSiteListNew = array_unique(array_merge($logSiteListNew, $logSiteList));
1805 && $sharedToIntranetUser
1806 && count($logSiteListNew) == 1
1807 && $logSiteListNew[0] == $extranetSite
1810 $logSiteListNew[] = \CSite::getDefSite();
1814 'postId' => $postId,
1815 'authorId' => $post[
"AUTHOR_ID"]
1818 \CSocNetLogRights::deleteByLogID($logId);
1819 \CSocNetLogRights::add($logId, $socnetPerms,
true,
false);
1821 foreach($newRights as $GROUP_CODE)
1823 if (preg_match(
'/^U(\d+)$/', $GROUP_CODE, $matches))
1827 'userId' => $matches[1],
1828 'siteId' => $siteId,
1829 'typeList' => array(
1831 'COUNTER_COMMENT_PUSH'
1833 'followDate' =>
'CURRENT'
1838 if (count(array_diff($logSiteListNew, $logSiteList)) > 0)
1840 \CSocNetLog::update($logId, array(
1841 "ENTITY_TYPE" => $logEntry[
"ENTITY_TYPE"],
1842 "SITE_ID" => $logSiteListNew
1848 $connection = \Bitrix\Main\Application::getConnection();
1849 $helper = $connection->getSqlHelper();
1851 $logCommentFields = array(
1852 'ENTITY_TYPE' => SONET_ENTITY_USER,
1853 'ENTITY_ID' => $post[
"AUTHOR_ID"],
1854 'EVENT_ID' =>
'blog_comment',
1855 '=LOG_DATE' => $helper->getCurrentDateTimeFunction(),
1857 'USER_ID' => $userId,
1858 'MESSAGE' => $auxText,
1859 "TEXT_MESSAGE" => $auxText,
1860 'MODULE_ID' =>
false,
1861 'SOURCE_ID' => $commentId,
1862 'RATING_TYPE_ID' =>
'BLOG_COMMENT',
1863 'RATING_ENTITY_ID' => $commentId
1866 \CSocNetLogComments::add($logCommentFields,
false,
false);
1869 \CSocNetLogFollow::deleteByLogID($logId,
"Y",
true);
1874 'userId' => $userId,
1877 'COUNTER_COMMENT_PUSH',
1879 'followDate' =>
'CURRENT',
1884 foreach($newRights as $v)
1886 if(mb_substr($v, 0, 2) ===
"SG")
1888 $groupId = (int)mb_substr($v, 2);
1891 \CSocNetGroup::setLastActivity($groupId);
1896 \Bitrix\Blog\Broadcast::send(array(
1897 "EMAIL_FROM" => \COption::getOptionString(
"main",
"email_from",
"nobody@nobody.com"),
1898 "SOCNET_RIGHTS" => $newRights,
1899 "ENTITY_TYPE" =>
"POST",
1900 "ENTITY_ID" => $post[
"ID"],
1901 "AUTHOR_ID" => $post[
"AUTHOR_ID"],
1902 "URL" => \CComponentEngine::makePathFromTemplate(
1903 htmlspecialcharsBack($params[
"PATH_TO_POST"]),
1905 "post_id" => $post[
"ID"],
1906 "user_id" => $post[
"AUTHOR_ID"]
1909 "EXCLUDE_USERS" => $userIdSent
1914 \Bitrix\Main\FinderDestTable::merge(array(
1915 "CONTEXT" =>
"blog_post",
1920 if (\
Bitrix\Main\Loader::includeModule(
'crm'))
1922 \CCrmLiveFeedComponent::processCrmBlogPostRights($logId, $logEntry, $post,
'share');
1928 !isset($params[
"LIVE"])
1929 || $params[
"LIVE"] !==
"N"
1933 $provider = \Bitrix\Socialnetwork\CommentAux\Base::init(\
Bitrix\Socialnetwork\CommentAux\Share::getType(), array(
1934 'liveParamList' => $auxLiveParamList
1937 \CBlogComment::addLiveComment($commentId, array(
1938 "PATH_TO_USER" => $params[
"PATH_TO_USER"],
1939 "PATH_TO_POST" => \CComponentEngine::makePathFromTemplate(
1940 htmlspecialcharsBack($params[
"PATH_TO_POST"]),
1942 "post_id" => $post[
"ID"],
1943 "user_id" => $post[
"AUTHOR_ID"]
1946 "LOG_ID" => ($logId ? (
int)$logId : 0),
1948 "AUX_LIVE_PARAMS" => $provider->getLiveParams(),
1949 "CAN_USER_COMMENT" => (!empty($params[
"CAN_USER_COMMENT"]) && $params[
"CAN_USER_COMMENT"] ===
'Y' ?
'Y' :
'N')
1962 isset($_GET[
"entityType"])
1963 && $_GET[
"entityType"] <>
''
1966 $result[
"ENTITY_TYPE"] = $_GET[
"entityType"];
1970 isset($_GET[
"entityId"])
1971 && (
int)$_GET[
"entityId"] > 0
1974 $result[
"ENTITY_ID"] = (int)$_GET[
"entityId"];
1986 && !empty($context[
"ENTITY_TYPE"])
1987 && !empty($context[
"ENTITY_ID"])
1990 $result = $url.(mb_strpos($url,
'?') ===
false ?
'?' :
'&').
'entityType='.$context[
"ENTITY_TYPE"].
'&entityId='.$context[
"ENTITY_ID"];
1998 if (!is_array($authIdList))
2000 $authIdList = array($authIdList);
2003 foreach($authIdList as $key => $authId)
2006 $authId ===
'replica'
2007 && !ModuleManager::isModuleInstalled(
"replica")
2010 unset($authIdList[$key]);
2014 $authId ===
'imconnector'
2015 && !ModuleManager::isModuleInstalled(
"imconnector")
2018 unset($authIdList[$key]);
2023 && !ModuleManager::isModuleInstalled(
"im")
2026 unset($authIdList[$key]);
2031 && !ModuleManager::isModuleInstalled(
"mail")
2034 unset($authIdList[$key]);
2038 in_array($authId, [
'sale',
'shop' ])
2039 && !ModuleManager::isModuleInstalled(
"sale")
2042 unset($authIdList[$key]);
2051 $optionValue = Option::get(
'socialnetwork',
'is_used',
false);
2055 Option::set(
'socialnetwork',
'is_used',
true);
2061 return (
bool)Option::get(
'socialnetwork',
'is_used',
false);
2066 if (!is_array($list))
2071 $siteId = (!empty($params[
"SITE_ID"]) ? $params[
"SITE_ID"] : SITE_ID);
2072 $sefFolder = (!empty($params[
"SEF_FOLDER"]) ? $params[
"SEF_FOLDER"] :
false);
2074 foreach ($list as $value)
2077 empty($value[
"OPTION"])
2078 || empty($value[
"OPTION"][
"MODULE_ID"])
2079 || empty($value[
"OPTION"][
"NAME"])
2080 || empty($value[
"VALUE"])
2086 $optionValue = Option::get($value[
"OPTION"][
"MODULE_ID"], $value[
"OPTION"][
"NAME"],
false, $siteId);
2091 !!($value[
"CHECK_SEF_FOLDER"] ??
false)
2093 && mb_substr($optionValue, 0, mb_strlen($sefFolder)) !== $sefFolder
2097 Option::set($value[
"OPTION"][
"MODULE_ID"], $value[
"OPTION"][
"NAME"], $value[
"VALUE"], $siteId);
2108 $currentUserId = $USER->getId();
2109 $limit = (isset($params[
'limit']) && (int)$params[
'limit'] > 0 ? (
int)$params[
'limit'] : 500);
2110 $useProjects = (!empty($params[
'useProjects']) && $params[
'useProjects'] ===
'Y' ?
'Y' :
'N');
2111 $siteId = (!empty($params[
'siteId']) ? $params[
'siteId'] : SITE_ID);
2112 $landing = (!empty($params[
'landing']) && $params[
'landing'] ===
'Y' ?
'Y' :
'');
2114 $currentCache = \Bitrix\Main\Data\Cache::createInstance();
2116 $cacheTtl = defined(
"BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
2117 $cacheId =
'dest_group_'.$siteId.
'_'.$currentUserId.
'_'.$limit.$useProjects.$landing;
2118 $cacheDir =
'/sonet/dest_sonet_groups/'.$siteId.
'/'.$currentUserId;
2120 if($currentCache->startDataCache($cacheTtl, $cacheId, $cacheDir))
2122 global $CACHE_MANAGER;
2124 $limitReached =
false;
2127 'features' => array(
"blog", array(
"premoderate_post",
"moderate_post",
"write_post",
"full_post")),
2129 'useProjects' => $useProjects,
2130 'site_id' => $siteId,
2133 if ($landing ===
'Y')
2135 $filter[
'landing'] =
'Y';
2138 $groupList = \CSocNetLogDestination::getSocnetGroup($filter, $limitReached);
2140 if(defined(
"BX_COMP_MANAGED_CACHE"))
2142 $CACHE_MANAGER->startTagCache($cacheDir);
2143 foreach($groupList as $group)
2145 $CACHE_MANAGER->registerTag(
"sonet_features_G_".$group[
"entityId"]);
2146 $CACHE_MANAGER->registerTag(
"sonet_group_".$group[
"entityId"]);
2148 $CACHE_MANAGER->registerTag(
"sonet_user2group_U".$currentUserId);
2149 if ($landing ===
'Y')
2151 $CACHE_MANAGER->registerTag(
"sonet_group");
2153 $CACHE_MANAGER->endTagCache();
2155 $currentCache->endDataCache(array(
2156 'groups' => $groupList,
2157 'limitReached' => $limitReached
2162 $tmp = $currentCache->getVars();
2163 $groupList = $tmp[
'groups'];
2164 $limitReached = $tmp[
'limitReached'];
2169 && \CSocNetUser::isCurrentUserModuleAdmin()
2172 $limitReached =
true;
2178 public static function canAddComment($logEntry = array(), $commentEvent = array())
2180 $canAddComments =
false;
2185 !is_array($logEntry)
2186 && (
int)$logEntry > 0
2189 $res = \CSocNetLog::getList(
2192 "ID" => (
int)$logEntry
2196 array(
"ID",
"ENTITY_TYPE",
"ENTITY_ID",
"EVENT_ID",
"USER_ID")
2199 if (!($logEntry = $res->fetch()))
2201 return $canAddComments;
2206 !is_array($logEntry)
2208 || empty($logEntry[
"EVENT_ID"])
2211 return $canAddComments;
2215 !is_array($commentEvent)
2216 || empty($commentEvent)
2219 $commentEvent = \CSocNetLogTools::findLogCommentEventByLogEventID($logEntry[
"EVENT_ID"]);
2222 if (is_array($commentEvent))
2224 $feature = \CSocNetLogTools::findFeatureByEventID($commentEvent[
"EVENT_ID"]);
2227 array_key_exists(
"OPERATION_ADD", $commentEvent)
2228 && $commentEvent[
"OPERATION_ADD"] ===
"log_rights"
2231 $canAddComments = \CSocNetLogRights::checkForUser($logEntry[
"ID"], $USER->getID());
2235 && array_key_exists(
"OPERATION_ADD", $commentEvent)
2236 && $commentEvent[
"OPERATION_ADD"] <>
''
2239 $canAddComments = \CSocNetFeaturesPerms::canPerformOperation(
2241 $logEntry[
"ENTITY_TYPE"],
2242 $logEntry[
"ENTITY_ID"],
2243 ($feature ===
"microblog" ?
"blog" : $feature),
2244 $commentEvent[
"OPERATION_ADD"],
2245 \CSocNetUser::isCurrentUserModuleAdmin()
2250 $canAddComments =
true;
2254 return $canAddComments;
2257 public static function addLiveComment($comment = [], $logEntry = [], $commentEvent = [], $params = []): array
2259 global $USER_FIELD_MANAGER;
2266 || !is_array($logEntry)
2268 || !is_array($commentEvent)
2269 || empty($commentEvent)
2275 $aux = !empty($params[
'AUX']);
2278 !isset($params[
"ACTION"])
2279 || !in_array($params[
"ACTION"], array(
"ADD",
"UPDATE"))
2282 $params[
"ACTION"] =
"ADD";
2286 !isset($params[
"LANGUAGE_ID"])
2287 || empty($params[
"LANGUAGE_ID"])
2290 $params[
"LANGUAGE_ID"] = LANGUAGE_ID;
2294 !isset($params[
"SITE_ID"])
2295 || empty($params[
"SITE_ID"])
2298 $params[
"SITE_ID"] = SITE_ID;
2301 if ($params[
"ACTION"] ===
"ADD")
2304 !empty($commentEvent)
2305 && !empty($commentEvent[
"METHOD_CANEDIT"])
2306 && !empty($comment[
"SOURCE_ID"])
2307 && (
int)$comment[
"SOURCE_ID"] > 0
2308 && !empty($logEntry[
"SOURCE_ID"])
2309 && (
int)$logEntry[
"SOURCE_ID"] > 0
2312 $canEdit = call_user_func($commentEvent[
"METHOD_CANEDIT"], array(
2313 "LOG_SOURCE_ID" => $logEntry[
"SOURCE_ID"],
2314 "COMMENT_SOURCE_ID" => $comment[
"SOURCE_ID"],
2315 "USER_ID" => $comment[
"USER_ID"]
2324 $result[
"hasEditCallback"] = (
2326 && is_array($commentEvent)
2327 && isset($commentEvent[
"UPDATE_CALLBACK"])
2329 $commentEvent[
"UPDATE_CALLBACK"] ===
"NO_SOURCE"
2330 || is_callable($commentEvent[
"UPDATE_CALLBACK"])
2336 $result[
"hasDeleteCallback"] = (
2338 && is_array($commentEvent)
2339 && isset($commentEvent[
"DELETE_CALLBACK"])
2341 $commentEvent[
"DELETE_CALLBACK"] ===
"NO_SOURCE"
2342 || is_callable($commentEvent[
"DELETE_CALLBACK"])
2349 !isset($params[
"SOURCE_ID"])
2350 || (int)$params[
"SOURCE_ID"] <= 0
2353 foreach (EventManager::getInstance()->findEventHandlers(
'socialnetwork',
'OnAfterSonetLogEntryAddComment') as $handler)
2355 ExecuteModuleEventEx($handler, array($comment));
2359 $result[
"arComment"] = $comment;
2360 foreach($result[
"arComment"] as $key => $value)
2362 if (mb_strpos($key,
"~") === 0)
2364 unset($result[
"arComment"][$key]);
2368 $result[
"arComment"][
"RATING_USER_HAS_VOTED"] =
"N";
2370 $result[
"sourceID"] = $comment[
"SOURCE_ID"];
2371 $result[
"timestamp"] = makeTimeStamp(
2372 array_key_exists(
"LOG_DATE_FORMAT", $comment)
2373 ? $comment[
"LOG_DATE_FORMAT"]
2374 : $comment[
"LOG_DATE"]
2377 $comment[
"UF"] = $USER_FIELD_MANAGER->getUserFields(
"SONET_COMMENT", $comment[
"ID"], LANGUAGE_ID);
2380 array_key_exists(
"UF_SONET_COM_DOC", $comment[
"UF"])
2381 && array_key_exists(
"VALUE", $comment[
"UF"][
"UF_SONET_COM_DOC"])
2382 && is_array($comment[
"UF"][
"UF_SONET_COM_DOC"][
"VALUE"])
2383 && count($comment[
"UF"][
"UF_SONET_COM_DOC"][
"VALUE"]) > 0
2384 && $commentEvent[
"EVENT_ID"] !==
"tasks_comment"
2387 $logEntryRights = array();
2388 $res = \CSocNetLogRights::getList(array(), array(
"LOG_ID" => $logEntry[
"ID"]));
2389 while ($right = $res->fetch())
2391 $logEntryRights[] = $right[
"GROUP_CODE"];
2394 \CSocNetLogTools::setUFRights($comment[
"UF"][
"UF_SONET_COM_DOC"][
"VALUE"], $logEntryRights);
2397 $result[
'timeFormatted'] = formatDateFromDB(
2398 ($comment[
'LOG_DATE_FORMAT'] ?? $comment[
'LOG_DATE']),
2399 self::getTimeFormat($params[
'TIME_FORMAT'])
2402 $authorFields = self::getAuthorData([
2403 'userId' => $comment[
'USER_ID'],
2405 $createdBy = self::getCreatedByData([
2406 'userFields' => $authorFields,
2407 'languageId' => $params[
'LANGUAGE_ID'],
2408 'nameTemplate' => $params[
'NAME_TEMPLATE'],
2409 'showLogin' => $params[
'SHOW_LOGIN'],
2410 'pathToUser' => $params[
'PATH_TO_USER'],
2413 $commentFormatted = array(
2414 'LOG_DATE' => $comment[
"LOG_DATE"],
2415 "LOG_DATE_FORMAT" => $comment[
"LOG_DATE_FORMAT"] ??
null,
2416 "LOG_DATE_DAY" => ConvertTimeStamp(MakeTimeStamp($comment[
'LOG_DATE']),
'SHORT'),
2417 'LOG_TIME_FORMAT' => $result[
'timeFormatted'],
2418 "MESSAGE" => $comment[
"MESSAGE"],
2419 "MESSAGE_FORMAT" => $comment[
"~MESSAGE"] ??
null,
2420 'CREATED_BY' => $createdBy,
2421 "AVATAR_SRC" => \CSocNetLogTools::formatEvent_CreateAvatar($authorFields, $params,
""),
2422 'USER_ID' => $comment[
'USER_ID'],
2426 array_key_exists(
"CLASS_FORMAT", $commentEvent)
2427 && array_key_exists(
"METHOD_FORMAT", $commentEvent)
2430 $fieldsFormatted = call_user_func(
2431 array($commentEvent[
"CLASS_FORMAT"], $commentEvent[
"METHOD_FORMAT"]),
2435 $commentFormatted[
"MESSAGE_FORMAT"] = htmlspecialcharsback($fieldsFormatted[
"EVENT_FORMATTED"][
"MESSAGE"]);
2439 $commentFormatted[
"MESSAGE_FORMAT"] = $comment[
"MESSAGE"];
2443 array_key_exists(
"CLASS_FORMAT", $commentEvent)
2444 && array_key_exists(
"METHOD_FORMAT", $commentEvent)
2447 $fieldsFormatted = call_user_func(
2448 array($commentEvent[
"CLASS_FORMAT"], $commentEvent[
"METHOD_FORMAT"]),
2457 $messageMobile = htmlspecialcharsback($fieldsFormatted[
"EVENT_FORMATTED"][
"MESSAGE"]);
2461 $messageMobile = $comment[
"MESSAGE"];
2464 $result[
"arCommentFormatted"] = $commentFormatted;
2467 isset($params[
"PULL"])
2468 && $params[
"PULL"] ===
"Y"
2472 'ID' => $logEntry[
'ID'],
2473 'EVENT_ID' => $logEntry[
'EVENT_ID'],
2474 'ENTITY_TYPE' => $logEntry[
'ENTITY_TYPE'],
2475 'ENTITY_ID' => $logEntry[
'ENTITY_ID'],
2476 'SOURCE_ID' => $logEntry[
'SOURCE_ID'],
2477 'PARAMS' => $logEntry[
'PARAMS'] ??
null
2480 $entityXMLId = $liveFeedCommentsParams[
'ENTITY_XML_ID'];
2483 !!$comment[
"SOURCE_ID"]
2484 ? $comment[
"SOURCE_ID"]
2488 $eventHandlerID = EventManager::getInstance()->addEventHandlerCompatible(
"main",
"system.field.view.file", array(
"CSocNetLogTools",
"logUFfileShow"));
2489 $rights = \CSocNetLogComponent::getCommentRights([
2490 'EVENT_ID' => $logEntry[
'EVENT_ID'],
2491 'SOURCE_ID' => $logEntry[
'SOURCE_ID'],
2492 'USER_ID' => $comment[
'USER_ID']
2495 $postContentTypeId =
'';
2496 $commentContentTypeId =
'';
2498 $postContentId = \Bitrix\Socialnetwork\Livefeed\Provider::getContentId($logEntry);
2499 $canGetCommentContent =
false;
2502 !empty($postContentId[
'ENTITY_TYPE'])
2503 && ($postProvider = \
Bitrix\Socialnetwork\Livefeed\Provider::getProvider($postContentId[
'ENTITY_TYPE']))
2504 && ($commentProvider = $postProvider->getCommentProvider())
2507 $postContentTypeId = $postProvider->getContentTypeId();
2508 $commentProviderClassName = get_class($commentProvider);
2509 $reflectionClass = new \ReflectionClass($commentProviderClassName);
2511 $canGetCommentContent = ($reflectionClass->getMethod(
'initSourceFields')->class == $commentProviderClassName);
2512 if ($canGetCommentContent)
2514 $commentContentTypeId = $commentProvider->getContentTypeId();
2518 $records = static::getLiveCommentRecords([
2519 'commentId' => $listCommentId,
2520 'ratingTypeId' => $comment[
'RATING_TYPE_ID'],
2521 'timestamp' => $result[
'timestamp'],
2523 'ID' => $authorFields[
'ID'],
2524 'NAME' => $authorFields[
'NAME'],
2525 'LAST_NAME' => $authorFields[
'LAST_NAME'],
2526 'SECOND_NAME' => $authorFields[
'SECOND_NAME'],
2527 'PERSONAL_GENDER' => $authorFields[
'PERSONAL_GENDER'],
2528 'AVATAR' => $commentFormatted[
'AVATAR_SRC'],
2530 'uf' => $comment[
'UF'],
2531 'ufFormatted' => $commentFormatted[
'UF'] ??
null,
2532 'postMessageTextOriginal' => $comment[
'~MESSAGE'] ??
null,
2533 'postMessageTextFormatted' => $commentFormatted[
'MESSAGE_FORMAT'],
2534 'mobileMessage' => $messageMobile,
2535 'aux' => ($params[
'AUX'] ??
''),
2536 'auxLiveParams' => ($params[
'AUX_LIVE_PARAMS'] ?? []),
2539 $viewUrl = (string)($comment[
'EVENT'][
'URL'] ??
'');
2540 if (empty($viewUrl))
2542 $pathToLogEntry = (string)($params[
'PATH_TO_LOG_ENTRY'] ??
'');
2543 if (!empty($pathToLogEntry))
2545 $viewUrl = \CComponentEngine::makePathFromTemplate(
2548 'log_id' => $logEntry[
'ID']
2550 ) . (mb_strpos($pathToLogEntry,
'?') ===
false ?
'?' :
'&') .
'commentId=#ID#';
2554 $rights[
'COMMENT_RIGHTS_CREATETASK'] = (
2555 $canGetCommentContent
2556 && ModuleManager::isModuleInstalled(
'tasks')
2561 $res = static::sendLiveComment([
2562 'ratingTypeId' => $comment[
'RATING_TYPE_ID'],
2563 'entityXMLId' => $entityXMLId,
2564 'postContentTypeId' => $postContentTypeId,
2565 'commentContentTypeId' => $commentContentTypeId,
2566 'records' => $records,
2567 'rights' => $rights,
2568 'commentId' => $listCommentId,
2569 'action' => ($params[
'ACTION'] ===
'UPDATE' ?
'EDIT' :
'REPLY'),
2572 'edit' =>
"__logEditComment('" . $entityXMLId .
"', '#ID#', '" . $logEntry[
"ID"] .
"');",
2573 'delete' =>
'/bitrix/components/bitrix/socialnetwork.log.entry/ajax.php?lang=' . $params[
'LANGUAGE_ID'] .
'&action=delete_comment&delete_comment_id=#ID#&post_id=' . $logEntry[
'ID'] .
'&site=' . $params[
'SITE_ID'],
2575 'avatarSize' => $params[
'AVATAR_SIZE_COMMENT'] ??
null,
2576 'nameTemplate' => $params[
'NAME_TEMPLATE'],
2577 'dateTimeFormat' => $params[
'DATE_TIME_FORMAT'] ??
null,
2580 if ($eventHandlerID > 0)
2582 EventManager::getInstance()->removeEventHandler(
'main',
'system.field.view.file', $eventHandlerID);
2585 $result[
'return_data'] = $res[
'JSON'];
2593 global $USER_FIELD_MANAGER, $APPLICATION, $USER;
2595 $siteId = (string)($params[
'siteId'] ?? SITE_ID);
2596 $languageId = (string)($params[
'siteId'] ?? LANGUAGE_ID);
2597 $entityXmlId = (string)($params[
'entityXmlId'] ??
'');
2598 $nameTemplate = (string)($params[
'nameTemplate'] ??
'');
2599 $showLogin = (string)($params[
'showLogin'] ??
'N');
2600 $pathToUser = (string)($params[
'pathToUser'] ??
'');
2601 $avatarSize = (int)($params[
'avatarSize'] ?? 100);
2603 $postProvider = $params[
'postProvider'];
2604 $commentProvider = $params[
'commentProvider'];
2608 || !$commentProvider
2614 $commentId = $commentProvider->getEntityId();
2615 $ratingTypeId = $commentProvider->getRatingTypeId();
2616 $commentDateTime = $commentProvider->getSourceDateTime();
2617 $commentAuthorId = $commentProvider->getSourceAuthorId();
2618 $commentText = $commentProvider->getSourceDescription();
2619 $userTypeEntityId = $commentProvider->getUserTypeEntityId();
2620 $commentContentTypeId = $commentProvider->getContentTypeId();
2622 $postContentTypeId = $postProvider->getContentTypeId();
2624 $timestamp = ($commentDateTime ? makeTimeStamp($commentDateTime) : 0);
2626 if (!empty($userTypeEntityId))
2628 $comment[
'UF'] = $USER_FIELD_MANAGER->getUserFields($userTypeEntityId, $commentId, $languageId);
2631 $timeFormatted = formatDateFromDB($commentDateTime, self::getTimeFormat());
2633 $authorFields = self::getAuthorData([
2634 'userId' => $commentAuthorId,
2637 $createdBy = self::getCreatedByData([
2638 'userFields' => $authorFields,
2639 'languageId' => $languageId,
2640 'nameTemplate' => $nameTemplate,
2641 'showLogin' => $showLogin,
2642 'pathToUser' => $pathToUser,
2645 $commentFormatted = [
2646 'LOG_DATE' => $commentDateTime->toString(),
2647 "LOG_DATE_FORMAT" => $comment[
"LOG_DATE_FORMAT"],
2648 'LOG_DATE_DAY' => convertTimeStamp($timestamp,
'SHORT'),
2649 'LOG_TIME_FORMAT' => $timeFormatted,
2650 'MESSAGE' => $commentText,
2651 'MESSAGE_FORMAT' => $commentText,
2652 'CREATED_BY' => $createdBy,
2653 'AVATAR_SRC' => \CSocNetLogTools::formatEvent_CreateAvatar($authorFields, [
2654 'AVATAR_SIZE' => $avatarSize,
2656 'USER_ID' => $commentAuthorId,
2661 && $commentProvider->getContentTypeId() === Livefeed\ForumPost::CONTENT_TYPE_ID
2664 $feedParams = $commentProvider->getFeedParams();
2665 if (!empty($feedParams[
'xml_id']))
2667 $entityXmlId = $feedParams[
'xml_id'];
2671 if (empty($entityXmlId))
2677 'COMMENT_RIGHTS_EDIT' =>
'N',
2678 'COMMENT_RIGHTS_DELETE' =>
'N',
2679 'COMMENT_RIGHTS_CREATETASK' =>
'N'
2682 $records = static::getLiveCommentRecords([
2683 'commentId' => $commentId,
2684 'ratingTypeId' => $ratingTypeId,
2685 'timestamp' => $timestamp,
2687 'ID' => $authorFields[
'ID'],
2688 'NAME' => $authorFields[
'NAME'],
2689 'LAST_NAME' => $authorFields[
'LAST_NAME'],
2690 'SECOND_NAME' => $authorFields[
'SECOND_NAME'],
2691 'PERSONAL_GENDER' => $authorFields[
'PERSONAL_GENDER'],
2692 'AVATAR' => $commentFormatted[
'AVATAR_SRC'],
2694 'uf' => $comment[
'UF'],
2695 'ufFormatted' => $commentFormatted[
'UF'],
2696 'postMessageTextOriginal' => $comment[
'~MESSAGE'],
2697 'postMessageTextFormatted' => $commentFormatted[
'MESSAGE_FORMAT'],
2698 'mobileMessage' => $commentText,
2699 'aux' => ($params[
'aux'] ??
''),
2700 'auxLiveParams' => ($params[
'auxLiveParams'] ?? []),
2718 $res = static::sendLiveComment([
2719 'ratingTypeId' => $ratingTypeId,
2720 'entityXMLId' => $entityXmlId,
2721 'postContentTypeId' => $postContentTypeId,
2722 'commentContentTypeId' => $commentContentTypeId,
2723 'records' => $records,
2724 'rights' => $rights,
2725 'commentId' => $commentId,
2726 'action' =>
'REPLY',
2732 'avatarSize' => $avatarSize,
2733 'nameTemplate' => $nameTemplate,
2738 private static function getAuthorData(array $params = []): array
2740 $userId = (int)($params[
'userId'] ?? 0);
2747 $res = Main\UserTable::getList([
2751 'select' => [
'ID',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'LOGIN',
'PERSONAL_PHOTO',
'PERSONAL_GENDER' ]
2754 if ($userFields = $res->fetch())
2756 $result = $userFields;
2767 private static function getCreatedByData(array $params = []): array
2769 $userFields = (array)($params[
'userFields'] ?? []);
2770 $languageId = ($params[
'languageId'] ??
null);
2771 $nameTemplate = (string)($params[
'nameTemplate'] ??
'');
2772 $showLogin = (string)($params[
'showLogin'] ??
'N');
2773 $pathToUser = (string)($params[
'pathToUser'] ??
'');
2775 if (!empty($userFields))
2778 'FORMATTED' => \CUser::formatName($nameTemplate, $userFields, ($showLogin !==
'N')),
2779 'URL' => \CComponentEngine::makePathFromTemplate(
2782 'user_id' => $userFields[
'ID'],
2783 'id' => $userFields[
'ID'],
2791 'FORMATTED' =>
Loc::getMessage(
'SONET_HELPER_CREATED_BY_ANONYMOUS',
false, $languageId)
2799 private static function getTimeFormat($siteTimeFormat =
''): string
2801 if (empty($siteTimeFormat))
2803 $siteTimeFormat = \CSite::getTimeFormat();
2807 mb_stripos($siteTimeFormat,
'a')
2809 $siteTimeFormat ===
'FULL'
2811 mb_strpos(FORMAT_DATETIME,
'T') !==
false
2812 || mb_strpos(FORMAT_DATETIME,
'TT') !==
false
2815 ? (mb_strpos(FORMAT_DATETIME,
'TT') !==
false ?
'H:MI TT' :
'H:MI T')
2820 private static function getLiveCommentRecords(array $params = []): array
2822 $commentId = (int)($params[
'commentId'] ?? 0);
2823 $ratingTypeId = (string)($params[
'ratingTypeId'] ??
'');
2824 $timestamp = (int)($params[
'timestamp'] ?? 0);
2825 $author = (array)($params[
'author'] ?? []);
2826 $uf = (array)($params[
'uf'] ?? []);
2827 $ufFormatted = (string)($params[
'ufFormatted'] ??
'');
2828 $postMessageTextOriginal = (string)($params[
'postMessageTextOriginal'] ??
'');
2829 $postMessageTextFormatted = (string)($params[
'postMessageTextFormatted'] ??
'');
2830 $mobileMessage = (string)($params[
'mobileMessage'] ??
'');
2831 $aux = (string)($params[
'aux'] ??
'');
2832 $auxLiveParams = (array)($params[
'auxLiveParams'] ?? []);
2837 'RATING_VOTE_ID' => $ratingTypeId .
'_' . $commentId .
'-' . (time() + random_int(0, 1000)),
2839 'POST_TIMESTAMP' => $timestamp,
2840 'AUTHOR' => $author,
2843 '~POST_MESSAGE_TEXT' => $postMessageTextOriginal,
2846 'POST_MESSAGE_TEXT' => $postMessageTextFormatted,
2847 'AFTER' => $ufFormatted,
2851 'POST_MESSAGE_TEXT' => $mobileMessage
2854 'AUX_LIVE_PARAMS' => $auxLiveParams,
2860 && !empty($uf[
'UF_SONET_COM_DOC'])
2861 && !empty($uf[
'UF_SONET_COM_DOC'][
'VALUE'])
2865 $inlineDiskAttachedObjectIdImageList = self::getInlineDiskImages([
2866 'text' => $postMessageTextOriginal,
2867 'commentId' => $commentId,
2870 if (!empty($inlineDiskAttachedObjectIdImageList))
2872 $records[$commentId][
'WEB'][
'UF'] = $records[$commentId][
'UF'];
2873 $records[$commentId][
'MOBILE'][
'UF'] = $records[$commentId][
'UF'];
2874 $records[$commentId][
'MOBILE'][
'UF'][
'UF_SONET_COM_DOC'][
'VALUE'] = array_diff($records[$commentId][
'MOBILE'][
'UF'][
'UF_SONET_COM_DOC'][
'VALUE'], $inlineDiskAttachedObjectIdImageList);
2881 private static function sendLiveComment(array $params = []): array
2883 global $APPLICATION;
2885 $ratingTypeId = (string)($params[
'ratingTypeId'] ??
'');
2886 $entityXMLId = (string)($params[
'entityXMLId'] ??
'');
2887 $postContentTypeId = (string)($params[
'postContentTypeId'] ??
'');
2888 $commentContentTypeId = (string)($params[
'commentContentTypeId'] ??
'');
2889 $records = (array)($params[
'records'] ?? []);
2890 $rights = (array)($params[
'rights'] ?? []);
2891 $commentId = (int)($params[
'commentId'] ?? 0);
2892 $action = (string)($params[
'action'] ??
'');
2893 $urlList = (array)($params[
'urlList'] ?? []);
2894 $avatarSize = (int)($params[
'avatarSize'] ?? 0);
2895 $nameTemplate = (string)($params[
'nameTemplate'] ??
'');
2896 $showLogin = (isset($params[
'showLogin']) && $params[
'showLogin'] ===
'Y' ?
'Y' :
'N');
2897 $dateTimeFormat = (string)($params[
'dateTimeFormat'] ??
'');
2899 return $APPLICATION->includeComponent(
2900 'bitrix:main.post.list',
2903 'TEMPLATE_ID' =>
'',
2904 'RATING_TYPE_ID' => $ratingTypeId,
2905 'ENTITY_XML_ID' => $entityXMLId,
2906 'POST_CONTENT_TYPE_ID' => $postContentTypeId,
2907 'COMMENT_CONTENT_TYPE_ID' => $commentContentTypeId,
2908 'RECORDS' => $records,
2914 'EDIT' => $rights[
'COMMENT_RIGHTS_EDIT'],
2915 'DELETE' => $rights[
'COMMENT_RIGHTS_DELETE'],
2916 'CREATETASK' => $rights[
'COMMENT_RIGHTS_CREATETASK'],
2918 'VISIBLE_RECORDS_COUNT' => 1,
2919 'ERROR_MESSAGE' =>
'',
2921 'RESULT' => $commentId,
2923 'ACTION' => $action,
2926 'MODE' =>
'PULL_MESSAGE',
2927 'VIEW_URL' => ($urlList[
'view'] ??
''),
2928 'EDIT_URL' => ($urlList[
'edit'] ??
''),
2929 'MODERATE_URL' =>
'',
2930 'DELETE_URL' => ($urlList[
'delete'] ??
''),
2932 'AVATAR_SIZE' => $avatarSize,
2933 'NAME_TEMPLATE' => $nameTemplate,
2934 'SHOW_LOGIN' => $showLogin,
2935 'DATE_TIME_FORMAT' => $dateTimeFormat,
2938 'NOTIFY_TEXT' =>
'',
2939 'SHOW_MINIMIZED' =>
'Y',
2940 'SHOW_POST_FORM' =>
'Y',
2950 private static function getInlineDiskImages(array $params = []): array
2954 $text = (string)($params[
'text'] ??
'');
2955 $commentId = (int)($params[
'commentId'] ?? 0);
2960 || !ModuleManager::isModuleInstalled(
'disk')
2966 $inlineDiskObjectIdList = [];
2967 $inlineDiskAttachedObjectIdList = [];
2970 if (preg_match_all(
'#\\[disk file id=(n\\d+)\\]#is' . BX_UTF_PCRE_MODIFIER, $text, $matches))
2972 $inlineDiskObjectIdList = array_map(
function($a) {
return (
int)mb_substr($a, 1); }, $matches[1]);
2976 if (preg_match_all(
'#\\[disk file id=(\\d+)\\]#is' . BX_UTF_PCRE_MODIFIER, $text, $matches))
2978 $inlineDiskAttachedObjectIdList = array_map(
function($a) {
return (
int)$a; }, $matches[1]);
2983 empty($inlineDiskObjectIdList)
2984 && empty($inlineDiskAttachedObjectIdList)
2986 || !Loader::includeModule(
'disk')
2993 '=OBJECT.TYPE_FILE' => TypeFile::IMAGE
2997 if (!empty($inlineDiskObjectIdList))
2999 $subFilter[
'@OBJECT_ID'] = $inlineDiskObjectIdList;
3001 elseif (!empty($inlineDiskAttachedObjectIdList))
3003 $subFilter[
'@ID'] = $inlineDiskAttachedObjectIdList;
3006 if(count($subFilter) > 1)
3008 $subFilter[
'LOGIC'] =
'OR';
3009 $filter[] = $subFilter;
3013 $filter = array_merge($filter, $subFilter);
3016 $res = \Bitrix\Disk\Internals\AttachedObjectTable::getList([
3017 'filter' => $filter,
3018 'select' => array(
'ID',
'ENTITY_ID')
3021 while ($attachedObjectFields = $res->fetch())
3023 if ((
int)$attachedObjectFields[
'ENTITY_ID'] === $commentId)
3025 $result[] = (int)$attachedObjectFields[
'ID'];
3035 empty($HTTPPost[
"SPERM"])
3036 || empty($HTTPPost[
"SPERM"][
"UE"])
3037 || !is_array($HTTPPost[
"SPERM"][
"UE"])
3043 $nameFormat = \CSite::getNameFormat(
false);
3044 foreach ($HTTPPost[
"SPERM"][
"UE"] as $invitedEmail)
3046 $name = (!empty($HTTPPost[
"INVITED_USER_NAME"][$invitedEmail]) ? $HTTPPost[
"INVITED_USER_NAME"][$invitedEmail] :
'');
3047 $lastName = (!empty($HTTPPost[
"INVITED_USER_LAST_NAME"][$invitedEmail]) ? $HTTPPost[
"INVITED_USER_LAST_NAME"][$invitedEmail] :
'');
3049 $createCrmContact = (
3050 !empty($HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"][$invitedEmail])
3051 && $HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"][$invitedEmail] ===
'Y'
3054 $userName = \CUser::formatName(
3055 empty($componentParams[
"NAME_TEMPLATE"]) ? $nameFormat : $componentParams[
"NAME_TEMPLATE"],
3058 'LAST_NAME' => $lastName,
3059 'LOGIN' => $invitedEmail
3065 $componentResult[
"PostToShow"][
"FEED_DESTINATION"][
'USERS'][$invitedEmail] = [
3066 'id' => $invitedEmail,
3067 'email' => $invitedEmail,
3069 'name' => $userName,
3071 'isCrmEmail' => ($createCrmContact ?
'Y' :
'N'),
3074 'lastName' => $lastName,
3075 'createCrmContact' => $createCrmContact,
3078 $componentResult[
"PostToShow"][
"FEED_DESTINATION"][
'SELECTED'][$invitedEmail] =
'users';
3085 if (isset($HTTPPost[
'SONET_PERMS']))
3087 $HTTPPost[
'SPERM'] = $HTTPPost[
'SONET_PERMS'];
3095 $HTTPPost[
'SONET_PERMS'] = $HTTPPost[
'SPERM'];
3096 unset($HTTPPost[
'SPERM']);
3100 private static function processUserEmail($params, &$errorText): array
3106 || empty($params[
'EMAIL'])
3107 || !check_email($params[
'EMAIL'])
3108 || !Loader::includeModule(
'mail')
3114 $userEmail = $params[
'EMAIL'];
3118 || !check_email($userEmail)
3124 $res = \CUser::getList(
3128 '=EMAIL' => $userEmail,
3129 '!EXTERNAL_AUTH_ID' => array_diff(\
Bitrix\Main\UserTable::getExternalUserTypes(), [
'email' ]),
3132 'FIELDS' => [
'ID',
'EXTERNAL_AUTH_ID',
'ACTIVE' ]
3139 ($emailUser = $res->fetch())
3144 (
int)$emailUser[
"ID"] > 0
3146 $emailUser[
"ACTIVE"] ===
"Y"
3147 || $emailUser[
"EXTERNAL_AUTH_ID"] ===
"email"
3151 if ($emailUser[
"ACTIVE"] ===
"N")
3154 $user->update($emailUser[
"ID"], [
3172 $userFields = array(
3173 'EMAIL' => $userEmail,
3174 'NAME' => ($params[
"NAME"] ??
''),
3175 'LAST_NAME' => ($params[
"LAST_NAME"] ??
'')
3179 !empty($params[
"CRM_ENTITY"])
3180 && Loader::includeModule(
'crm')
3183 $userFields[
'UF'] = [
3184 'UF_USER_CRM_ENTITY' => $params[
"CRM_ENTITY"],
3186 $res = \CCrmLiveFeedComponent::resolveLFEntityFromUF($params[
"CRM_ENTITY"]);
3195 $k === \CCrmLiveFeedEntity::Contact
3196 && ($contact = \CCrmContact::getById($v))
3197 && (
int)$contact[
'PHOTO'] > 0
3200 $userFields[
'PERSONAL_PHOTO_ID'] = (int)$contact[
'PHOTO'];
3206 !empty($params[
"CREATE_CRM_CONTACT"])
3207 && $params[
"CREATE_CRM_CONTACT"] ===
'Y'
3208 && Loader::includeModule(
'crm')
3209 && ($contactId = \CCrmLiveFeedComponent::createContact($userFields))
3212 $userFields[
'UF'] = [
3213 'UF_USER_CRM_ENTITY' =>
'C_'.$contactId
3215 $result[] =
"CRMCONTACT".$contactId;
3219 $userId = \Bitrix\Mail\User::create($userFields);
3221 $errorMessage =
false;
3228 $errorMessage =
$userId->LAST_ERROR;
3236 $result[] =
"U".$userId;
3240 $errorText = $errorMessage;
3249 \Bitrix\Main\UI\Selector\Entities::save([
3250 'context' => (isset($params[
'CONTEXT']) && $params[
'CONTEXT'] <>
'' ? $params[
'CONTEXT'] :
'BLOG_POST'),
3254 if (Loader::includeModule(
'intranet') && class_exists(
'\Bitrix\Intranet\Integration\Mail\EmailUser'))
3256 \Bitrix\Intranet\Integration\Mail\EmailUser::invite($userId);
3265 foreach($destinationList as $key => $code)
3267 if (preg_match(
'/^UE(.+)$/i', $code, $matches))
3270 $userEmail = $matches[1];
3273 $destRes = self::processUserEmail(array(
3274 'EMAIL' => $userEmail,
3275 'CONTEXT' =>
'BLOG_POST'
3280 && is_array($destRes)
3283 unset($destinationList[$key]);
3284 $destinationList = array_merge($destinationList, $destRes);
3293 isset($HTTPPost[
"SPERM"][
"U"])
3294 && is_array($HTTPPost[
"SPERM"][
"U"])
3295 && !empty($HTTPPost[
"SPERM"][
"U"])
3299 $componentResult[
"ALLOW_EMAIL_INVITATION"]
3300 && isset($HTTPPost[
"SPERM"][
"UE"])
3301 && is_array($HTTPPost[
"SPERM"][
"UE"])
3302 && !empty($HTTPPost[
"SPERM"][
"UE"])
3307 && Loader::includeModule(
'mail')
3312 && Loader::includeModule(
'crm')
3315 $userIdList = array();
3316 foreach ($HTTPPost[
"SPERM"][
"U"] as $code)
3318 if (preg_match(
'/^U(\d+)$/i', $code, $matches))
3320 $userIdList[] = (int)$matches[1];
3324 if (!empty($userIdList))
3326 $res = Main\UserTable::getList(array(
3328 'ID' => $userIdList,
3329 '!=UF_USER_CRM_ENTITY' =>
false
3331 'select' => array(
'ID',
'UF_USER_CRM_ENTITY')
3333 while ($user = $res->fetch())
3335 $livefeedCrmEntity = \CCrmLiveFeedComponent::resolveLFEntityFromUF($user[
'UF_USER_CRM_ENTITY']);
3337 if (!empty($livefeedCrmEntity))
3339 list($k, $v) = $livefeedCrmEntity;
3342 if (!isset($HTTPPost[
"SPERM"][$k]))
3344 $HTTPPost[
"SPERM"][$k] = array();
3346 $HTTPPost[
"SPERM"][$k][] = $k.$v;
3355 foreach ($HTTPPost[
"SPERM"][
"UE"] as $key => $userEmail)
3357 if (!check_email($userEmail))
3364 $destRes = self::processUserEmail([
3365 'EMAIL' => $userEmail,
3367 isset($HTTPPost[
"INVITED_USER_NAME"])
3368 && isset($HTTPPost[
"INVITED_USER_NAME"][$userEmail])
3369 ? $HTTPPost[
"INVITED_USER_NAME"][$userEmail]
3373 isset($HTTPPost[
"INVITED_USER_LAST_NAME"])
3374 && isset($HTTPPost[
"INVITED_USER_LAST_NAME"][$userEmail])
3375 ? $HTTPPost[
"INVITED_USER_LAST_NAME"][$userEmail]
3379 isset($HTTPPost[
"INVITED_USER_CRM_ENTITY"])
3380 && isset($HTTPPost[
"INVITED_USER_CRM_ENTITY"][$userEmail])
3381 ? $HTTPPost[
"INVITED_USER_CRM_ENTITY"][$userEmail]
3384 "CREATE_CRM_CONTACT" => (
3385 isset($HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"])
3386 && isset($HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"][$userEmail])
3387 ? $HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"][$userEmail]
3390 'CONTEXT' =>
'BLOG_POST'
3393 foreach($destRes as $code)
3395 if (preg_match(
'/^U(\d+)$/i', $code, $matches))
3397 $HTTPPost[
"SPERM"][
"U"][] = $code;
3400 Loader::includeModule(
'crm')
3401 && (preg_match(
'/^CRM(CONTACT|COMPANY|LEAD|DEAL)(\d+)$/i', $code, $matches))
3404 if (!isset($HTTPPost[
"SPERM"][
"CRM".$matches[1]]))
3406 $HTTPPost[
"SPERM"][
"CRM".$matches[1]] = array();
3408 $HTTPPost[
"SPERM"][
"CRM".$matches[1]][] = $code;
3412 if (!empty($errorText))
3414 $componentResult[
"ERROR_MESSAGE"] .= $errorText;
3426 if ((
int)$userId <= 0)
3429 $userId = (int)$USER->getId();
3437 $currentCache = \Bitrix\Main\Data\Cache::createInstance();
3439 $cacheTtl = defined(
"BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
3440 $cacheId =
'user_group_member'.$siteId.
'_'.$userId;
3441 $cacheDir =
'/sonet/user_group_member/'.$siteId.
'/'.$userId;
3443 if($currentCache->startDataCache($cacheTtl, $cacheId, $cacheDir))
3445 global $CACHE_MANAGER;
3447 $res = UserToGroupTable::getList(array(
3450 '=USER_ID' => $userId,
3451 '=GROUP.ACTIVE' =>
'Y',
3452 '=GROUP.WorkgroupSite:GROUP.SITE_ID' => $siteId
3454 'select' => array(
'GROUP_ID')
3457 while ($record = $res->fetch())
3459 $result[] = $record[
"GROUP_ID"];
3462 if(defined(
"BX_COMP_MANAGED_CACHE"))
3464 $CACHE_MANAGER->startTagCache($cacheDir);
3465 $CACHE_MANAGER->registerTag(
"sonet_user2group_U".$userId);
3466 $CACHE_MANAGER->endTagCache();
3468 $currentCache->endDataCache($result);
3472 $result = $currentCache->getVars();
3482 $userId = (int)$userId;
3485 $userId = (int)$USER->getId();
3488 $allowToAll = (Option::get(
"socialnetwork",
"allow_livefeed_toall",
"Y") ===
"Y");
3492 $toAllRightsList = unserialize(Option::get(
"socialnetwork",
"livefeed_toall_rights",
'a:1:{i:0;s:2:"AU";}'), [
'allowed_classes' =>
false ]);
3493 if (!$toAllRightsList)
3495 $toAllRightsList = array(
"AU");
3498 $userGroupCodeList = array_merge(array(
"AU"), \CAccess::getUserCodesArray($userId));
3499 if (count(array_intersect($toAllRightsList, $userGroupCodeList)) <= 0)
3501 $allowToAll =
false;
3511 if (ModuleManager::isModuleInstalled(
'blog'))
3513 $res[
"blog"] = array(
'Bitrix\Blog\Update\LivefeedIndexPost',
'Bitrix\Blog\Update\LivefeedIndexComment');
3515 if (ModuleManager::isModuleInstalled(
'tasks'))
3517 $res[
"tasks"] = array(
'Bitrix\Tasks\Update\LivefeedIndexTask');
3519 if (ModuleManager::isModuleInstalled(
'calendar'))
3521 $res[
"calendar"] = array(
'Bitrix\Calendar\Update\LivefeedIndexCalendar');
3523 if (ModuleManager::isModuleInstalled(
'forum'))
3525 $res[
"forum"] = array(
'Bitrix\Forum\Update\LivefeedIndexMessage',
'Bitrix\Forum\Update\LivefeedIndexComment');
3527 if (ModuleManager::isModuleInstalled(
'xdimport'))
3529 $res[
"xdimport"] = array(
'Bitrix\XDImport\Update\LivefeedIndexLog',
'Bitrix\XDImport\Update\LivefeedIndexComment');
3531 if (ModuleManager::isModuleInstalled(
'wiki'))
3533 $res[
"wiki"] = array(
'Bitrix\Wiki\Update\LivefeedIndexLog',
'Bitrix\Wiki\Update\LivefeedIndexComment');
3537 echo Stepper::getHtml($res,
Loc::getMessage(ModuleManager::isModuleInstalled(
'intranet') ?
'SONET_HELPER_STEPPER_LIVEFEED2':
'SONET_HELPER_STEPPER_LIVEFEED'));
3543 $userId = (int)$userId;
3549 $select = array(
'ID',
'EXTERNAL_AUTH_ID');
3550 if (ModuleManager::isModuleInstalled(
'crm'))
3552 $select[] =
'UF_USER_CRM_ENTITY';
3554 $res = Main\UserTable::getList(array(
3561 if ($userFields = $res->fetch())
3565 'onUserProfileRedirectGetUrl',
3567 'userFields' => $userFields
3572 foreach ($event->getResults() as $eventResult)
3574 if ($eventResult->getType() === \
Bitrix\Main\EventResult::SUCCESS)
3576 $eventParams = $eventResult->getParameters();
3579 is_array($eventParams)
3580 && isset($eventParams[
'url'])
3583 LocalRedirect($eventParams[
'url']);
3598 && !empty($params[
'logId'])
3599 && (int)$params[
'logId'] > 0
3600 ? (
int)$params[
'logId']
3609 if ($logItem = Log::getById($logId))
3611 $logItemFields = $logItem->getFields();
3613 isset($logItemFields[
'TRANSFORM'])
3614 && $logItemFields[
'TRANSFORM'] ===
"Y"
3626 static $extranetSiteId =
null;
3632 && isset($params[
'show'])
3633 && $params[
'show'] === true
3638 && !empty($params[
'postId'])
3639 && (int)$params[
'postId'] > 0
3640 ? (
int)$params[
'postId']
3646 || !Loader::includeModule(
'blog')
3654 $liveFeedEntity = Livefeed\Provider::init(array(
3655 'ENTITY_TYPE' =>
'BLOG_POST',
3656 'ENTITY_ID' => $postId,
3659 $logId = $liveFeedEntity->getLogId();
3660 if (!self::getBlogPostLimitedViewStatus(array(
3667 $post = Post::getById($postId);
3668 $postFields = $post->getFields();
3671 'postId' => $postId,
3672 'authorId' => $postFields[
"AUTHOR_ID"]
3675 \CSocNetLogRights::deleteByLogID($logId);
3676 \CSocNetLogRights::add($logId, $socnetPerms,
true,
false);
3682 if (\
Bitrix\Main\Loader::includeModule(
'crm'))
3684 $logItem = Log::getById($logId);
3685 \CCrmLiveFeedComponent::processCrmBlogPostRights($logId, $logItem->getFields(), $postFields,
'new');
3688 \Bitrix\Blog\Integration\Socialnetwork\CounterPost::increment(array(
3689 'socnetPerms' => $socnetPerms,
3691 'logEventId' => $liveFeedEntity->getEventId()
3694 $logSiteIdList = array();
3695 $resSite = \CSocNetLog::getSite($logId);
3696 while($logSite = $resSite->fetch())
3698 $logSiteIdList[] = $logSite[
"LID"];
3702 $extranetSiteId ===
null
3703 && Loader::includeModule(
'extranet')
3706 $extranetSiteId = \CExtranet::getExtranetSiteID();
3710 foreach($logSiteIdList as $logSiteId)
3712 if ($logSiteId != $extranetSiteId)
3714 $siteId = $logSiteId;
3721 $siteId = \CSite::getDefSite();
3724 $postUrl = \CComponentEngine::makePathFromTemplate(
3725 \
Bitrix\Socialnetwork\Helper\Path::get(
'userblogpost_page', $siteId),
3727 "post_id" => $postId,
3728 "user_id" => $postFields[
"AUTHOR_ID"]
3732 $notificationParamsList = array(
3734 'ID' => $postFields[
"ID"],
3735 'TITLE' => $postFields[
"TITLE"],
3736 'AUTHOR_ID' => $postFields[
"AUTHOR_ID"]
3738 'siteId' => $siteId,
3739 'postUrl' => $postUrl,
3740 'socnetRights' => $socnetPerms,
3748 !isset($params[
'notifyAuthor'])
3749 || $params[
'notifyAuthor']
3752 self::notifyAuthorOnSetBlogPostLimitedViewStatusShow(array(
3753 'POST_ID' => $postId,
3754 'POST_FIELDS' => $postFields,
3755 'POST_URL' => $postUrl,
3757 'SITE_ID' => $siteId
3761 BXClearCache(
true, self::getBlogPostCacheDir(array(
3763 'POST_ID' => $postId
3773 private static function notifyAuthorOnSetBlogPostLimitedViewStatusShow($params = array())
3775 $postId = $params[
'POST_ID'];
3776 $postFields = $params[
'POST_FIELDS'];
3777 $postUrl = $params[
'POST_URL'];
3778 $logId = $params[
'LOG_ID'];
3779 $siteId = $params[
'SITE_ID'];
3782 if (Loader::includeModule(
'im'))
3784 $authorPostUrl = $postUrl;
3785 if (ModuleManager::isModuleInstalled(
"extranet"))
3787 $tmp = \CSocNetLogTools::processPath(
3789 "URL" => $authorPostUrl,
3791 $postFields[
"AUTHOR_ID"],
3794 $authorPostUrl = $tmp[
"URLS"][
"URL"];
3797 mb_strpos($authorPostUrl,
"http://") === 0
3798 || mb_strpos($authorPostUrl,
"https://") === 0
3800 : $tmp[
"SERVER_NAME"]
3804 $messageFields = array(
3805 "MESSAGE_TYPE" => IM_MESSAGE_SYSTEM,
3806 "TO_USER_ID" => $postFields[
"AUTHOR_ID"],
3807 "FROM_USER_ID" => $postFields[
"AUTHOR_ID"],
3808 "NOTIFY_TYPE" => IM_NOTIFY_SYSTEM,
3809 "NOTIFY_ANSWER" =>
"N",
3810 "NOTIFY_MODULE" =>
"socialnetwork",
3811 "NOTIFY_EVENT" =>
"transform",
3812 "NOTIFY_TAG" =>
"SONET|BLOG_POST_CONVERT|".$postId,
3813 "PARSE_LINK" =>
"N",
3815 "NOTIFY_MESSAGE" =>
Loc::getMessage(
'SONET_HELPER_VIDEO_CONVERSION_COMPLETED', array(
3816 '#POST_TITLE#' =>
'<a href="'.$authorPostUrl.
'" class="bx-notifier-item-action">'.htmlspecialcharsbx($postFields[
"TITLE"]).
'</a>'
3818 "NOTIFY_MESSAGE_OUT" =>
Loc::getMessage(
'SONET_HELPER_VIDEO_CONVERSION_COMPLETED', array(
3819 '#POST_TITLE#' => htmlspecialcharsbx($postFields[
"TITLE"]),
3820 )).
" ".$serverName.$authorPostUrl,
3823 $messageFields[
'PUSH_MESSAGE'] = $messageFields[
'NOTIFY_MESSAGE'];
3824 $messageFields[
'PUSH_PARAMS'] = array(
3825 'ACTION' =>
'transform',
3826 'TAG' => $messageFields[
'NOTIFY_TAG']
3829 \CIMNotify::add($messageFields);
3839 && !empty($params[
'postId'])
3840 && (int)$params[
'postId'] > 0
3841 ? (
int)$params[
'postId']
3847 && !empty($params[
'authorId'])
3848 && (int)$params[
'authorId'] > 0
3849 ? (
int)$params[
'authorId']
3860 $blogPostFields = \CBlogPost::getByID($postId);
3861 $authorId = (int)$blogPostFields[
"AUTHOR_ID"];
3869 $result = \CBlogPost::getSocNetPermsCode($postId);
3871 $profileBlogPost =
false;
3872 foreach($result as $perm)
3874 if (preg_match(
'/^UP(\d+)$/', $perm, $matches))
3876 $profileBlogPost =
true;
3880 if (!$profileBlogPost)
3882 if (!in_array(
"U".$authorId, $result,
true))
3884 $result[] =
"U".$authorId;
3889 in_array(
"AU", $result,
true)
3890 || in_array(
"G2", $result,
true)
3893 $socnetPermsAdd = array();
3895 foreach ($result as $perm)
3897 if (preg_match(
'/^SG(\d+)$/', $perm, $matches))
3905 $socnetPermsAdd[] =
"SG".$matches[1].
"_".$result;
3909 if (count($socnetPermsAdd) > 0)
3911 $result = array_merge($result, $socnetPermsAdd);
3921 if (!Loader::includeModule(
'blog'))
3928 && is_array($params)
3929 && !empty($params[
'post'])
3930 && is_array($params[
'post'])
3937 && is_array($params)
3938 && !empty($params[
'siteId'])
3940 : \CSite::getDefSite()
3945 && is_array($params)
3946 && !empty($params[
'postUrl'])
3947 ? $params[
'postUrl']
3953 && is_array($params)
3954 && !empty($params[
'socnetRights'])
3955 && is_array($params[
'socnetRights'])
3956 ? $params[
'socnetRights']
3960 $socnetRightsOld = (
3962 && is_array($params)
3963 && !empty($params[
'socnetRightsOld'])
3964 && is_array($params[
'socnetRightsOld'])
3965 ? $params[
'socnetRightsOld']
3974 && is_array($params)
3975 && !empty($params[
'mentionListOld'])
3976 && is_array($params[
'mentionListOld'])
3977 ? $params[
'mentionListOld']
3983 && is_array($params)
3984 && !empty($params[
'mentionList'])
3985 && is_array($params[
'mentionList'])
3986 ? $params[
'mentionList']
3992 && is_array($params)
3993 && !empty($params[
'gratData'])
3994 && is_array($params[
'gratData'])
3995 ? $params[
'gratData']
3999 $IMNotificationFields = array(
4001 "TITLE" => $post[
"TITLE"],
4003 "ID" => $post[
"ID"],
4004 "FROM_USER_ID" => $post[
"AUTHOR_ID"],
4005 "TO_USER_ID" => array(),
4006 "TO_SOCNET_RIGHTS" => $socnetRights,
4007 "TO_SOCNET_RIGHTS_OLD" => $socnetRightsOld,
4008 "GRAT_DATA" => $gratData
4010 if (!empty($mentionListOld))
4012 $IMNotificationFields[
"MENTION_ID_OLD"] = $mentionListOld;
4014 if (!empty($mentionList))
4016 $IMNotificationFields[
"MENTION_ID"] = $mentionList;
4019 $userIdSentList = \CBlogPost::notifyIm($IMNotificationFields);
4020 if (!$userIdSentList)
4022 $userIdSentList = [];
4025 $userIdToMailList = [];
4027 if (!empty($socnetRights))
4029 \Bitrix\Blog\Broadcast::send(array(
4030 "EMAIL_FROM" => Option::get(
'main',
'email_from',
'nobody@nobody.com'),
4031 "SOCNET_RIGHTS" => $socnetRights,
4032 "SOCNET_RIGHTS_OLD" => $socnetRightsOld,
4033 "ENTITY_TYPE" =>
"POST",
4034 "ENTITY_ID" => $post[
"ID"],
4035 "AUTHOR_ID" => $post[
"AUTHOR_ID"],
4037 'EXCLUDE_USERS' => array_merge([ $post[
'AUTHOR_ID'] ], $userIdSentList),
4040 foreach ($socnetRights as $right)
4042 if (mb_strpos($right,
"U") === 0)
4044 $rightUserId = (int)mb_substr($right, 1);
4047 && empty($socnetRightsOld[
"U"][$rightUserId])
4048 && $rightUserId !== (int)$post[
"AUTHOR_ID"]
4049 && !in_array($rightUserId, $userIdToMailList,
true)
4052 $userIdToMailList[] = $rightUserId;
4058 if (!empty($userIdToMailList))
4060 \CBlogPost::notifyMail([
4062 "siteId" => $siteId,
4063 "userId" => $userIdToMailList,
4064 "authorId" => $post[
"AUTHOR_ID"],
4065 "postId" => $post[
"ID"],
4066 "postUrl" => \CComponentEngine::makePathFromTemplate(
4067 '/pub/post.php?post_id=#post_id#',
4069 "post_id" => $post[
"ID"],
4080 list($siteId, $siteDir) = self::getSiteId($params);
4082 return Option::get(
'socialnetwork',
'user_page', $siteDir.
'company/personal/', $siteId);
4087 list($siteId, $siteDir) = self::getSiteId($params);
4089 return Option::get(
'socialnetwork',
'workgroups_page', $siteDir.
'workgroups/', $siteId);
4094 list($siteId, $siteDir) = self::getSiteId($params);
4096 return $siteDir .
'spaces/';
4099 private static function getSiteId($params = []): array
4103 && isset($params[
'siteId'])
4108 $siteDir = SITE_DIR;
4111 $res = \CSite::getById($siteId);
4112 if ($site = $res->fetch())
4114 $siteDir = $site[
'DIR'];
4118 return [$siteId, $siteDir];
4127 if (!Loader::includeModule(
'blog'))
4133 isset($params[
'POST_ID'])
4134 && (int)$params[
'POST_ID'] > 0
4135 ? (
int)$params[
'POST_ID']
4139 $postFields = array();
4143 $postFields = \Bitrix\Blog\Item\Post::getById($postId)->getFields();
4148 && isset($params[
'AUTHOR_ID'])
4149 && (int)$params[
'AUTHOR_ID'] > 0
4150 ? (
int)$params[
'AUTHOR_ID']
4151 : $postFields[
'AUTHOR_ID']
4156 'siteId' => SITE_ID,
4157 'userId' => $USER->getId(),
4162 !empty($params[
'SITE_ID'])
4163 ? $params[
'SITE_ID']
4167 $socNetPermsListOld = array();
4171 $socNetPermsListOld = \CBlogPost::getSocNetPerms($postId);
4176 && !empty($postFields[
'AUTHOR_ID'])
4177 && !empty($socNetPermsListOld)
4178 && !empty($socNetPermsListOld[
'U'])
4179 && isset($socNetPermsListOld[
'U'][$postFields[
'AUTHOR_ID']])
4180 && in_array(
'U' . $postFields[
'AUTHOR_ID'], $socNetPermsListOld[
'U'][$postFields[
'AUTHOR_ID']],
true)
4184 isset($params[
'PERM'])
4185 && is_array($params[
'PERM'])
4194 && isset($params[
"IS_REST"])
4195 && $params[
"IS_REST"]
4199 $permList = array(
"UA" => array(
"UA"));
4202 foreach ($permList as $v => $k)
4215 empty($postFields[
'AUTHOR_ID'])
4216 || $vv !==
'U'.$postFields[
'AUTHOR_ID']
4229 'SITE_ID' => $siteId,
4230 'AUTHOR_ID' => $authorId,
4231 'IS_EXTRANET_USER' => $extranetUser,
4232 'POST_ID' => $postId
4242 $destinationList = (
4243 isset($params[
"DEST"])
4244 && is_array($params[
"DEST"])
4250 !empty($params[
'SITE_ID'])
4251 ? $params[
'SITE_ID']
4255 $currentUserId = $USER->getId();
4257 if (!$currentUserId)
4264 'siteId' => SITE_ID,
4265 'userId' => $USER->getId()
4270 isset($params[
'POST_ID'])
4271 && (int)$params[
'POST_ID'] > 0
4272 ? (
int)$params[
'POST_ID']
4277 $oldSonetGroupIdList = [];
4281 $socNetPermsListOld = \CBlogPost::getSocNetPerms($postId);
4282 $postFields = \Bitrix\Blog\Item\Post::getById($postId)->getFields();
4283 if (!empty($socNetPermsListOld[
'SG']))
4285 $oldSonetGroupIdList = array_keys($socNetPermsListOld[
'SG']);
4289 $userAdmin = \CSocNetUser::isUserModuleAdmin($currentUserId, $siteId);
4292 $newSonetGroupIdList = [];
4293 $newUserIdList = [];
4295 foreach($destinationList as $code)
4297 if (preg_match(
'/^SG(\d+)/i', $code, $matches))
4299 $newSonetGroupIdList[] = (int)$matches[1];
4301 elseif (preg_match(
'/^U(\d+)/i', $code, $matches))
4303 $newUserIdList[] = (int)$matches[1];
4307 if (!empty($newSonetGroupIdList))
4312 $premoderateSGList = [];
4315 foreach ($newSonetGroupIdList as $groupId)
4319 && $postFields[
"PUBLISH_STATUS"] === BLOG_PUBLISH_STATUS_PUBLISH
4320 && in_array($groupId, $oldSonetGroupIdList)
4326 $canPublishToGroup = (
4328 || \CSocNetFeaturesPerms::canPerformOperation($currentUserId, SONET_ENTITY_GROUP, $groupId,
'blog',
'write_post')
4329 || \CSocNetFeaturesPerms::canPerformOperation($currentUserId, SONET_ENTITY_GROUP, $groupId,
'blog',
'full_post')
4330 || \CSocNetFeaturesPerms::canPerformOperation($currentUserId, SONET_ENTITY_GROUP, $groupId,
'blog',
'moderate_post')
4333 $canPremoderateToGroup = \CSocNetFeaturesPerms::canPerformOperation($currentUserId, SONET_ENTITY_GROUP, $groupId,
'blog',
'premoderate_post');
4337 && $canPremoderateToGroup
4340 $premoderateSGList[] = $groupId;
4345 && $canPublishToGroup
4361 if (!empty($premoderateSGList))
4365 if ($resultFields[
'PUBLISH_STATUS'] === BLOG_PUBLISH_STATUS_PUBLISH)
4369 $resultFields[
'PUBLISH_STATUS'] = BLOG_PUBLISH_STATUS_READY;
4371 elseif ($postFields[
'PUBLISH_STATUS'] !== BLOG_PUBLISH_STATUS_PUBLISH)
4373 $resultFields[
'PUBLISH_STATUS'] = $postFields[
'PUBLISH_STATUS'];
4377 $resultFields[
'ERROR_MESSAGE'] =
Loc::getMessage(
'SBPE_EXISTING_POST_PREMODERATION');
4378 $resultFields[
'ERROR_MESSAGE_PUBLIC'] = $resultFields[
'ERROR_MESSAGE'];
4384 $groupNameList = [];
4385 $groupUrl = Option::get(
'socialnetwork',
'workgroups_page', SITE_DIR.
'workgroups/', SITE_ID).
'group/#group_id#/';
4387 $res = WorkgroupTable::getList([
4389 '@ID' => $premoderateSGList
4391 'select' => [
'ID',
'NAME' ]
4393 while ($groupFields = $res->fetch())
4395 $groupNameList[] = (
4396 isset($params[
'MOBILE']) && $params[
'MOBILE'] ===
'Y'
4397 ? $groupFields[
'NAME']
4398 :
'<a href="' . \CComponentEngine::makePathFromTemplate($groupUrl, [
'group_id' => $groupFields[
'ID'] ]) .
'">' . htmlspecialcharsEx($groupFields[
'NAME']) .
'</a>'
4402 $resultFields[
'ERROR_MESSAGE'] =
Loc::getMessage(
'SBPE_MULTIPLE_PREMODERATION2', [
4403 '#GROUPS_LIST#' => implode(
', ', $groupNameList)
4405 $resultFields[
'ERROR_MESSAGE_PUBLIC'] = $resultFields[
'ERROR_MESSAGE'];
4410 $resultFields[
'ERROR_MESSAGE'] =
Loc::getMessage(
'SONET_HELPER_NO_PERMISSIONS');
4417 $destinationList = array_filter($destinationList,
static function ($code) {
4418 return (!preg_match(
'/^(DR|D)(\d+)$/i', $code, $matches));
4422 !empty($newUserIdList)
4423 && Loader::includeModule(
'extranet')
4426 $visibleUserIdList = \CExtranet::getMyGroupsUsersSimple(SITE_ID);
4428 if (!empty(array_diff($newUserIdList, $visibleUserIdList)))
4430 $resultFields[
'ERROR_MESSAGE'] =
Loc::getMessage(
'SONET_HELPER_NO_PERMISSIONS');
4437 && in_array(
"UA", $destinationList,
true)
4440 foreach ($destinationList as $key => $value)
4442 if ($value ===
"UA")
4444 unset($destinationList[$key]);
4453 empty($destinationList)
4454 || in_array(
"UA", $destinationList,
true)
4457 $resultFields[
"ERROR_MESSAGE"] .=
Loc::getMessage(
"BLOG_BPE_EXTRANET_ERROR");
4460 elseif (empty($destinationList))
4462 $resultFields[
"ERROR_MESSAGE"] .=
Loc::getMessage(
"BLOG_BPE_DESTINATION_EMPTY");
4465 return $destinationList;
4470 static $allowedTypes = array(
4482 if (!is_array($params))
4487 $type = ($params[
'TYPE'] ??
false);
4491 || !in_array($type, $allowedTypes,
true)
4498 isset($params[
'POST_ID'])
4499 && (int)$params[
'POST_ID'] > 0
4500 ? (
int)$params[
'POST_ID']
4506 && in_array($type, array(
'post_general',
'post',
'post_comments',
'post_urlpreview'))
4512 $siteId = ($params[
'SITE_ID'] ?? SITE_ID);
4517 $result =
"/blog/socnet_post/".(int)($postId / 100).
"/".$postId.
"/";
4519 case 'post_general':
4520 $result =
"/blog/socnet_post/gen/".(int)($postId / 100).
"/".$postId;
4522 case 'post_urlpreview':
4523 $result =
"/blog/socnet_post/urlpreview/".(int)($postId / 100).
"/".$postId;
4525 case 'posts_popular':
4526 $result =
"/".$siteId.
"/blog/popular_posts/";
4529 $result =
"/".$siteId.
"/blog/last_messages_list/";
4531 case 'posts_last_blog':
4532 $result =
"/".$siteId.
"/blog/last_messages/";
4534 case 'post_comments':
4535 $result =
"/blog/comment/".(int)($postId / 100).
"/".$postId.
"/";
4551 !empty($params[
'logId'])
4556 if (!is_array($logIdList))
4558 $logIdList = [ $logIdList ];
4561 if (empty($logIdList))
4566 $ratingId = \CRatings::getAuthorityRating();
4567 if ((
int)$ratingId <= 0)
4572 $result = array_fill_keys($logIdList, []);
4575 isset($params[
'topCount'])
4576 ? (int)$params[
'topCount']
4591 isset($params[
'avatarSize'])
4592 ? (int)$params[
'avatarSize']
4598 if (ModuleManager::isModuleInstalled(
'intranet'))
4600 $res = $connection->query(
'
4601 SELECT /*+ NO_DERIVED_CONDITION_PUSHDOWN() */
4602 RS1.ENTITY_ID as USER_ID,
4604 MAX(RS1.VOTES) as WEIGHT
4606 b_rating_subordinate RS1,
4608 INNER JOIN b_sonet_log SL
4609 ON SL.RATING_TYPE_ID = RV1.ENTITY_TYPE_ID
4610 AND SL.RATING_ENTITY_ID = RV1.ENTITY_ID
4611 AND SL.ID IN ('.implode(
',', $logIdList).
')
4613 RS1.ENTITY_ID = RV1.USER_ID
4614 AND RS1.RATING_ID = '.(
int)$ratingId.
'
4616 SL.ID, RS1.ENTITY_ID
4624 $res = $connection->query(
'
4625 SELECT /*+ NO_DERIVED_CONDITION_PUSHDOWN() */
4626 RV1.USER_ID as USER_ID,
4631 INNER JOIN b_sonet_log SL
4632 ON SL.RATING_TYPE_ID = RV1.ENTITY_TYPE_ID
4633 AND SL.RATING_ENTITY_ID = RV1.ENTITY_ID
4634 AND SL.ID IN ('.implode(
',', $logIdList).
')
4641 $userWeightData = [];
4648 while ($voteFields = $res->fetch())
4650 $voteUserId = (int)$voteFields[
'USER_ID'];
4651 $voteLogId = (int)$voteFields[
'LOG_ID'];
4655 && $voteUserId === (
int)$USER->getId()
4661 if ($voteLogId !== $currentLogId)
4665 $logUserData[$voteLogId] = [];
4668 $currentLogId = $voteLogId;
4670 if (in_array($voteUserId, $logUserData[$voteLogId],
true))
4677 if ($cnt > ($hasMine ? $topCount+1 : $topCount))
4682 $logUserData[$voteLogId][] = $voteUserId;
4683 if (!isset($userWeightData[$voteUserId]))
4685 $userWeightData[$voteUserId] = (float)$voteFields[
'WEIGHT'];
4691 if (!empty($userWeightData))
4693 $res = Main\UserTable::getList([
4695 '@ID' => array_keys($userWeightData)
4697 'select' => [
'ID',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'LOGIN',
'PERSONAL_PHOTO',
'PERSONAL_GENDER' ]
4700 while ($userFields = $res->fetch())
4702 $userData[$userFields[
"ID"]] = [
4703 'NAME_FORMATTED' => \CUser::formatName(
4704 \CSite::getNameFormat(
false),
4708 'PERSONAL_PHOTO' => [
4709 'ID' => $userFields[
'PERSONAL_PHOTO'],
4712 'PERSONAL_GENDER' => $userFields[
'PERSONAL_GENDER']
4715 if ((
int)$userFields[
'PERSONAL_PHOTO'] > 0)
4717 $imageFile = \CFile::getFileArray($userFields[
"PERSONAL_PHOTO"]);
4718 if ($imageFile !==
false)
4720 $file = \CFile::resizeImageGet(
4723 'width' => $avatarSize,
4724 'height' => $avatarSize,
4726 BX_RESIZE_IMAGE_EXACT,
4729 $userData[$userFields[
"ID"]][
'PERSONAL_PHOTO'][
'SRC'] = $file[
'src'];
4735 foreach ($logUserData as $logId => $userIdList)
4737 $result[$logId] = [];
4739 foreach ($userIdList as $userId)
4741 $result[$logId][] = [
4743 'NAME_FORMATTED' => $userData[$userId][
'NAME_FORMATTED'],
4744 'PERSONAL_PHOTO' => $userData[$userId][
'PERSONAL_PHOTO'][
'ID'],
4745 'PERSONAL_PHOTO_SRC' => $userData[$userId][
'PERSONAL_PHOTO'][
'SRC'],
4746 'PERSONAL_GENDER' => $userData[$userId][
'PERSONAL_GENDER'],
4747 'WEIGHT' => $userWeightData[$userId]
4752 foreach ($result as $logId => $data)
4756 static function($a, $b)
4759 !isset($a[
'WEIGHT'], $b[
'WEIGHT'])
4760 || $a[
'WEIGHT'] === $b[
'WEIGHT']
4765 return ($a[
'WEIGHT'] > $b[
'WEIGHT']) ? -1 : 1;
4768 $result[$logId] = $data;
4776 static $result = [];
4778 $siteId = (!empty($params[
'siteId']) ? $params[
'siteId'] : SITE_ID);
4780 if (!isset($result[$siteId]))
4782 $result[$siteId] = (
4783 !\CSocNetUser::isCurrentUserModuleAdmin($siteId,
false)
4784 && Loader::includeModule(
'extranet')
4785 && !\CExtranet::isIntranetUser()
4789 return $result[$siteId];
4795 $logAuthorList = array(),
4796 $logDestUserList = array();
4798 $userId = (isset($params[
'userId']) ? (int)$params[
'userId'] : 0);
4799 $logId = (isset($params[
'logId']) ? (int)$params[
'logId'] : 0);
4800 $typeList = ($params[
'typeList'] ?? []);
4801 $siteId = (isset($params[
'siteId']) ? (int)$params[
'siteId'] : SITE_ID);
4802 $followByWF = !empty($params[
'followByWF']);
4804 if (!is_array($typeList))
4806 $typeList = array($typeList);
4819 if (in_array(
'FOLLOW', $typeList))
4821 $followRes = \CSocNetLogFollow::set(
4826 !empty($params[
'followDate'])
4828 mb_strtoupper($params[
'followDate']) ===
'CURRENT'
4829 ? ConvertTimeStamp(time() + \CTimeZone::getOffset(),
"FULL", $siteId)
4830 : $params[
'followDate']
4839 if (in_array(
'COUNTER_COMMENT_PUSH', $typeList))
4841 if (!isset($logAuthorList[$logId]))
4847 'select' => array(
'USER_ID')
4849 if ($logFields = $res->fetch())
4851 $logAuthorList[$logId] = $logFields[
'USER_ID'];
4855 if (!isset($logDestUserList[$logId]))
4857 $logDestUserList[$logId] = array();
4858 $res = LogRightTable::getList(array(
4862 'select' => array(
'GROUP_CODE')
4864 while ($logRightFields = $res->fetch())
4866 if (preg_match(
'/^U(\d+)$/', $logRightFields[
'GROUP_CODE'], $matches))
4868 $logDestUserList[$logId][] = $matches[1];
4874 $userId != $logAuthorList[$logId]
4875 && !in_array($userId, $logDestUserList[$logId])
4879 'userId' => $userId,
4888 in_array(
'FOLLOW', $typeList)
4896 $forumMetaData = \CSocNetLogTools::getForumCommentMetaData($eventFields[
"EVENT_ID"]);
4900 && $eventFields[
"SOURCE_ID"] > 0
4904 "ENTITY_TYPE" => $forumMetaData[1],
4905 "ENTITY_XML_ID" => $forumMetaData[0].
"_".$eventFields[
"SOURCE_ID"],
4906 "NOTIFY_TAGS" => $forumMetaData[2]
4912 $eventFields[
"EVENT_ID"] ===
'calendar'
4913 && !empty($eventFields[
"PARAMS"])
4914 && ($calendarEventParams = unserialize(htmlspecialcharsback($eventFields[
"PARAMS"]), [
'allowed_classes' =>
false ]))
4915 && !empty($calendarEventParams[
'COMMENT_XML_ID'])
4918 $result[
"ENTITY_XML_ID"] = $calendarEventParams[
'COMMENT_XML_ID'];
4921 elseif ($eventFields[
"EVENT_ID"] ===
'photo')
4924 "ENTITY_TYPE" =>
'PA',
4925 "ENTITY_XML_ID" =>
'PHOTO_ALBUM_'.$eventFields[
"ID"],
4932 "ENTITY_TYPE" => mb_substr(mb_strtoupper($eventFields[
"EVENT_ID"]).
"_".$eventFields[
"ID"], 0, 2),
4933 "ENTITY_XML_ID" => mb_strtoupper($eventFields[
"EVENT_ID"]).
"_".$eventFields[
"ID"],
4939 mb_strtoupper($eventFields[
"ENTITY_TYPE"]) ===
"CRMACTIVITY"
4940 && Loader::includeModule(
'crm')
4941 && ($activityFields = \CCrmActivity::getById($eventFields[
"ENTITY_ID"],
false))
4943 $activityFields[
"TYPE_ID"] == \CCrmActivityType::Task
4945 (
int)$activityFields[
'TYPE_ID'] === \CCrmActivityType::Provider
4946 && $activityFields[
'PROVIDER_ID'] === Task::getId()
4951 $result[
"ENTITY_XML_ID"] =
"TASK_".$activityFields[
"ASSOCIATED_ENTITY_ID"];
4954 $eventFields[
"ENTITY_TYPE"] ===
"WF"
4955 && is_numeric($eventFields[
"SOURCE_ID"])
4956 && (
int)$eventFields[
"SOURCE_ID"] > 0
4957 && Loader::includeModule(
'bizproc')
4958 && ($workflowId = \CBPStateService::getWorkflowByIntegerId($eventFields[
"SOURCE_ID"]))
4961 $result[
"ENTITY_XML_ID"] =
"WF_".$workflowId;
4969 static $canCommentCached = [];
4971 $userId = (isset($params[
'userId']) ? (int)$params[
'userId'] : 0);
4972 $workgroupId = (isset($params[
'workgroupId']) ? (int)$params[
'workgroupId'] : 0);
4975 || $workgroupId <= 0
4981 $cacheKey = $userId.
'_'.$workgroupId;
4983 if (!isset($canCommentCached[$cacheKey]))
4985 $canCommentCached[$cacheKey] = (
4986 \CSocNetFeaturesPerms::canPerformOperation($userId, SONET_ENTITY_GROUP, $workgroupId,
"blog",
"premoderate_comment")
4987 || \CSocNetFeaturesPerms::canPerformOperation($userId, SONET_ENTITY_GROUP, $workgroupId,
"blog",
"write_comment")
4991 return $canCommentCached[$cacheKey];
4996 return Option::get(
'socialnetwork',
'livefeed_allow_tasks',
true);
5001 $perms = (string)($params[
'perms'] ??
'');
5002 $crm = (bool)($params[
'crm'] ??
false);
5005 'DEST_DATA' =>
'DEST_CODES',
5006 'GRAT_DEST_DATA' =>
'GRAT_DEST_CODES',
5009 foreach ($mapping as $from => $to)
5011 if (isset($postFields[$from]))
5015 $entities = Json::decode($postFields[$from]);
5022 $postFields[$to] = array_merge(
5023 ($postFields[$to] ?? []),
5024 \
Bitrix\Main\UI\EntitySelector\Converter::convertToFinderCodes($entities)
5030 'DEST_CODES' =>
'SPERM',
5031 'GRAT_DEST_CODES' =>
'GRAT',
5032 'EVENT_DEST_CODES' =>
'EVENT_PERM'
5035 foreach ($mapping as $from => $to)
5037 if (isset($postFields[$from]))
5040 !isset($postFields[$to])
5041 || !is_array($postFields[$to])
5044 $postFields[$to] = [];
5047 foreach ($postFields[$from] as $destCode)
5049 if ($destCode ===
'UA')
5051 if (empty($postFields[$to][
'UA']))
5053 $postFields[$to][
'UA'] = [];
5055 $postFields[$to][
'UA'][] =
'UA';
5057 elseif (preg_match(
'/^UE(.+)$/i', $destCode, $matches))
5059 if (empty($postFields[$to][
'UE']))
5061 $postFields[$to][
'UE'] = [];
5063 $postFields[$to][
'UE'][] = $matches[1];
5065 elseif (preg_match(
'/^U(\d+)$/i', $destCode, $matches))
5067 if (empty($postFields[$to][
'U']))
5069 $postFields[$to][
'U'] = [];
5071 $postFields[$to][
'U'][] =
'U' . $matches[1];
5074 $from ===
'DEST_CODES'
5075 && $perms === BLOG_PERMS_FULL
5076 && preg_match(
'/^UP(\d+)$/i', $destCode, $matches)
5077 && Loader::includeModule(
'blog')
5080 if (empty($postFields[$to][
'UP']))
5082 $postFields[$to][
'UP'] = [];
5084 $postFields[$to][
'UP'][] =
'UP' . $matches[1];
5086 elseif (preg_match(
'/^SG(\d+)$/i', $destCode, $matches))
5088 if (empty($postFields[$to][
'SG']))
5090 $postFields[$to][
'SG'] = [];
5092 $postFields[$to][
'SG'][] =
'SG' . $matches[1];
5094 elseif (preg_match(
'/^DR(\d+)$/i', $destCode, $matches))
5096 if (empty($postFields[$to][
'DR']))
5098 $postFields[$to][
'DR'] = [];
5100 $postFields[$to][
'DR'][] =
'DR' . $matches[1];
5102 elseif ($crm && preg_match(
'/^CRMCONTACT(\d+)$/i', $destCode, $matches))
5104 if (empty($postFields[$to][
'CRMCONTACT']))
5106 $postFields[$to][
'CRMCONTACT'] = [];
5108 $postFields[$to][
'CRMCONTACT'][] =
'CRMCONTACT' . $matches[1];
5110 elseif ($crm && preg_match(
'/^CRMCOMPANY(\d+)$/i', $destCode, $matches))
5112 if (empty($postFields[$to][
'CRMCOMPANY']))
5114 $postFields[$to][
'CRMCOMPANY'] = [];
5116 $postFields[$to][
'CRMCOMPANY'][] =
'CRMCOMPANY' . $matches[1];
5118 elseif ($crm && preg_match(
'/^CRMLEAD(\d+)$/i', $destCode, $matches))
5120 if (empty($postFields[$to][
'CRMLEAD']))
5122 $postFields[$to][
'CRMLEAD'] = [];
5124 $postFields[$to][
'CRMLEAD'][] =
'CRMLEAD' . $matches[1];
5126 elseif ($crm && preg_match(
'/^CRMDEAL(\d+)$/i', $destCode, $matches))
5128 if (empty($postFields[$to][
'CRMDEAL']))
5130 $postFields[$to][
'CRMDEAL'] = [];
5132 $postFields[$to][
'CRMDEAL'][] =
'CRMDEAL' . $matches[1];
5136 unset($postFields[$from]);
5145 $componentName = (string)($params[
'componentName'] ??
'');
5146 $page = (string)($params[
'page'] ??
'');
5147 $entityId = (int)($params[
'entityId'] ?? 0);
5148 $firstMenuItemCode = (string)($params[
'firstMenuItemCode'] ??
'');
5149 $canViewTasks = (bool)($params[
'canView'][
'tasks'] ??
false);
5156 if ($componentName ===
'bitrix:socialnetwork_group')
5158 if ($firstMenuItemCode !==
'')
5161 mb_strpos($page, $firstMenuItemCode) !==
false
5162 || in_array($page, [
'group',
'group_general',
'group_tasks' ])
5168 $page ===
'group_tasks'
5169 && \CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $entityId,
'tasks')
5174 || $page ===
'group_general'
5185 'CARD' => (string)($componentResult[
'PATH_TO_GROUP_CARD'] ??
''),
5186 'EDIT' => (string)($componentResult[
'PATH_TO_GROUP_EDIT'] ??
''),
5187 'COPY' => (string)($componentResult[
'PATH_TO_GROUP_COPY'] ??
''),
5188 'DELETE' => (string)($componentResult[
'PATH_TO_GROUP_DELETE'] ??
''),
5189 'LEAVE' => (string)($componentResult[
'PATH_TO_USER_LEAVE_GROUP'] ??
''),
5190 'JOIN' => (string)($componentResult[
'PATH_TO_USER_REQUEST_GROUP'] ??
''),
5191 'MEMBERS' => (string)($componentResult[
'PATH_TO_GROUP_USERS'] ??
''),
5192 'REQUESTS_IN' => (string)($componentResult[
'PATH_TO_GROUP_REQUESTS'] ??
''),
5193 'REQUESTS_OUT' => (string)($componentResult[
'PATH_TO_GROUP_REQUESTS_OUT'] ??
''),
5194 'FEATURES' => (string)($componentResult[
'PATH_TO_GROUP_FEATURES'] ??
''),
5200 return array_filter($componentParameters,
static function ($key) {
5272 return (in_array($key, [
5277 }, ARRAY_FILTER_USE_KEY);
5282 return Main\Component\ParameterSigner::signParameters(self::getWorkgroupSliderMenuSignedParametersSalt(), $params);
5288 foreach ($sourceParametersList as $source)
5290 if (isset($source[
'signedParameters']) && is_string($source[
'signedParameters']))
5294 $componentParameters = ParameterSigner::unsignParameters(
5295 self::getWorkgroupSliderMenuSignedParametersSalt(),
5296 $source[
'signedParameters']
5298 $componentParameters[
'IFRAME'] =
'Y';
5299 return $componentParameters;
5313 return 'bitrix:socialnetwork.group.card.menu';
5323 $filePath = \CFile::getPath($fileId);
5324 if ((
string)$filePath ===
'')
5329 $signer = new \Bitrix\Main\Security\Sign\Signer;
5330 return $signer->sign(serialize([ $fileId, $filePath ]),
'workgroup_avatar_token');
5335 $params[$paramName] = (isset($params[$paramName]) && (int)$params[$paramName] > 0 ? (
int)$params[$paramName] : $defaultValue);
5340 $params[$paramName] = (isset($params[$paramName]) && trim($params[$paramName]) !==
'' ? trim($params[$paramName]) : $defaultValue);
5345 if (ModuleManager::isModuleInstalled(
'intranet'))
5357 $defaultProperties = [
5366 "PERSONAL_BIRTHDAY",
5372 $defaultProperties = [];
5376 'SHOW_FIELDS_TOOLTIP' => ($params[
'SHOW_FIELDS_TOOLTIP'] ?? unserialize(Option::get(
'socialnetwork',
'tooltip_fields', serialize($defaultFields)), [
'allowed_classes' =>
false])),
5377 'USER_PROPERTY_TOOLTIP' => ($params[
'USER_PROPERTY_TOOLTIP'] ?? unserialize(Option::get(
'socialnetwork',
'tooltip_properties', serialize($defaultProperties)), [
'allowed_classes' =>
false])),
5383 $workgroupName = (string)($params[
'WORKGROUP_NAME'] ??
'');
5384 $workgroupId = (int)($params[
'WORKGROUP_ID'] ?? 0);
5387 $workgroupName ===
''
5391 $groupFields = \CSocNetGroup::getById($workgroupId,
true);
5392 if (!empty($groupFields))
5394 $workgroupName = $groupFields[
'NAME'];
5398 return Loc::getMessage(
'SONET_HELPER_PAGE_TITLE_WORKGROUP_TEMPLATE', [
5399 '#WORKGROUP#' => $workgroupName,
5400 '#TITLE#' => ($params[
'TITLE'] ??
''),