3namespace Bitrix\Socialnetwork;
5use Bitrix\Blog\Item\Post;
6use Bitrix\Crm\Activity\Provider\Tasks\Task;
7use Bitrix\Main\Component\ParameterSigner;
10use Bitrix\Main\ModuleManager;
12use Bitrix\Main\Localization\Loc;
13use Bitrix\Main\Config\Option;
14use Bitrix\Main\EventManager;
15use Bitrix\Main\Security\Sign\BadSignatureException;
16use Bitrix\Main\Update\Stepper;
17use Bitrix\Main\UrlPreview\UrlPreview;
18use Bitrix\Socialnetwork\Item\Log;
19use Bitrix\Main\DB\SqlExpression;
20use Bitrix\Main\Application;
21use Bitrix\Disk\Uf\FileUserType;
22use Bitrix\Disk\AttachedObject;
24use Bitrix\Disk\TypeFile;
25use Bitrix\Socialnetwork\Helper\Mention;
26use Bitrix\Main\Web\Json;
27use Bitrix\Main\ArgumentException;
29Loc::loadMessages(__FILE__);
54 if (isset(self::$postsCache[$postId]))
56 $result = self::$postsCache[$postId];
60 if (!Loader::includeModule(
'blog'))
65 $res = \CBlogPost::getList(
72 [
'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' ]
77 if (!empty(
$result[
'DETAIL_TEXT']))
84 if(
$result[
"HAS_PROPS"] !==
"N")
87 $postUf = [
'UF_BLOG_POST_FILE' ];
88 foreach ($userFields as $fieldName => $userField)
90 if (!in_array($fieldName, $postUf))
92 unset($userFields[$fieldName]);
97 !empty($userFields[
"UF_BLOG_POST_FILE"])
98 && !empty($userFields[
"UF_BLOG_POST_FILE"][
"VALUE"])
113 $result[
"DETAIL_TEXT_FORMATTED"] = preg_replace(
115 '|\[DISK\sFILE\sID=[n]*\d+\]|',
116 '|\[DOCUMENT\sID=[n]*\d+\]|'
122 $result[
'DETAIL_TEXT_FORMATTED'] = Mention::clear(
$result[
'DETAIL_TEXT_FORMATTED']);
124 $p = new \blogTextParser();
125 $p->arUserfields = [];
128 $allow = [
'IMAGE' =>
'Y' ];
129 $parserParameters = [];
131 $result[
"DETAIL_TEXT_FORMATTED"] =
$p->convert(
$result[
"DETAIL_TEXT_FORMATTED"],
false, $images, $allow, $parserParameters);
140 '|\[MAIL\sDISK\sFILE\sID=[n]*\d+\]|',
145 $title = str_replace([
"\r\n",
"\n",
"\r" ],
" ",
$title);
150 self::$postsCache[$postId] =
$result;
166 if (isset(self::$destinationsCache[$postId]))
168 $result = self::$destinationsCache[$postId];
174 if (!Loader::includeModule(
'blog'))
179 $sonetPermission = \CBlogPost::getSocnetPermsName($postId);
180 if (!empty($sonetPermission))
182 foreach ($sonetPermission as $typeCode =>
$type)
184 foreach (
$type as $destination)
188 if ($typeCode ===
"SG")
190 if ($sonetGroup = \CSocNetGroup::getByID($destination[
"ENTITY_ID"]))
192 $name = $sonetGroup[
"NAME"];
195 elseif ($typeCode ===
"U")
197 if(in_array(
"US" . $destination[
"ENTITY_ID"], $destination[
"ENTITY"],
true))
200 Loader::includeModule(
'intranet');
204 $name = \CUser::formatName(
205 \CSite::getNameFormat(
false),
207 "NAME" => $destination[
"~U_NAME"],
208 "LAST_NAME" => $destination[
"~U_LAST_NAME"],
209 "SECOND_NAME" => $destination[
"~U_SECOND_NAME"],
210 "LOGIN" => $destination[
"~U_LOGIN"]
216 elseif ($typeCode ===
"DR")
218 $name = $destination[
"EL_NAME"];
229 self::$destinationsCache[$postId] =
$result;
246 if (isset(self::$authorsCache[$authorId]))
248 $result = self::$authorsCache[$authorId];
252 if (!Loader::includeModule(
'blog'))
257 $result = \CBlogUser::getUserInfo(
263 && (
int)
$params[
"AVATAR_SIZE"] > 0
267 "AVATAR_SIZE_COMMENT" => (
268 isset(
$params[
"AVATAR_SIZE_COMMENT"])
269 && (
int)
$params[
"AVATAR_SIZE_COMMENT"] > 0
270 ? (
int)
$params[
"AVATAR_SIZE_COMMENT"]
273 "RESIZE_IMMEDIATE" =>
"Y"
277 $result[
"NAME_FORMATTED"] = \CUser::formatName(
278 \CSite::getNameFormat(
false),
281 "LAST_NAME" =>
$result[
"~LAST_NAME"],
282 "SECOND_NAME" =>
$result[
"~SECOND_NAME"],
288 self::$authorsCache[$authorId] =
$result;
307 if (isset(self::$commentListsCache[$postId]))
309 $result = self::$commentListsCache[$postId];
315 if (!Loader::includeModule(
'blog'))
320 $p = new \blogTextParser();
322 $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' ];
327 $selectedFields[] =
"DATE_CREATE_TS";
330 $res = \CBlogComment::getList(
338 "nTopCount" =>
$params[
"COMMENTS_COUNT"]
345 self::processCommentData(
$comment, $languageId,
$p, [
"MAIL" => (isset(
$params[
"MAIL"]) &&
$params[
"MAIL"] ===
"Y" ?
"Y" :
"N") ]);
349 if (!in_array((
int)
$comment[
"AUTHOR_ID"], $authorIdList,
true))
351 $authorIdList[] = (int)
$comment[
"AUTHOR_ID"];
360 self::$commentListsCache[$postId] =
$result;
376 if (isset(self::$commentCountCache[$postId]))
378 $result = self::$commentCountCache[$postId];
382 if (!Loader::includeModule(
'blog'))
387 $selectedFields = [
'ID' ];
389 $result = \CBlogComment::getList(
393 "POST_ID" => $postId,
400 self::$commentCountCache[$postId] =
$result;
418 if (isset(self::$commentsCache[$commentId]))
420 $result = self::$commentsCache[$commentId];
424 $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" ];
429 $selectedFields[] =
"DATE_CREATE_TS";
432 $res = \CBlogComment::getList(
444 $p = new \blogTextParser();
446 self::processCommentData(
$comment, $languageId,
$p);
451 self::$commentsCache[$commentId] =
$result;
464 private static function processCommentData(&
$comment, $languageId,
$p,
$params = []): void
479 "mobile" => (isset(
$params[
"MOBILE"]) &&
$params[
"MOBILE"] ===
"Y"),
485 $comment[
"POST_TEXT_FORMATTED"] = $commentAuxProvider->getText();
486 $arComment[
"AUX_TYPE"] = $commentAuxProvider->getType();
493 $commentUf = [
'UF_BLOG_COMMENT_FILE' ];
494 foreach ($userFields as $fieldName => $userField)
496 if (!in_array($fieldName, $commentUf,
true))
498 unset($userFields[$fieldName]);
503 !empty($userFields[
"UF_BLOG_COMMENT_FILE"])
504 && !empty($userFields[
"UF_BLOG_COMMENT_FILE"][
"VALUE"])
512 && isset(
$comment[
"PROPS"][
"UF_BLOG_COMM_URL_PRV"])
515 unset(
$comment[
"PROPS"][
"UF_BLOG_COMM_URL_PRV"]);
527 $comment[
"POST_TEXT_FORMATTED"] = preg_replace(
529 '|\[DISK\sFILE\sID=[n]*\d+\]|',
530 '|\[DOCUMENT\sID=[n]*\d+\]|'
536 $comment[
'POST_TEXT_FORMATTED'] = Mention::clear(
$comment[
'POST_TEXT_FORMATTED']);
540 $p->arUserfields = [];
543 $allow = [
'IMAGE' =>
'Y' ];
544 $parserParameters = [];
546 $comment[
"POST_TEXT_FORMATTED"] =
$p->convert(
$comment[
"POST_TEXT_FORMATTED"],
false, $images, $allow, $parserParameters);
569 $entityType = (string)$entityType;
576 || $entityType ===
''
579 || !Loader::includeModule(
'mail')
585 $urlRes = \Bitrix\Mail\User::getReplyTo(
593 if (is_array($urlRes))
618 if (!Loader::includeModule(
'disk'))
631 foreach ($valueList as $value)
633 $attachedObject = AttachedObject::loadById($value, [
'OBJECT' ]);
636 || !$attachedObject->getFile()
642 $attachedObjectUrl = \Bitrix\Disk\UrlManager::getUrlUfController(
'show', [
'attachedId' => $value ]);
646 "OBJECT_ID" => $attachedObject->getFile()->getId(),
647 "NAME" => $attachedObject->getFile()->getName(),
648 "SIZE" => \CFile::formatSize($attachedObject->getFile()->getSize()),
649 "URL" => $attachedObjectUrl,
650 "IS_IMAGE" => TypeFile::isImage($attachedObject->getFile())
668 public static function getAttachmentUrlList($valueList = [], $entityType =
'',
$entityId = 0, $authorId = 0, $attachmentList = []):
array
674 || empty($attachmentList)
675 || (
int)$authorId <= 0
677 || !Loader::includeModule(
'disk')
683 $userFieldManager = Driver::getInstance()->getUserFieldManager();
684 [ $connectorClass,
$moduleId ] = $userFieldManager->getConnectorDataByEntityType($entityType);
686 foreach($valueList as $value)
688 $attachedFileId =
false;
689 $attachedObject =
false;
691 [
$type, $realValue ] = FileUserType::detectType($value);
692 if (
$type === FileUserType::TYPE_NEW_OBJECT)
694 $attachedObject = AttachedObject::load([
695 '=ENTITY_TYPE' => $connectorClass,
698 'OBJECT_ID'=> $realValue
703 $attachedFileId = $attachedObject->getId();
708 $attachedFileId = $realValue;
712 (
int)$attachedFileId > 0
713 && !empty($attachmentList[$attachedFileId])
716 if (!$attachmentList[$attachedFileId][
"IS_IMAGE"])
720 'URL' => $attachmentList[$attachedFileId][
"URL"]
725 if (!$attachedObject)
727 $attachedObject = AttachedObject::loadById($attachedFileId, [
'OBJECT' ]);
732 $file = $attachedObject->getFile();
734 $extLinks = $file->getExternalLinks([
736 'OBJECT_ID' => $file->getId(),
737 'CREATED_BY' => $authorId,
738 'TYPE' => \Bitrix\Disk\Internals\ExternalLinkTable::TYPE_MANUAL,
739 'IS_EXPIRED' =>
false,
744 if (empty($extLinks))
746 $externalLink = $file->addExternalLink([
747 'CREATED_BY' => $authorId,
748 'TYPE' => \Bitrix\Disk\Internals\ExternalLinkTable::TYPE_MANUAL,
754 $externalLink = reset($extLinks);
759 $originalFile = $file->getFile();
763 'URL' => Driver::getInstance()->getUrlManager()->getUrlExternalLink(
765 'hash' => $externalLink->getHash(),
766 'action' =>
'showFile'
770 'WIDTH' => (int)$originalFile[
"WIDTH"],
771 'HEIGHT' => (
int)$originalFile[
"HEIGHT"]
791 if (preg_match_all(
'|\[MAIL\sDISK\sFILE\sID=([n]*\d+)\]|',
$text,
$matches))
793 foreach(
$matches[1] as $inlineFileId)
795 $attachmentId =
false;
796 if (mb_strpos($inlineFileId,
'n') === 0)
799 foreach($attachmentList as $attachmentId => $attachment)
802 isset($attachment[
"OBJECT_ID"])
803 && (
int)$attachment[
"OBJECT_ID"] === (
int)mb_substr($inlineFileId, 1)
812 $attachmentId =
false;
817 $attachmentId = $inlineFileId;
820 if ((
int)$attachmentId > 0)
822 $text = preg_replace(
823 '|\[MAIL\sDISK\sFILE\sID='.$inlineFileId.
'\]|',
824 '[URL='.$attachmentList[$attachmentId][
"URL"].
']['.$attachmentList[$attachmentId][
"NAME"].
'][/URL]',
830 $p = new \CTextParser();
831 $p->allow = [
'HTML' =>
'Y',
'ANCHOR' =>
'Y' ];
851 $authorId = (int)$authorId;
852 $entityType = (string)$entityType;
857 || empty($attachmentList)
859 || $entityType ===
''
866 if (preg_match_all(
'|\[DISK\sFILE\sID=([n]*\d+)\]|',
$text,
$matches))
868 $attachmentUrlList = self::getAttachmentUrlList(
876 foreach(
$matches[1] as $inlineFileId)
878 if (!empty($attachmentUrlList[$inlineFileId]))
880 $needCreatePicture =
false;
881 $sizeSource = $sizeDestination = [];
883 $attachmentUrlList[$inlineFileId][
'WIDTH'], $attachmentUrlList[$inlineFileId][
'HEIGHT'],
885 $needCreatePicture, $sizeSource, $sizeDestination
889 $attachmentUrlList[$inlineFileId][
"TYPE"] ===
'image'
890 ?
'[IMG WIDTH='.(int)$sizeDestination[
'width'].
' HEIGHT='.(int)$sizeDestination[
'height'].
']'.\htmlspecialcharsBack($attachmentUrlList[$inlineFileId][
"URL"]).
'[/IMG]'
891 :
'[MAIL DISK FILE ID='.$inlineFileId.
']'
893 $text = preg_replace(
894 '|\[DISK\sFILE\sID='.$inlineFileId.
'\]|',
917 preg_match_all(
"#\\[disk file id=(n?\\d+)\\]#isu",
$text,
$matches)
918 && Loader::includeModule(
'disk')
921 $userFieldManager = Driver::getInstance()->getUserFieldManager();
926 [
$type, $realValue ] = FileUserType::detectType($id);
928 if (
$type === FileUserType::TYPE_NEW_OBJECT)
930 $fileModel = File::loadById($realValue);
938 $attachedModel = $userFieldManager->getAttachedObjectById($realValue);
944 $attachedModel->setOperableEntity([
945 'ENTITY_ID' => $ufData[
'ENTITY_ID'],
946 'ENTITY_VALUE_ID' => $ufData[
'ENTITY_VALUE_ID']
948 $fileModel = $attachedModel->getFile();
951 if(TypeFile::isImage($fileModel))
971 if (empty($dateTimeSource))
976 $serverTs =
\MakeTimeStamp($dateTimeSource) - \CTimeZone::getOffset();
977 $serverGMTOffset = (int)date(
'Z');
978 $authorOffset = (int)\CTimeZone::getOffset($authorId);
980 $authorGMTOffset = $serverGMTOffset + $authorOffset;
981 $authorGMTOffsetFormatted =
'GMT';
982 if ($authorGMTOffset !== 0)
984 $authorGMTOffsetFormatted .= ($authorGMTOffset >= 0 ?
'+' :
'-').sprintf(
'%02d', floor($authorGMTOffset / 3600)).
':'.sprintf(
'%02u', ($authorGMTOffset % 3600) / 60);
989 ($serverTs + $authorOffset)
990 ).
' ('.$authorGMTOffsetFormatted.
')';
1003 if (!Loader::includeModule(
'blog'))
1008 $cacheTtl = 3153600;
1009 $cacheId =
'blog_group_list_'.md5(serialize(
$params));
1010 $cacheDir =
'/blog/group/';
1011 $cache = new \CPHPCache;
1013 if($cache->initCache($cacheTtl, $cacheId, $cacheDir))
1019 $cache->startDataCache();
1021 $ideaBlogGroupIdList =
array();
1022 if (ModuleManager::isModuleInstalled(
"idea"))
1024 $res = \CSite::getList(
"sort",
"desc", Array(
"ACTIVE" =>
"Y"));
1027 $val = Option::get(
"idea",
"blog_group_id",
false,
$site[
"LID"]);
1030 $ideaBlogGroupIdList[] =
$val;
1036 if (!empty(
$params[
"SITE_ID"]))
1040 if (!empty($ideaBlogGroupIdList))
1042 $filter[
'!@ID'] = $ideaBlogGroupIdList;
1046 while($blogGroup =
$res->fetch())
1051 $cache->endDataCache(
$result);
1070 if (!Loader::includeModule(
'blog'))
1077 || (
int)
$params[
"BLOG_GROUP_ID"] <= 0
1078 || (
int)
$params[
"USER_ID"] <= 0
1079 || (
string)
$params[
"SITE_ID"] ===
''
1086 !isset(
$params[
"PATH_TO_BLOG"])
1087 ||
$params[
"PATH_TO_BLOG"] ==
''
1097 "=DATE_UPDATE" => $helper->getCurrentDateTimeFunction(),
1098 "=DATE_CREATE" => $helper->getCurrentDateTimeFunction(),
1099 "GROUP_ID" => (
int)
$params[
"BLOG_GROUP_ID"],
1101 "OWNER_ID" => (
int)
$params[
"USER_ID"],
1102 "ENABLE_COMMENTS" =>
"Y",
1103 "ENABLE_IMG_VERIF" =>
"Y",
1104 "EMAIL_NOTIFY" =>
"Y",
1105 "ENABLE_RSS" =>
"Y",
1106 "ALLOW_HTML" =>
"N",
1107 "ENABLE_TRACKBACK" =>
"N",
1108 "SEARCH_INDEX" =>
"Y",
1109 "USE_SOCNET" =>
"Y",
1110 "PERMS_POST" => Array(
1114 "PERMS_COMMENT" => Array(
1125 'select' =>
array(
"NAME",
"LAST_NAME",
"LOGIN")
1130 $fields[
"NAME"] = Loc::getMessage(
"BLG_NAME").
" ".(
1137 $urlCheck = preg_replace(
"/[^a-zA-Z0-9_-]/i",
"",
$fields[
"URL"]);
1138 if ($urlCheck !==
$fields[
"URL"])
1140 $fields[
"URL"] =
"u".$params[
"USER_ID"].
"-blog-".
$params[
"SITE_ID"];
1143 if(\CBlog::getByUrl(
$fields[
"URL"]))
1151 while (\CBlog::getByUrl(
$fields[
"URL"]));
1158 "user_id" =>
$fields[
"OWNER_ID"]
1162 $lock =
'blog_create_lock';
1169 if ($blogID = \CBlog::add(
$fields))
1173 $rightsFound =
false;
1175 $featureOperationPerms = \CSocNetFeaturesPerms::getOperationPerm(
1184 $rightsFound =
true;
1189 \CBlog::addSocnetRead($blogID);
1192 $result = \CBlog::getByID($blogID);
1209 static $parser =
false;
1219 $parser = new \CTextParser();
1227 preg_match_all(
"/\[url\s*=\s*([^\]]*)\](.+?)\[\/url\]/isu",
$text,
$res);
1236 $metaData = UrlPreview::getMetadataAndHtmlByUrl(
$url,
true,
false);
1239 && !empty($metaData[
"ID"])
1240 && (
int)$metaData[
"ID"] > 0
1243 $signer = new \Bitrix\Main\Security\Sign\Signer();
1244 $value = $signer->sign($metaData[
"ID"].
'', UrlPreview::SIGN_SALT);
1263 if ($uf[
"USER_TYPE"][
"USER_TYPE_ID"] !==
'url_preview')
1271 "bitrix:system.field.view",
1272 $uf[
"USER_TYPE"][
"USER_TYPE_ID"],
1274 "LAZYLOAD" => (isset(
$params[
"LAZYLOAD"]) &&
$params[
"LAZYLOAD"] ===
"Y" ?
"Y" :
"N"),
1275 "MOBILE" => (isset(
$params[
"MOBILE"]) &&
$params[
"MOBILE"] ===
"Y" ?
"Y" :
"N"),
1276 "arUserField" => $uf,
1277 "arAddField" =>
array(
1278 "NAME_TEMPLATE" => (
$params[
"NAME_TEMPLATE"] ??
false),
1279 "PATH_TO_USER" => (
$params[
"PATH_TO_USER"] ??
'')
1281 ),
null,
array(
"HIDE_ICONS"=>
"Y")
1284 $res = ob_get_clean();
1298 if (!ModuleManager::isModuleInstalled(
'extranet'))
1303 $ttl = (defined(
"BX_COMP_MANAGED_CACHE") ? 2592000 : 600);
1304 $cacheId =
'sonet_ex_userid';
1305 $cache = new \CPHPCache;
1306 $cacheDir =
'/bitrix/sonet/user_ex';
1308 if($cache->initCache($ttl, $cacheId, $cacheDir))
1310 $tmpVal = $cache->getVars();
1311 $result = $tmpVal[
'EX_USER_ID'];
1316 if (defined(
"BX_COMP_MANAGED_CACHE"))
1322 'UF_DEPARTMENT_SINGLE' =>
false
1326 if (!empty($externalAuthIdList))
1328 $filter[
'!=EXTERNAL_AUTH_ID'] = $externalAuthIdList;
1334 'select' =>
array(
'ID')
1343 $res = \Bitrix\Main\UserGroupTable::getList(
array(
1348 'select' => [
'USER_ID' ]
1350 while($relationFields =
$res->fetch())
1356 if (defined(
"BX_COMP_MANAGED_CACHE"))
1363 if($cache->startDataCache())
1365 $cache->endDataCache(
array(
1382 !ModuleManager::isModuleInstalled(
'mail')
1383 || !ModuleManager::isModuleInstalled(
'intranet')
1389 $ttl = (defined(
"BX_COMP_MANAGED_CACHE") ? 2592000 : 600);
1390 $cacheId =
'sonet_email_userid';
1391 $cache = new \CPHPCache;
1392 $cacheDir =
'/bitrix/sonet/user_email';
1394 if($cache->initCache($ttl, $cacheId, $cacheDir))
1396 $tmpVal = $cache->getVars();
1397 $result = $tmpVal[
'EMAIL_USER_ID'];
1402 if (defined(
"BX_COMP_MANAGED_CACHE"))
1410 '=EXTERNAL_AUTH_ID' =>
'email'
1412 'select' =>
array(
'ID')
1420 if (defined(
"BX_COMP_MANAGED_CACHE"))
1426 if($cache->startDataCache())
1428 $cache->endDataCache(
array(
1441 $ttl = (defined(
"BX_COMP_MANAGED_CACHE") ? 2592000 : 600);
1442 $cacheId =
'sonet_ex_groupid';
1443 $cache = new \CPHPCache;
1444 $cacheDir =
'/bitrix/sonet/group_ex';
1446 if($cache->initCache($ttl, $cacheId, $cacheDir))
1448 $tmpVal = $cache->getVars();
1449 $result = $tmpVal[
'EX_GROUP_ID'];
1452 elseif (Loader::includeModule(
'extranet'))
1455 if (defined(
"BX_COMP_MANAGED_CACHE"))
1463 "=WorkgroupSite:GROUP.SITE_ID" => \CExtranet::getExtranetSiteID()
1465 'select' =>
array(
'ID')
1468 while($sonetGroup =
$res->fetch())
1470 $result[] = $sonetGroup[
"ID"];
1471 if (defined(
"BX_COMP_MANAGED_CACHE"))
1477 if (defined(
"BX_COMP_MANAGED_CACHE"))
1483 if($cache->startDataCache())
1485 $cache->endDataCache(
array(
1498 if (empty(
$params[
"LOG_EVENT_ID"]))
1503 $commentEvent = \CSocNetLogTools::findLogCommentEventByLogEventID(
$params[
"LOG_EVENT_ID"]);
1506 isset($commentEvent[
"DELETE_CALLBACK"])
1507 && $commentEvent[
"DELETE_CALLBACK"] !==
"NO_SOURCE"
1511 $commentEvent[
"EVENT_ID"] ===
"crm_activity_add_comment"
1512 && isset(
$params[
"LOG_ENTITY_ID"])
1513 && (
int)
$params[
"LOG_ENTITY_ID"] > 0
1514 && Loader::includeModule(
'crm')
1517 $result = \CCrmActivity::getList(
1520 'ID' => (
int)
$params[
"LOG_ENTITY_ID"],
1521 'CHECK_PERMISSIONS' =>
'N'
1527 $res = ((int)
$activity[
'TYPE_ID'] === \CCrmActivityType::Task);
1542 $postId = (int)
$fields[
"POST_ID"];
1543 $blogId = (int)
$fields[
"BLOG_ID"];
1545 $sonetRights =
$fields[
"SONET_RIGHTS"];
1546 $newRights =
$fields[
"NEW_RIGHTS"];
1549 $clearCommentsCache = (!isset(
$params[
'CLEAR_COMMENTS_CACHE']) ||
$params[
'CLEAR_COMMENTS_CACHE'] !==
'N');
1555 Loader::includeModule(
'blog')
1556 && \CBlogPost::update($postId,
array(
"SOCNET_RIGHTS" => $sonetRights,
"HAS_SOCNET_ALL" =>
"N"))
1561 'POST_ID' => $postId
1564 'TYPE' =>
'post_general',
1565 'POST_ID' => $postId
1568 'TYPE' =>
'posts_popular',
1572 $logSiteListNew =
array();
1573 $user2NotifyList =
array();
1574 $sonetPermissionList = \CBlogPost::getSocnetPermsName($postId);
1575 $extranet = Loader::includeModule(
"extranet");
1576 $extranetSite = ($extranet ? \CExtranet::getExtranetSiteID() :
false);
1577 $tzOffset = \CTimeZone::getOffset();
1579 $res = \CBlogPost::getList(
1581 array(
"ID" => $postId),
1584 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")
1592 if (!empty(
$post[
'DETAIL_TEXT']))
1597 $intranetUserIdList = ($extranet ? \CExtranet::getIntranetUsers() :
false);
1598 $auxLiveParamList =
array();
1599 $sharedToIntranetUser =
false;
1601 foreach ($sonetPermissionList as
$type => $v)
1607 && in_array(
$type . $vv[
"ENTITY_ID"], $newRights,
true)
1611 $renderData = $renderParts->getData($vv[
"ENTITY_ID"]);
1613 if($sonetGroup = \CSocNetGroup::getByID($vv[
"ENTITY_ID"]))
1615 $res = \CSocNetGroup::getSite($vv[
"ENTITY_ID"]);
1616 while ($groupSiteList =
$res->fetch())
1618 $logSiteListNew[] = $groupSiteList[
"LID"];
1621 $auxLiveParamList[] =
array(
1622 "ENTITY_TYPE" =>
'SG',
1623 "ENTITY_ID" => $renderData[
'id'],
1624 "NAME" => $renderData[
'name'],
1625 "LINK" => $renderData[
'link'],
1626 "VISIBILITY" => ($sonetGroup[
"VISIBLE"] ===
"Y" ?
"all" :
"group_members")
1633 in_array(
"US" . $vv[
"ENTITY_ID"], $vv[
"ENTITY"],
true)
1634 && in_array(
"UA", $newRights,
true)
1638 $renderData = $renderParts->getData(0);
1640 $auxLiveParamList[] =
array(
1641 "ENTITY_TYPE" =>
'UA',
1642 "ENTITY_ID" =>
'UA',
1643 "NAME" => $renderData[
'name'],
1644 "LINK" => $renderData[
'link'],
1645 "VISIBILITY" =>
'all'
1648 elseif (in_array(
$type . $vv[
"ENTITY_ID"], $newRights,
true))
1651 $renderData = $renderParts->getData($vv[
"ENTITY_ID"]);
1653 $user2NotifyList[] = $vv[
"ENTITY_ID"];
1657 && is_array($intranetUserIdList)
1658 && !in_array($vv[
"ENTITY_ID"], $intranetUserIdList)
1661 $logSiteListNew[] = $extranetSite;
1662 $visibility =
'extranet';
1666 $sharedToIntranetUser =
true;
1667 $visibility =
'intranet';
1670 $auxLiveParamList[] =
array(
1671 "ENTITY_TYPE" =>
'U',
1672 "ENTITY_ID" => $renderData[
'id'],
1673 "NAME" => $renderData[
'name'],
1674 "LINK" => $renderData[
'link'],
1675 "VISIBILITY" => $visibility
1681 && in_array(
$type.$vv[
"ENTITY_ID"], $newRights)
1685 $renderData = $renderParts->getData($vv[
"ENTITY_ID"]);
1687 $auxLiveParamList[] =
array(
1688 "ENTITY_TYPE" =>
'DR',
1689 "ENTITY_ID" => $renderData[
'id'],
1690 "NAME" => $renderData[
'name'],
1691 "LINK" => $renderData[
'link'],
1692 "VISIBILITY" =>
'intranet'
1698 $userIP = \CBlogUser::getUserIP();
1705 $commentFields = Array(
1706 "POST_ID" => $postId,
1707 "BLOG_ID" => $blogId,
1708 "POST_TEXT" => $auxText,
1709 "DATE_CREATE" => convertTimeStamp(time() + $tzOffset,
"FULL"),
1710 "AUTHOR_IP" => $userIP[0],
1711 "AUTHOR_IP1" => $userIP[1],
1712 "PARENT_ID" =>
false,
1714 "SHARE_DEST" => implode(
",", $newRights).($mention ?
'|mention' :
''),
1719 if($commentId = \CBlogComment::add($commentFields,
false))
1721 if ($clearCommentsCache)
1724 'TYPE' =>
'post_comments',
1725 'POST_ID' => $postId
1735 htmlspecialcharsBack(
$params[
"PATH_TO_POST"]),
1737 "post_id" => $postId,
1738 "user_id" =>
$post[
"AUTHOR_ID"]
1745 \CBlogPost::notifyIm($fieldsIM);
1746 $userIdSent[] = array_merge($userIdSent, $fieldsIM[
"TO_USER_ID"]);
1749 if(!empty($user2NotifyList))
1752 "TYPE" =>
"SHARE2USERS",
1755 htmlspecialcharsBack(
$params[
"PATH_TO_POST"]),
1757 "post_id" => $postId,
1758 "user_id" =>
$post[
"AUTHOR_ID"]
1762 "TO_USER_ID" => $user2NotifyList,
1764 \CBlogPost::notifyIm($fieldsIM);
1765 $userIdSent[] = array_merge($userIdSent, $fieldsIM[
"TO_USER_ID"]);
1767 \CBlogPost::notifyMail(
array(
1768 "type" =>
"POST_SHARE",
1770 "userId" => $user2NotifyList,
1772 "postId" =>
$post[
"ID"],
1774 '/pub/post.php?post_id=#post_id#',
1776 "post_id"=>
$post[
"ID"]
1783 $blogPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\BlogPost;
1786 $res = \CSocNetLog::getList(
1787 array(
"ID" =>
"DESC"),
1789 "EVENT_ID" => $blogPostLivefeedProvider->getEventId(),
1790 "SOURCE_ID" => $postId
1794 array(
"ID",
"ENTITY_TYPE",
"ENTITY_ID",
"USER_ID",
"EVENT_ID")
1796 if ($logEntry =
$res->fetch())
1798 $logId = $logEntry[
"ID"];
1799 $logSiteList =
array();
1800 $res = \CSocNetLog::getSite($logId);
1801 while ($logSite =
$res->fetch())
1803 $logSiteList[] = $logSite[
"LID"];
1805 $logSiteListNew = array_unique(array_merge($logSiteListNew, $logSiteList));
1809 && $sharedToIntranetUser
1810 &&
count($logSiteListNew) == 1
1811 && $logSiteListNew[0] == $extranetSite
1814 $logSiteListNew[] = \CSite::getDefSite();
1818 'postId' => $postId,
1819 'authorId' =>
$post[
"AUTHOR_ID"]
1822 \CSocNetLogRights::deleteByLogID($logId);
1823 \CSocNetLogRights::add($logId, $socnetPerms,
true,
false);
1825 foreach($newRights as $GROUP_CODE)
1827 if (preg_match(
'/^U(\d+)$/', $GROUP_CODE,
$matches))
1833 'typeList' =>
array(
1835 'COUNTER_COMMENT_PUSH'
1837 'followDate' =>
'CURRENT'
1842 if (
count(array_diff($logSiteListNew, $logSiteList)) > 0)
1844 \CSocNetLog::update($logId,
array(
1845 "ENTITY_TYPE" => $logEntry[
"ENTITY_TYPE"],
1846 "SITE_ID" => $logSiteListNew
1855 $logCommentFields =
array(
1857 'ENTITY_ID' =>
$post[
"AUTHOR_ID"],
1858 'EVENT_ID' =>
'blog_comment',
1859 '=LOG_DATE' => $helper->getCurrentDateTimeFunction(),
1862 'MESSAGE' => $auxText,
1863 "TEXT_MESSAGE" => $auxText,
1864 'MODULE_ID' =>
false,
1865 'SOURCE_ID' => $commentId,
1866 'RATING_TYPE_ID' =>
'BLOG_COMMENT',
1867 'RATING_ENTITY_ID' => $commentId
1870 \CSocNetLogComments::add($logCommentFields,
false,
false);
1873 \CSocNetLogFollow::deleteByLogID($logId,
"Y",
true);
1881 'COUNTER_COMMENT_PUSH',
1883 'followDate' =>
'CURRENT',
1888 foreach($newRights as $v)
1890 if(mb_substr($v, 0, 2) ===
"SG")
1892 $groupId = (int)mb_substr($v, 2);
1895 \CSocNetGroup::setLastActivity($groupId);
1901 "EMAIL_FROM" => \COption::getOptionString(
"main",
"email_from",
"nobody@nobody.com"),
1902 "SOCNET_RIGHTS" => $newRights,
1903 "ENTITY_TYPE" =>
"POST",
1904 "ENTITY_ID" =>
$post[
"ID"],
1905 "AUTHOR_ID" =>
$post[
"AUTHOR_ID"],
1907 htmlspecialcharsBack(
$params[
"PATH_TO_POST"]),
1909 "post_id" =>
$post[
"ID"],
1910 "user_id" =>
$post[
"AUTHOR_ID"]
1913 "EXCLUDE_USERS" => $userIdSent
1919 "CONTEXT" =>
"blog_post",
1924 if (\
Bitrix\
Main\Loader::includeModule(
'crm'))
1926 \CCrmLiveFeedComponent::processCrmBlogPostRights($logId, $logEntry,
$post,
'share');
1938 'liveParamList' => $auxLiveParamList
1942 "PATH_TO_USER" =>
$params[
"PATH_TO_USER"],
1944 htmlspecialcharsBack(
$params[
"PATH_TO_POST"]),
1946 "post_id" =>
$post[
"ID"],
1947 "user_id" =>
$post[
"AUTHOR_ID"]
1950 "LOG_ID" => ($logId ? (
int)$logId : 0),
1952 "AUX_LIVE_PARAMS" =>
$provider->getLiveParams(),
1953 "CAN_USER_COMMENT" => (!empty(
$params[
"CAN_USER_COMMENT"]) &&
$params[
"CAN_USER_COMMENT"] ===
'Y' ?
'Y' :
'N')
1966 isset($_GET[
"entityType"])
1967 && $_GET[
"entityType"] <>
''
1970 $result[
"ENTITY_TYPE"] = $_GET[
"entityType"];
1974 isset($_GET[
"entityId"])
1975 && (
int)$_GET[
"entityId"] > 0
1978 $result[
"ENTITY_ID"] = (int)$_GET[
"entityId"];
2002 if (!is_array($authIdList))
2004 $authIdList =
array($authIdList);
2007 foreach($authIdList as
$key => $authId)
2010 $authId ===
'replica'
2011 && !ModuleManager::isModuleInstalled(
"replica")
2014 unset($authIdList[
$key]);
2018 $authId ===
'imconnector'
2019 && !ModuleManager::isModuleInstalled(
"imconnector")
2022 unset($authIdList[
$key]);
2027 && !ModuleManager::isModuleInstalled(
"im")
2030 unset($authIdList[
$key]);
2035 && !ModuleManager::isModuleInstalled(
"mail")
2038 unset($authIdList[
$key]);
2042 in_array($authId, [
'sale',
'shop' ])
2043 && !ModuleManager::isModuleInstalled(
"sale")
2046 unset($authIdList[
$key]);
2055 $optionValue = Option::get(
'socialnetwork',
'is_used',
false);
2059 Option::set(
'socialnetwork',
'is_used',
true);
2065 return (
bool)Option::get(
'socialnetwork',
'is_used',
false);
2070 if (!is_array($list))
2076 $sefFolder = (!empty(
$params[
"SEF_FOLDER"]) ?
$params[
"SEF_FOLDER"] :
false);
2078 foreach ($list as $value)
2081 empty($value[
"OPTION"])
2082 || empty($value[
"OPTION"][
"MODULE_ID"])
2083 || empty($value[
"OPTION"][
"NAME"])
2084 || empty($value[
"VALUE"])
2090 $optionValue = Option::get($value[
"OPTION"][
"MODULE_ID"], $value[
"OPTION"][
"NAME"],
false,
$siteId);
2095 !!($value[
"CHECK_SEF_FOLDER"] ??
false)
2097 && mb_substr(
$optionValue, 0, mb_strlen($sefFolder)) !== $sefFolder
2101 Option::set($value[
"OPTION"][
"MODULE_ID"], $value[
"OPTION"][
"NAME"], $value[
"VALUE"],
$siteId);
2112 $currentUserId =
$USER->getId();
2114 $useProjects = (!empty(
$params[
'useProjects']) &&
$params[
'useProjects'] ===
'Y' ?
'Y' :
'N');
2116 $landing = (!empty(
$params[
'landing']) &&
$params[
'landing'] ===
'Y' ?
'Y' :
'');
2118 $currentCache = \Bitrix\Main\Data\Cache::createInstance();
2120 $cacheTtl = defined(
"BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
2121 $cacheId =
'dest_group_'.$siteId.
'_'.$currentUserId.
'_'.$limit.$useProjects.$landing;
2122 $cacheDir =
'/sonet/dest_sonet_groups_v2/'.$siteId.
'/'.$currentUserId;
2124 if($currentCache->startDataCache($cacheTtl, $cacheId, $cacheDir))
2128 $limitReached =
false;
2131 'features' =>
array(
"blog",
array(
"premoderate_post",
"moderate_post",
"write_post",
"full_post")),
2133 'useProjects' => $useProjects,
2137 if ($landing ===
'Y')
2142 $groupList = \CSocNetLogDestination::getSocnetGroup(
$filter, $limitReached);
2144 if(defined(
"BX_COMP_MANAGED_CACHE"))
2147 foreach($groupList as $group)
2149 $CACHE_MANAGER->registerTag(
"sonet_features_G_".$group[
"entityId"]);
2152 $CACHE_MANAGER->registerTag(
"sonet_user2group_U".$currentUserId);
2153 $CACHE_MANAGER->registerTag(self::MAIN_SELECTOR_GROUPS_CACHE_TAG);
2154 if ($landing ===
'Y')
2160 $currentCache->endDataCache(
array(
2161 'groups' => $groupList,
2162 'limitReached' => $limitReached
2167 $tmp = $currentCache->getVars();
2168 $groupList =
$tmp[
'groups'];
2169 $limitReached =
$tmp[
'limitReached'];
2174 && \CSocNetUser::isCurrentUserModuleAdmin()
2177 $limitReached =
true;
2185 $canAddComments =
false;
2190 !is_array($logEntry)
2191 && (
int)$logEntry > 0
2194 $res = \CSocNetLog::getList(
2197 "ID" => (
int)$logEntry
2201 array(
"ID",
"ENTITY_TYPE",
"ENTITY_ID",
"EVENT_ID",
"USER_ID")
2204 if (!($logEntry =
$res->fetch()))
2206 return $canAddComments;
2211 !is_array($logEntry)
2213 || empty($logEntry[
"EVENT_ID"])
2216 return $canAddComments;
2220 !is_array($commentEvent)
2221 || empty($commentEvent)
2224 $commentEvent = \CSocNetLogTools::findLogCommentEventByLogEventID($logEntry[
"EVENT_ID"]);
2227 if (is_array($commentEvent))
2229 $feature = \CSocNetLogTools::findFeatureByEventID($commentEvent[
"EVENT_ID"]);
2232 array_key_exists(
"OPERATION_ADD", $commentEvent)
2233 && $commentEvent[
"OPERATION_ADD"] ===
"log_rights"
2236 $canAddComments = \CSocNetLogRights::checkForUser($logEntry[
"ID"],
$USER->getID());
2240 && array_key_exists(
"OPERATION_ADD", $commentEvent)
2241 && $commentEvent[
"OPERATION_ADD"] <>
''
2244 $canAddComments = \CSocNetFeaturesPerms::canPerformOperation(
2246 $logEntry[
"ENTITY_TYPE"],
2247 $logEntry[
"ENTITY_ID"],
2248 ($feature ===
"microblog" ?
"blog" : $feature),
2249 $commentEvent[
"OPERATION_ADD"],
2250 \CSocNetUser::isCurrentUserModuleAdmin()
2255 $canAddComments =
true;
2259 return $canAddComments;
2271 || !is_array($logEntry)
2273 || !is_array($commentEvent)
2274 || empty($commentEvent)
2280 $aux = !empty(
$params[
'AUX']);
2284 || !in_array(
$params[
"ACTION"],
array(
"ADD",
"UPDATE"))
2291 !isset(
$params[
"LANGUAGE_ID"])
2292 || empty(
$params[
"LANGUAGE_ID"])
2295 $params[
"LANGUAGE_ID"] = LANGUAGE_ID;
2306 if (
$params[
"ACTION"] ===
"ADD")
2309 !empty($commentEvent)
2310 && !empty($commentEvent[
"METHOD_CANEDIT"])
2313 && !empty($logEntry[
"SOURCE_ID"])
2314 && (
int)$logEntry[
"SOURCE_ID"] > 0
2317 $canEdit = call_user_func($commentEvent[
"METHOD_CANEDIT"],
array(
2318 "LOG_SOURCE_ID" => $logEntry[
"SOURCE_ID"],
2319 "COMMENT_SOURCE_ID" =>
$comment[
"SOURCE_ID"],
2329 $result[
"hasEditCallback"] = (
2331 && is_array($commentEvent)
2332 && isset($commentEvent[
"UPDATE_CALLBACK"])
2334 $commentEvent[
"UPDATE_CALLBACK"] ===
"NO_SOURCE"
2335 || is_callable($commentEvent[
"UPDATE_CALLBACK"])
2341 $result[
"hasDeleteCallback"] = (
2343 && is_array($commentEvent)
2344 && isset($commentEvent[
"DELETE_CALLBACK"])
2346 $commentEvent[
"DELETE_CALLBACK"] ===
"NO_SOURCE"
2347 || is_callable($commentEvent[
"DELETE_CALLBACK"])
2355 || (
int)
$params[
"SOURCE_ID"] <= 0
2358 foreach (EventManager::getInstance()->findEventHandlers(
'socialnetwork',
'OnAfterSonetLogEntryAddComment') as $handler)
2367 if (mb_strpos(
$key,
"~") === 0)
2373 $result[
"arComment"][
"RATING_USER_HAS_VOTED"] =
"N";
2376 $result[
"timestamp"] = makeTimeStamp(
2377 array_key_exists(
"LOG_DATE_FORMAT",
$comment)
2385 array_key_exists(
"UF_SONET_COM_DOC",
$comment[
"UF"])
2386 && array_key_exists(
"VALUE",
$comment[
"UF"][
"UF_SONET_COM_DOC"])
2387 && is_array(
$comment[
"UF"][
"UF_SONET_COM_DOC"][
"VALUE"])
2389 && $commentEvent[
"EVENT_ID"] !==
"tasks_comment"
2392 $logEntryRights =
array();
2393 $res = \CSocNetLogRights::getList(
array(),
array(
"LOG_ID" => $logEntry[
"ID"]));
2396 $logEntryRights[] =
$right[
"GROUP_CODE"];
2399 \CSocNetLogTools::setUFRights(
$comment[
"UF"][
"UF_SONET_COM_DOC"][
"VALUE"], $logEntryRights);
2402 $result[
'timeFormatted'] = formatDateFromDB(
2404 self::getTimeFormat(
$params[
'TIME_FORMAT'])
2407 $authorFields = self::getAuthorData([
2410 $createdBy = self::getCreatedByData([
2411 'userFields' => $authorFields,
2412 'languageId' =>
$params[
'LANGUAGE_ID'],
2413 'nameTemplate' =>
$params[
'NAME_TEMPLATE'],
2414 'showLogin' =>
$params[
'SHOW_LOGIN'],
2415 'pathToUser' =>
$params[
'PATH_TO_USER'],
2418 $commentFormatted =
array(
2419 'LOG_DATE' =>
$comment[
"LOG_DATE"],
2420 "LOG_DATE_FORMAT" =>
$comment[
"LOG_DATE_FORMAT"] ??
null,
2422 'LOG_TIME_FORMAT' =>
$result[
'timeFormatted'],
2424 "MESSAGE_FORMAT" =>
$comment[
"~MESSAGE"] ??
null,
2425 'CREATED_BY' => $createdBy,
2426 "AVATAR_SRC" => \CSocNetLogTools::formatEvent_CreateAvatar($authorFields,
$params,
""),
2431 array_key_exists(
"CLASS_FORMAT", $commentEvent)
2432 && array_key_exists(
"METHOD_FORMAT", $commentEvent)
2435 $fieldsFormatted = call_user_func(
2436 array($commentEvent[
"CLASS_FORMAT"], $commentEvent[
"METHOD_FORMAT"]),
2440 $commentFormatted[
"MESSAGE_FORMAT"] =
htmlspecialcharsback($fieldsFormatted[
"EVENT_FORMATTED"][
"MESSAGE"]);
2444 $commentFormatted[
"MESSAGE_FORMAT"] =
$comment[
"MESSAGE"];
2448 array_key_exists(
"CLASS_FORMAT", $commentEvent)
2449 && array_key_exists(
"METHOD_FORMAT", $commentEvent)
2452 $fieldsFormatted = call_user_func(
2453 array($commentEvent[
"CLASS_FORMAT"], $commentEvent[
"METHOD_FORMAT"]),
2466 $messageMobile =
$comment[
"MESSAGE"];
2469 $result[
"arCommentFormatted"] = $commentFormatted;
2477 'ID' => $logEntry[
'ID'],
2478 'EVENT_ID' => $logEntry[
'EVENT_ID'],
2479 'ENTITY_TYPE' => $logEntry[
'ENTITY_TYPE'],
2480 'ENTITY_ID' => $logEntry[
'ENTITY_ID'],
2481 'SOURCE_ID' => $logEntry[
'SOURCE_ID'],
2482 'PARAMS' => $logEntry[
'PARAMS'] ??
null
2485 $entityXMLId = $liveFeedCommentsParams[
'ENTITY_XML_ID'];
2493 $eventHandlerID = EventManager::getInstance()->addEventHandlerCompatible(
"main",
"system.field.view.file",
array(
"CSocNetLogTools",
"logUFfileShow"));
2494 $rights = \CSocNetLogComponent::getCommentRights([
2495 'EVENT_ID' => $logEntry[
'EVENT_ID'],
2496 'SOURCE_ID' => $logEntry[
'SOURCE_ID'],
2500 $postContentTypeId =
'';
2501 $commentContentTypeId =
'';
2504 $canGetCommentContent =
false;
2507 !empty($postContentId[
'ENTITY_TYPE'])
2509 && ($commentProvider = $postProvider->getCommentProvider())
2512 $postContentTypeId = $postProvider->getContentTypeId();
2513 $commentProviderClassName = get_class($commentProvider);
2514 $reflectionClass = new \ReflectionClass($commentProviderClassName);
2516 $canGetCommentContent = ($reflectionClass->getMethod(
'initSourceFields')->
class == $commentProviderClassName);
2517 if ($canGetCommentContent)
2519 $commentContentTypeId = $commentProvider->getContentTypeId();
2523 $records = static::getLiveCommentRecords([
2524 'commentId' => $listCommentId,
2525 'ratingTypeId' =>
$comment[
'RATING_TYPE_ID'],
2526 'timestamp' =>
$result[
'timestamp'],
2528 'ID' => $authorFields[
'ID'],
2529 'NAME' => $authorFields[
'NAME'],
2530 'LAST_NAME' => $authorFields[
'LAST_NAME'],
2531 'SECOND_NAME' => $authorFields[
'SECOND_NAME'],
2532 'PERSONAL_GENDER' => $authorFields[
'PERSONAL_GENDER'],
2533 'AVATAR' => $commentFormatted[
'AVATAR_SRC'],
2536 'ufFormatted' => $commentFormatted[
'UF'] ??
null,
2537 'postMessageTextOriginal' =>
$comment[
'~MESSAGE'] ??
null,
2538 'postMessageTextFormatted' => $commentFormatted[
'MESSAGE_FORMAT'],
2539 'mobileMessage' => $messageMobile,
2540 'aux' => (
$params[
'AUX'] ??
''),
2541 'auxLiveParams' => (
$params[
'AUX_LIVE_PARAMS'] ?? []),
2544 $viewUrl = (string)(
$comment[
'EVENT'][
'URL'] ??
'');
2545 if (empty($viewUrl))
2547 $pathToLogEntry = (string)(
$params[
'PATH_TO_LOG_ENTRY'] ??
'');
2548 if (!empty($pathToLogEntry))
2553 'log_id' => $logEntry[
'ID']
2555 ) . (mb_strpos($pathToLogEntry,
'?') ===
false ?
'?' :
'&') .
'commentId=#ID#';
2559 $rights[
'COMMENT_RIGHTS_CREATETASK'] = (
2560 $canGetCommentContent
2561 && ModuleManager::isModuleInstalled(
'tasks')
2566 $res = static::sendLiveComment([
2567 'ratingTypeId' =>
$comment[
'RATING_TYPE_ID'],
2568 'entityXMLId' => $entityXMLId,
2569 'postContentTypeId' => $postContentTypeId,
2570 'commentContentTypeId' => $commentContentTypeId,
2571 'records' => $records,
2573 'commentId' => $listCommentId,
2574 'action' => (
$params[
'ACTION'] ===
'UPDATE' ?
'EDIT' :
'REPLY'),
2577 'edit' =>
"__logEditComment('" . $entityXMLId .
"', '#ID#', '" . $logEntry[
"ID"] .
"');",
2578 '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'],
2580 'avatarSize' =>
$params[
'AVATAR_SIZE_COMMENT'] ??
null,
2581 'nameTemplate' =>
$params[
'NAME_TEMPLATE'],
2582 'dateTimeFormat' =>
$params[
'DATE_TIME_FORMAT'] ??
null,
2585 if ($eventHandlerID > 0)
2587 EventManager::getInstance()->removeEventHandler(
'main',
'system.field.view.file', $eventHandlerID);
2601 $languageId = (string)(
$params[
'siteId'] ?? LANGUAGE_ID);
2602 $entityXmlId = (string)(
$params[
'entityXmlId'] ??
'');
2603 $nameTemplate = (string)(
$params[
'nameTemplate'] ??
'');
2604 $showLogin = (string)(
$params[
'showLogin'] ??
'N');
2605 $pathToUser = (string)(
$params[
'pathToUser'] ??
'');
2606 $avatarSize = (int)(
$params[
'avatarSize'] ?? 100);
2608 $postProvider =
$params[
'postProvider'];
2609 $commentProvider =
$params[
'commentProvider'];
2613 || !$commentProvider
2619 $commentId = $commentProvider->getEntityId();
2620 $ratingTypeId = $commentProvider->getRatingTypeId();
2621 $commentDateTime = $commentProvider->getSourceDateTime();
2622 $commentAuthorId = $commentProvider->getSourceAuthorId();
2623 $commentText = $commentProvider->getSourceDescription();
2624 $userTypeEntityId = $commentProvider->getUserTypeEntityId();
2625 $commentContentTypeId = $commentProvider->getContentTypeId();
2627 $postContentTypeId = $postProvider->getContentTypeId();
2629 $timestamp = ($commentDateTime ? makeTimeStamp($commentDateTime) : 0);
2631 if (!empty($userTypeEntityId))
2636 $timeFormatted = formatDateFromDB($commentDateTime, self::getTimeFormat());
2638 $authorFields = self::getAuthorData([
2639 'userId' => $commentAuthorId,
2642 $createdBy = self::getCreatedByData([
2643 'userFields' => $authorFields,
2644 'languageId' => $languageId,
2645 'nameTemplate' => $nameTemplate,
2646 'showLogin' => $showLogin,
2647 'pathToUser' => $pathToUser,
2650 $commentFormatted = [
2651 'LOG_DATE' => $commentDateTime->toString(),
2652 "LOG_DATE_FORMAT" =>
$comment[
"LOG_DATE_FORMAT"],
2653 'LOG_DATE_DAY' => convertTimeStamp($timestamp,
'SHORT'),
2654 'LOG_TIME_FORMAT' => $timeFormatted,
2655 'MESSAGE' => $commentText,
2656 'MESSAGE_FORMAT' => $commentText,
2657 'CREATED_BY' => $createdBy,
2658 'AVATAR_SRC' => \CSocNetLogTools::formatEvent_CreateAvatar($authorFields, [
2659 'AVATAR_SIZE' => $avatarSize,
2661 'USER_ID' => $commentAuthorId,
2666 && $commentProvider->getContentTypeId() ===
Livefeed\ForumPost::CONTENT_TYPE_ID
2669 $feedParams = $commentProvider->getFeedParams();
2670 if (!empty($feedParams[
'xml_id']))
2672 $entityXmlId = $feedParams[
'xml_id'];
2676 if (empty($entityXmlId))
2682 'COMMENT_RIGHTS_EDIT' =>
'N',
2683 'COMMENT_RIGHTS_DELETE' =>
'N',
2684 'COMMENT_RIGHTS_CREATETASK' =>
'N'
2687 $records = static::getLiveCommentRecords([
2688 'commentId' => $commentId,
2689 'ratingTypeId' => $ratingTypeId,
2690 'timestamp' => $timestamp,
2692 'ID' => $authorFields[
'ID'],
2693 'NAME' => $authorFields[
'NAME'],
2694 'LAST_NAME' => $authorFields[
'LAST_NAME'],
2695 'SECOND_NAME' => $authorFields[
'SECOND_NAME'],
2696 'PERSONAL_GENDER' => $authorFields[
'PERSONAL_GENDER'],
2697 'AVATAR' => $commentFormatted[
'AVATAR_SRC'],
2700 'ufFormatted' => $commentFormatted[
'UF'],
2701 'postMessageTextOriginal' =>
$comment[
'~MESSAGE'],
2702 'postMessageTextFormatted' => $commentFormatted[
'MESSAGE_FORMAT'],
2703 'mobileMessage' => $commentText,
2704 'aux' => (
$params[
'aux'] ??
''),
2705 'auxLiveParams' => (
$params[
'auxLiveParams'] ?? []),
2723 $res = static::sendLiveComment([
2724 'ratingTypeId' => $ratingTypeId,
2725 'entityXMLId' => $entityXmlId,
2726 'postContentTypeId' => $postContentTypeId,
2727 'commentContentTypeId' => $commentContentTypeId,
2728 'records' => $records,
2730 'commentId' => $commentId,
2731 'action' =>
'REPLY',
2737 'avatarSize' => $avatarSize,
2738 'nameTemplate' => $nameTemplate,
2756 'select' => [
'ID',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'LOGIN',
'PERSONAL_PHOTO',
'PERSONAL_GENDER' ]
2759 if ($userFields =
$res->fetch())
2775 $languageId = (
$params[
'languageId'] ??
null);
2776 $nameTemplate = (string)(
$params[
'nameTemplate'] ??
'');
2777 $showLogin = (string)(
$params[
'showLogin'] ??
'N');
2778 $pathToUser = (string)(
$params[
'pathToUser'] ??
'');
2780 if (!empty($userFields))
2783 'FORMATTED' => \CUser::formatName($nameTemplate, $userFields, ($showLogin !==
'N')),
2784 'URL' => \CComponentEngine::makePathFromTemplate(
2787 'user_id' => $userFields[
'ID'],
2788 'id' => $userFields[
'ID'],
2796 'FORMATTED' => Loc::getMessage(
'SONET_HELPER_CREATED_BY_ANONYMOUS',
false, $languageId)
2804 private static function getTimeFormat($siteTimeFormat =
''): string
2806 if (empty($siteTimeFormat))
2808 $siteTimeFormat = \CSite::getTimeFormat();
2812 mb_stripos($siteTimeFormat,
'a')
2814 $siteTimeFormat ===
'FULL'
2827 $commentId = (int)(
$params[
'commentId'] ?? 0);
2828 $ratingTypeId = (string)(
$params[
'ratingTypeId'] ??
'');
2829 $timestamp = (int)(
$params[
'timestamp'] ?? 0);
2832 $ufFormatted = (string)(
$params[
'ufFormatted'] ??
'');
2833 $postMessageTextOriginal = (string)(
$params[
'postMessageTextOriginal'] ??
'');
2834 $postMessageTextFormatted = (string)(
$params[
'postMessageTextFormatted'] ??
'');
2835 $mobileMessage = (string)(
$params[
'mobileMessage'] ??
'');
2836 $aux = (string)(
$params[
'aux'] ??
'');
2837 $auxLiveParams = (
array)(
$params[
'auxLiveParams'] ?? []);
2842 'RATING_VOTE_ID' => $ratingTypeId .
'_' . $commentId .
'-' . (time() + random_int(0, 1000)),
2844 'POST_TIMESTAMP' => $timestamp,
2845 'AUTHOR' => $author,
2848 '~POST_MESSAGE_TEXT' => $postMessageTextOriginal,
2851 'POST_MESSAGE_TEXT' => $postMessageTextFormatted,
2852 'AFTER' => $ufFormatted,
2856 'POST_MESSAGE_TEXT' => $mobileMessage
2859 'AUX_LIVE_PARAMS' => $auxLiveParams,
2865 && !empty($uf[
'UF_SONET_COM_DOC'])
2866 && !empty($uf[
'UF_SONET_COM_DOC'][
'VALUE'])
2870 $inlineDiskAttachedObjectIdImageList = self::getInlineDiskImages([
2871 'text' => $postMessageTextOriginal,
2872 'commentId' => $commentId,
2875 if (!empty($inlineDiskAttachedObjectIdImageList))
2877 $records[$commentId][
'WEB'][
'UF'] = $records[$commentId][
'UF'];
2878 $records[$commentId][
'MOBILE'][
'UF'] = $records[$commentId][
'UF'];
2879 $records[$commentId][
'MOBILE'][
'UF'][
'UF_SONET_COM_DOC'][
'VALUE'] = array_diff($records[$commentId][
'MOBILE'][
'UF'][
'UF_SONET_COM_DOC'][
'VALUE'], $inlineDiskAttachedObjectIdImageList);
2890 $ratingTypeId = (string)(
$params[
'ratingTypeId'] ??
'');
2891 $entityXMLId = (string)(
$params[
'entityXMLId'] ??
'');
2892 $postContentTypeId = (string)(
$params[
'postContentTypeId'] ??
'');
2893 $commentContentTypeId = (string)(
$params[
'commentContentTypeId'] ??
'');
2896 $commentId = (int)(
$params[
'commentId'] ?? 0);
2899 $avatarSize = (int)(
$params[
'avatarSize'] ?? 0);
2900 $nameTemplate = (string)(
$params[
'nameTemplate'] ??
'');
2901 $showLogin = (isset(
$params[
'showLogin']) &&
$params[
'showLogin'] ===
'Y' ?
'Y' :
'N');
2902 $dateTimeFormat = (string)(
$params[
'dateTimeFormat'] ??
'');
2905 'bitrix:main.post.list',
2908 'TEMPLATE_ID' =>
'',
2909 'RATING_TYPE_ID' => $ratingTypeId,
2910 'ENTITY_XML_ID' => $entityXMLId,
2911 'POST_CONTENT_TYPE_ID' => $postContentTypeId,
2912 'COMMENT_CONTENT_TYPE_ID' => $commentContentTypeId,
2913 'RECORDS' => $records,
2919 'EDIT' =>
$rights[
'COMMENT_RIGHTS_EDIT'],
2920 'DELETE' =>
$rights[
'COMMENT_RIGHTS_DELETE'],
2921 'CREATETASK' =>
$rights[
'COMMENT_RIGHTS_CREATETASK'],
2923 'VISIBLE_RECORDS_COUNT' => 1,
2924 'ERROR_MESSAGE' =>
'',
2926 'RESULT' => $commentId,
2931 'MODE' =>
'PULL_MESSAGE',
2932 'VIEW_URL' => ($urlList[
'view'] ??
''),
2933 'EDIT_URL' => ($urlList[
'edit'] ??
''),
2934 'MODERATE_URL' =>
'',
2935 'DELETE_URL' => ($urlList[
'delete'] ??
''),
2937 'AVATAR_SIZE' => $avatarSize,
2938 'NAME_TEMPLATE' => $nameTemplate,
2939 'SHOW_LOGIN' => $showLogin,
2940 'DATE_TIME_FORMAT' => $dateTimeFormat,
2943 'NOTIFY_TEXT' =>
'',
2944 'SHOW_MINIMIZED' =>
'Y',
2945 'SHOW_POST_FORM' =>
'Y',
2960 $commentId = (int)(
$params[
'commentId'] ?? 0);
2965 || !ModuleManager::isModuleInstalled(
'disk')
2971 $inlineDiskObjectIdList = [];
2972 $inlineDiskAttachedObjectIdList = [];
2975 if (preg_match_all(
'#\\[disk file id=(n\\d+)\\]#isu',
$text,
$matches))
2977 $inlineDiskObjectIdList = array_map(
function(
$a) {
return (
int)mb_substr(
$a, 1); },
$matches[1]);
2981 if (preg_match_all(
'#\\[disk file id=(\\d+)\\]#isu',
$text,
$matches))
2983 $inlineDiskAttachedObjectIdList = array_map(
function(
$a) {
return (
int)
$a; },
$matches[1]);
2988 empty($inlineDiskObjectIdList)
2989 && empty($inlineDiskAttachedObjectIdList)
2991 || !Loader::includeModule(
'disk')
2998 '=OBJECT.TYPE_FILE' => TypeFile::IMAGE
3002 if (!empty($inlineDiskObjectIdList))
3004 $subFilter[
'@OBJECT_ID'] = $inlineDiskObjectIdList;
3006 elseif (!empty($inlineDiskAttachedObjectIdList))
3008 $subFilter[
'@ID'] = $inlineDiskAttachedObjectIdList;
3011 if(
count($subFilter) > 1)
3013 $subFilter[
'LOGIC'] =
'OR';
3021 $res = \Bitrix\Disk\Internals\AttachedObjectTable::getList([
3023 'select' =>
array(
'ID',
'ENTITY_ID')
3026 while ($attachedObjectFields =
$res->fetch())
3028 if ((
int)$attachedObjectFields[
'ENTITY_ID'] === $commentId)
3030 $result[] = (int)$attachedObjectFields[
'ID'];
3040 empty($HTTPPost[
"SPERM"])
3041 || empty($HTTPPost[
"SPERM"][
"UE"])
3042 || !is_array($HTTPPost[
"SPERM"][
"UE"])
3049 foreach ($HTTPPost[
"SPERM"][
"UE"] as $invitedEmail)
3051 $name = (!empty($HTTPPost[
"INVITED_USER_NAME"][$invitedEmail]) ? $HTTPPost[
"INVITED_USER_NAME"][$invitedEmail] :
'');
3052 $lastName = (!empty($HTTPPost[
"INVITED_USER_LAST_NAME"][$invitedEmail]) ? $HTTPPost[
"INVITED_USER_LAST_NAME"][$invitedEmail] :
'');
3054 $createCrmContact = (
3055 !empty($HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"][$invitedEmail])
3056 && $HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"][$invitedEmail] ===
'Y'
3063 'LAST_NAME' => $lastName,
3064 'LOGIN' => $invitedEmail
3070 $componentResult[
"PostToShow"][
"FEED_DESTINATION"][
'USERS'][$invitedEmail] = [
3071 'id' => $invitedEmail,
3072 'email' => $invitedEmail,
3076 'isCrmEmail' => ($createCrmContact ?
'Y' :
'N'),
3079 'lastName' => $lastName,
3080 'createCrmContact' => $createCrmContact,
3083 $componentResult[
"PostToShow"][
"FEED_DESTINATION"][
'SELECTED'][$invitedEmail] =
'users';
3090 if (isset($HTTPPost[
'SONET_PERMS']))
3092 $HTTPPost[
'SPERM'] = $HTTPPost[
'SONET_PERMS'];
3100 $HTTPPost[
'SONET_PERMS'] = $HTTPPost[
'SPERM'];
3101 unset($HTTPPost[
'SPERM']);
3105 private static function processUserEmail(
$params, &$errorText):
array
3113 || !Loader::includeModule(
'mail')
3119 $userEmail =
$params[
'EMAIL'];
3129 $res = \CUser::getList(
3133 '=EMAIL' => $userEmail,
3134 '!EXTERNAL_AUTH_ID' => array_diff(\
Bitrix\Main\UserTable::getExternalUserTypes(), [
'email' ]),
3137 'FIELDS' => [
'ID',
'EXTERNAL_AUTH_ID',
'ACTIVE' ]
3144 ($emailUser =
$res->fetch())
3149 (
int)$emailUser[
"ID"] > 0
3151 $emailUser[
"ACTIVE"] ===
"Y"
3152 || $emailUser[
"EXTERNAL_AUTH_ID"] ===
"email"
3156 if ($emailUser[
"ACTIVE"] ===
"N")
3159 $user->update($emailUser[
"ID"], [
3177 $userFields =
array(
3178 'EMAIL' => $userEmail,
3179 'NAME' => (
$params[
"NAME"] ??
''),
3180 'LAST_NAME' => (
$params[
"LAST_NAME"] ??
'')
3185 && Loader::includeModule(
'crm')
3188 $userFields[
'UF'] = [
3189 'UF_USER_CRM_ENTITY' =>
$params[
"CRM_ENTITY"],
3191 $res = \CCrmLiveFeedComponent::resolveLFEntityFromUF(
$params[
"CRM_ENTITY"]);
3200 $k === \CCrmLiveFeedEntity::Contact
3201 && ($contact = \CCrmContact::getById($v))
3202 && (
int)$contact[
'PHOTO'] > 0
3205 $userFields[
'PERSONAL_PHOTO_ID'] = (int)$contact[
'PHOTO'];
3211 !empty(
$params[
"CREATE_CRM_CONTACT"])
3212 &&
$params[
"CREATE_CRM_CONTACT"] ===
'Y'
3213 && Loader::includeModule(
'crm')
3214 && ($contactId = \CCrmLiveFeedComponent::createContact($userFields))
3217 $userFields[
'UF'] = [
3218 'UF_USER_CRM_ENTITY' =>
'C_'.$contactId
3220 $result[] =
"CRMCONTACT".$contactId;
3224 $userId = \Bitrix\Mail\User::create($userFields);
3254 \Bitrix\Main\UI\Selector\Entities::save([
3255 'context' => (isset(
$params[
'CONTEXT']) &&
$params[
'CONTEXT'] <>
'' ?
$params[
'CONTEXT'] :
'BLOG_POST'),
3259 if (Loader::includeModule(
'intranet') && class_exists(
'\Bitrix\Intranet\Integration\Mail\EmailUser'))
3261 \Bitrix\Intranet\Integration\Mail\EmailUser::invite(
$userId);
3270 foreach($destinationList as
$key =>
$code)
3278 $destRes = self::processUserEmail(
array(
3279 'EMAIL' => $userEmail,
3280 'CONTEXT' =>
'BLOG_POST'
3285 && is_array($destRes)
3288 unset($destinationList[
$key]);
3289 $destinationList = array_merge($destinationList, $destRes);
3298 isset($HTTPPost[
"SPERM"][
"U"])
3299 && is_array($HTTPPost[
"SPERM"][
"U"])
3300 && !empty($HTTPPost[
"SPERM"][
"U"])
3304 $componentResult[
"ALLOW_EMAIL_INVITATION"]
3305 && isset($HTTPPost[
"SPERM"][
"UE"])
3306 && is_array($HTTPPost[
"SPERM"][
"UE"])
3307 && !empty($HTTPPost[
"SPERM"][
"UE"])
3312 && Loader::includeModule(
'mail')
3317 && Loader::includeModule(
'crm')
3320 $userIdList =
array();
3321 foreach ($HTTPPost[
"SPERM"][
"U"] as
$code)
3329 if (!empty($userIdList))
3333 'ID' => $userIdList,
3334 '!=UF_USER_CRM_ENTITY' =>
false
3336 'select' =>
array(
'ID',
'UF_USER_CRM_ENTITY')
3340 $livefeedCrmEntity = \CCrmLiveFeedComponent::resolveLFEntityFromUF(
$user[
'UF_USER_CRM_ENTITY']);
3342 if (!empty($livefeedCrmEntity))
3344 list(
$k, $v) = $livefeedCrmEntity;
3347 if (!isset($HTTPPost[
"SPERM"][
$k]))
3349 $HTTPPost[
"SPERM"][
$k] =
array();
3351 $HTTPPost[
"SPERM"][
$k][] =
$k.$v;
3360 foreach ($HTTPPost[
"SPERM"][
"UE"] as
$key => $userEmail)
3369 $destRes = self::processUserEmail([
3370 'EMAIL' => $userEmail,
3372 isset($HTTPPost[
"INVITED_USER_NAME"])
3373 && isset($HTTPPost[
"INVITED_USER_NAME"][$userEmail])
3374 ? $HTTPPost[
"INVITED_USER_NAME"][$userEmail]
3378 isset($HTTPPost[
"INVITED_USER_LAST_NAME"])
3379 && isset($HTTPPost[
"INVITED_USER_LAST_NAME"][$userEmail])
3380 ? $HTTPPost[
"INVITED_USER_LAST_NAME"][$userEmail]
3384 isset($HTTPPost[
"INVITED_USER_CRM_ENTITY"])
3385 && isset($HTTPPost[
"INVITED_USER_CRM_ENTITY"][$userEmail])
3386 ? $HTTPPost[
"INVITED_USER_CRM_ENTITY"][$userEmail]
3389 "CREATE_CRM_CONTACT" => (
3390 isset($HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"])
3391 && isset($HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"][$userEmail])
3392 ? $HTTPPost[
"INVITED_USER_CREATE_CRM_CONTACT"][$userEmail]
3395 'CONTEXT' =>
'BLOG_POST'
3398 foreach($destRes as
$code)
3402 $HTTPPost[
"SPERM"][
"U"][] =
$code;
3405 Loader::includeModule(
'crm')
3406 && (preg_match(
'/^CRM(CONTACT|COMPANY|LEAD|DEAL)(\d+)$/i',
$code,
$matches))
3409 if (!isset($HTTPPost[
"SPERM"][
"CRM".
$matches[1]]))
3411 $HTTPPost[
"SPERM"][
"CRM".$matches[1]] =
array();
3413 $HTTPPost[
"SPERM"][
"CRM".$matches[1]][] =
$code;
3417 if (!empty($errorText))
3419 $componentResult[
"ERROR_MESSAGE"] .= $errorText;
3442 $currentCache = \Bitrix\Main\Data\Cache::createInstance();
3444 $cacheTtl = defined(
"BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
3445 $cacheId =
'user_group_member'.$siteId.
'_'.
$userId;
3446 $cacheDir =
'/sonet/user_group_member/'.$siteId.
'/'.
$userId;
3448 if($currentCache->startDataCache($cacheTtl, $cacheId, $cacheDir))
3456 '=GROUP.ACTIVE' =>
'Y',
3457 '=GROUP.WorkgroupSite:GROUP.SITE_ID' =>
$siteId
3459 'select' =>
array(
'GROUP_ID')
3462 while ($record =
$res->fetch())
3464 $result[] = $record[
"GROUP_ID"];
3467 if(defined(
"BX_COMP_MANAGED_CACHE"))
3473 $currentCache->endDataCache(
$result);
3477 $result = $currentCache->getVars();
3493 $allowToAll = (Option::get(
"socialnetwork",
"allow_livefeed_toall",
"Y") ===
"Y");
3497 $toAllRightsList = unserialize(Option::get(
"socialnetwork",
"livefeed_toall_rights",
'a:1:{i:0;s:2:"AU";}'), [
'allowed_classes' =>
false ]);
3498 if (!$toAllRightsList)
3500 $toAllRightsList =
array(
"AU");
3503 $userGroupCodeList = array_merge(
array(
"AU"), \CAccess::getUserCodesArray(
$userId));
3504 if (
count(array_intersect($toAllRightsList, $userGroupCodeList)) <= 0)
3506 $allowToAll =
false;
3516 if (ModuleManager::isModuleInstalled(
'blog'))
3518 $res[
"blog"] =
array(
'Bitrix\Blog\Update\LivefeedIndexPost',
'Bitrix\Blog\Update\LivefeedIndexComment');
3520 if (ModuleManager::isModuleInstalled(
'tasks'))
3522 $res[
"tasks"] =
array(
'Bitrix\Tasks\Update\LivefeedIndexTask');
3524 if (ModuleManager::isModuleInstalled(
'calendar'))
3526 $res[
"calendar"] =
array(
'Bitrix\Calendar\Update\LivefeedIndexCalendar');
3528 if (ModuleManager::isModuleInstalled(
'forum'))
3530 $res[
"forum"] =
array(
'Bitrix\Forum\Update\LivefeedIndexMessage',
'Bitrix\Forum\Update\LivefeedIndexComment');
3532 if (ModuleManager::isModuleInstalled(
'xdimport'))
3534 $res[
"xdimport"] =
array(
'Bitrix\XDImport\Update\LivefeedIndexLog',
'Bitrix\XDImport\Update\LivefeedIndexComment');
3536 if (ModuleManager::isModuleInstalled(
'wiki'))
3538 $res[
"wiki"] =
array(
'Bitrix\Wiki\Update\LivefeedIndexLog',
'Bitrix\Wiki\Update\LivefeedIndexComment');
3542 echo Stepper::getHtml(
$res, Loc::getMessage(ModuleManager::isModuleInstalled(
'intranet') ?
'SONET_HELPER_STEPPER_LIVEFEED2':
'SONET_HELPER_STEPPER_LIVEFEED'));
3555 if (ModuleManager::isModuleInstalled(
'crm'))
3557 $select[] =
'UF_USER_CRM_ENTITY';
3566 if ($userFields =
$res->fetch())
3570 'onUserProfileRedirectGetUrl',
3572 'userFields' => $userFields
3577 foreach (
$event->getResults() as $eventResult)
3579 if ($eventResult->getType() === \
Bitrix\
Main\EventResult::SUCCESS)
3581 $eventParams = $eventResult->getParameters();
3584 is_array($eventParams)
3585 && isset($eventParams[
'url'])
3614 if ($logItem = Log::getById($logId))
3616 $logItemFields = $logItem->getFields();
3618 isset($logItemFields[
'TRANSFORM'])
3619 && $logItemFields[
'TRANSFORM'] ===
"Y"
3631 static $extranetSiteId =
null;
3651 || !Loader::includeModule(
'blog')
3660 'ENTITY_TYPE' =>
'BLOG_POST',
3661 'ENTITY_ID' => $postId,
3664 $logId = $liveFeedEntity->getLogId();
3665 if (!self::getBlogPostLimitedViewStatus(
array(
3672 $post = Post::getById($postId);
3673 $postFields =
$post->getFields();
3676 'postId' => $postId,
3677 'authorId' => $postFields[
"AUTHOR_ID"]
3680 \CSocNetLogRights::deleteByLogID($logId);
3681 \CSocNetLogRights::add($logId, $socnetPerms,
true,
false);
3683 'LOG_UPDATE' =>
new SqlExpression(Application::getConnection()->getSqlHelper()->getCurrentDateTimeFunction()),
3687 if (\
Bitrix\
Main\Loader::includeModule(
'crm'))
3689 $logItem = Log::getById($logId);
3690 \CCrmLiveFeedComponent::processCrmBlogPostRights($logId, $logItem->getFields(), $postFields,
'new');
3694 'socnetPerms' => $socnetPerms,
3696 'logEventId' => $liveFeedEntity->getEventId()
3699 $logSiteIdList =
array();
3700 $resSite = \CSocNetLog::getSite($logId);
3701 while($logSite = $resSite->fetch())
3703 $logSiteIdList[] = $logSite[
"LID"];
3707 $extranetSiteId ===
null
3708 && Loader::includeModule(
'extranet')
3711 $extranetSiteId = \CExtranet::getExtranetSiteID();
3715 foreach($logSiteIdList as $logSiteId)
3717 if ($logSiteId != $extranetSiteId)
3726 $siteId = \CSite::getDefSite();
3732 "post_id" => $postId,
3733 "user_id" => $postFields[
"AUTHOR_ID"]
3737 $notificationParamsList =
array(
3739 'ID' => $postFields[
"ID"],
3740 'TITLE' => $postFields[
"TITLE"],
3741 'AUTHOR_ID' => $postFields[
"AUTHOR_ID"]
3744 'postUrl' => $postUrl,
3745 'socnetRights' => $socnetPerms,
3748 $notificationParamsList[
'mentionList'] = Mention::getUserIds($postFields[
'DETAIL_TEXT']);
3753 !isset(
$params[
'notifyAuthor'])
3757 self::notifyAuthorOnSetBlogPostLimitedViewStatusShow(
array(
3758 'POST_ID' => $postId,
3759 'POST_FIELDS' => $postFields,
3760 'POST_URL' => $postUrl,
3768 'POST_ID' => $postId
3778 private static function notifyAuthorOnSetBlogPostLimitedViewStatusShow(
$params =
array())
3781 $postFields =
$params[
'POST_FIELDS'];
3782 $postUrl =
$params[
'POST_URL'];
3787 if (Loader::includeModule(
'im'))
3789 $authorPostUrl = $postUrl;
3790 if (ModuleManager::isModuleInstalled(
"extranet"))
3792 $tmp = \CSocNetLogTools::processPath(
3794 "URL" => $authorPostUrl,
3796 $postFields[
"AUTHOR_ID"],
3799 $authorPostUrl =
$tmp[
"URLS"][
"URL"];
3802 mb_strpos($authorPostUrl,
"http://") === 0
3803 || mb_strpos($authorPostUrl,
"https://") === 0
3805 :
$tmp[
"SERVER_NAME"]
3811 "TO_USER_ID" => $postFields[
"AUTHOR_ID"],
3812 "FROM_USER_ID" => $postFields[
"AUTHOR_ID"],
3814 "NOTIFY_ANSWER" =>
"N",
3815 "NOTIFY_MODULE" =>
"socialnetwork",
3816 "NOTIFY_EVENT" =>
"transform",
3817 "NOTIFY_TAG" =>
"SONET|BLOG_POST_CONVERT|".$postId,
3818 "PARSE_LINK" =>
"N",
3820 "NOTIFY_MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
'SONET_HELPER_VIDEO_CONVERSION_COMPLETED',
array(
3821 '#POST_TITLE#' =>
'<a href="'.$authorPostUrl.
'" class="bx-notifier-item-action">'.
htmlspecialcharsbx($postFields[
"TITLE"]).
'</a>'
3823 "NOTIFY_MESSAGE_OUT" => fn (?
string $languageId =
null) => Loc::getMessage(
'SONET_HELPER_VIDEO_CONVERSION_COMPLETED',
array(
3825 ), $languageId).
" ".$serverName.$authorPostUrl,
3828 $messageFields[
'PUSH_MESSAGE'] = Loc::getMessage(
'SONET_HELPER_VIDEO_CONVERSION_COMPLETED',
array(
3829 '#POST_TITLE#' =>
'<a href="'.$authorPostUrl.
'" class="bx-notifier-item-action">'.
htmlspecialcharsbx($postFields[
"TITLE"]).
'</a>'
3832 'ACTION' =>
'transform',
3854 && !empty(
$params[
'authorId'])
3855 && (int)
$params[
'authorId'] > 0
3867 $blogPostFields = \CBlogPost::getByID($postId);
3868 $authorId = (int)$blogPostFields[
"AUTHOR_ID"];
3876 $result = \CBlogPost::getSocNetPermsCode($postId);
3878 $profileBlogPost =
false;
3883 $profileBlogPost =
true;
3887 if (!$profileBlogPost)
3889 if (!in_array(
"U".$authorId,
$result,
true))
3897 || in_array(
"G2",
$result,
true)
3900 $socnetPermsAdd =
array();
3912 $socnetPermsAdd[] =
"SG".$matches[1].
"_".
$result;
3916 if (
count($socnetPermsAdd) > 0)
3928 if (!Loader::includeModule(
'blog'))
3947 : \CSite::getDefSite()
3961 && !empty(
$params[
'socnetRights'])
3962 && is_array(
$params[
'socnetRights'])
3967 $socnetRightsOld = (
3970 && !empty(
$params[
'socnetRightsOld'])
3971 && is_array(
$params[
'socnetRightsOld'])
3982 && !empty(
$params[
'mentionListOld'])
3983 && is_array(
$params[
'mentionListOld'])
3991 && !empty(
$params[
'mentionList'])
3992 && is_array(
$params[
'mentionList'])
4000 && !empty(
$params[
'gratData'])
4001 && is_array(
$params[
'gratData'])
4006 $IMNotificationFields =
array(
4008 "TITLE" =>
$post[
"TITLE"],
4010 "ID" =>
$post[
"ID"],
4011 "FROM_USER_ID" =>
$post[
"AUTHOR_ID"],
4012 "TO_USER_ID" =>
array(),
4013 "TO_SOCNET_RIGHTS" => $socnetRights,
4014 "TO_SOCNET_RIGHTS_OLD" => $socnetRightsOld,
4015 "GRAT_DATA" => $gratData
4017 if (!empty($mentionListOld))
4019 $IMNotificationFields[
"MENTION_ID_OLD"] = $mentionListOld;
4021 if (!empty($mentionList))
4023 $IMNotificationFields[
"MENTION_ID"] = $mentionList;
4026 $userIdSentList = \CBlogPost::notifyIm($IMNotificationFields);
4027 if (!$userIdSentList)
4029 $userIdSentList = [];
4032 $userIdToMailList = [];
4034 if (!empty($socnetRights))
4037 "EMAIL_FROM" => Option::get(
'main',
'email_from',
'nobody@nobody.com'),
4038 "SOCNET_RIGHTS" => $socnetRights,
4039 "SOCNET_RIGHTS_OLD" => $socnetRightsOld,
4040 "ENTITY_TYPE" =>
"POST",
4041 "ENTITY_ID" =>
$post[
"ID"],
4042 "AUTHOR_ID" =>
$post[
"AUTHOR_ID"],
4044 'EXCLUDE_USERS' => array_merge([
$post[
'AUTHOR_ID'] ], $userIdSentList),
4047 foreach ($socnetRights as
$right)
4049 if (mb_strpos(
$right,
"U") === 0)
4051 $rightUserId = (int)mb_substr(
$right, 1);
4054 && empty($socnetRightsOld[
"U"][$rightUserId])
4055 && $rightUserId !== (
int)
$post[
"AUTHOR_ID"]
4056 && !in_array($rightUserId, $userIdToMailList,
true)
4059 $userIdToMailList[] = $rightUserId;
4065 if (!empty($userIdToMailList))
4067 \CBlogPost::notifyMail([
4070 "userId" => $userIdToMailList,
4071 "authorId" =>
$post[
"AUTHOR_ID"],
4072 "postId" =>
$post[
"ID"],
4074 '/pub/post.php?post_id=#post_id#',
4076 "post_id" =>
$post[
"ID"],
4089 return Option::get(
'socialnetwork',
'user_page', $siteDir.
'company/personal/',
$siteId);
4096 return Option::get(
'socialnetwork',
'workgroups_page', $siteDir.
'workgroups/',
$siteId);
4103 return $siteDir .
'spaces/';
4121 $siteDir =
$site[
'DIR'];
4134 if (!Loader::includeModule(
'blog'))
4141 && (int)
$params[
'POST_ID'] > 0
4146 $postFields =
array();
4155 && isset(
$params[
'AUTHOR_ID'])
4156 && (int)
$params[
'AUTHOR_ID'] > 0
4158 : $postFields[
'AUTHOR_ID']
4164 'userId' =>
$USER->getId(),
4174 $socNetPermsListOld =
array();
4183 && !empty($postFields[
'AUTHOR_ID'])
4184 && !empty($socNetPermsListOld)
4185 && !empty($socNetPermsListOld[
'U'])
4186 && isset($socNetPermsListOld[
'U'][$postFields[
'AUTHOR_ID']])
4187 && in_array(
'U' . $postFields[
'AUTHOR_ID'], $socNetPermsListOld[
'U'][$postFields[
'AUTHOR_ID']],
true)
4209 foreach ($permList as $v =>
$k)
4222 empty($postFields[
'AUTHOR_ID'])
4223 || $vv !==
'U'.$postFields[
'AUTHOR_ID']
4237 'AUTHOR_ID' => $authorId,
4238 'IS_EXTRANET_USER' => $extranetUser,
4239 'POST_ID' => $postId
4249 $destinationList = (
4262 $currentUserId =
$USER->getId();
4264 if (!$currentUserId)
4272 'userId' =>
$USER->getId()
4278 && (int)
$params[
'POST_ID'] > 0
4284 $oldSonetGroupIdList = [];
4290 if (!empty($socNetPermsListOld[
'SG']))
4292 $oldSonetGroupIdList = array_keys($socNetPermsListOld[
'SG']);
4296 $userAdmin = \CSocNetUser::isUserModuleAdmin($currentUserId,
$siteId);
4299 $newSonetGroupIdList = [];
4300 $newUserIdList = [];
4302 foreach($destinationList as
$code)
4306 $newSonetGroupIdList[] = (int)
$matches[1];
4310 $newUserIdList[] = (int)
$matches[1];
4314 if (!empty($newSonetGroupIdList))
4319 $premoderateSGList = [];
4322 foreach ($newSonetGroupIdList as $groupId)
4327 && in_array($groupId, $oldSonetGroupIdList)
4333 $canPublishToGroup = (
4335 || \CSocNetFeaturesPerms::canPerformOperation($currentUserId,
SONET_ENTITY_GROUP, $groupId,
'blog',
'write_post')
4336 || \CSocNetFeaturesPerms::canPerformOperation($currentUserId,
SONET_ENTITY_GROUP, $groupId,
'blog',
'full_post')
4337 || \CSocNetFeaturesPerms::canPerformOperation($currentUserId,
SONET_ENTITY_GROUP, $groupId,
'blog',
'moderate_post')
4340 $canPremoderateToGroup = \CSocNetFeaturesPerms::canPerformOperation($currentUserId,
SONET_ENTITY_GROUP, $groupId,
'blog',
'premoderate_post');
4344 && $canPremoderateToGroup
4347 $premoderateSGList[] = $groupId;
4352 && $canPublishToGroup
4368 if (!empty($premoderateSGList))
4380 $resultFields[
'PUBLISH_STATUS'] = $postFields[
'PUBLISH_STATUS'];
4384 $resultFields[
'ERROR_MESSAGE'] = Loc::getMessage(
'SBPE_EXISTING_POST_PREMODERATION');
4385 $resultFields[
'ERROR_MESSAGE_PUBLIC'] = $resultFields[
'ERROR_MESSAGE'];
4391 $groupNameList = [];
4392 $groupUrl = Option::get(
'socialnetwork',
'workgroups_page',
SITE_DIR.
'workgroups/',
SITE_ID).
'group/#group_id#/';
4394 $res = WorkgroupTable::getList([
4396 '@ID' => $premoderateSGList
4398 'select' => [
'ID',
'NAME' ]
4400 while ($groupFields =
$res->fetch())
4402 $groupNameList[] = (
4404 ? $groupFields[
'NAME']
4409 $resultFields[
'ERROR_MESSAGE'] = Loc::getMessage(
'SBPE_MULTIPLE_PREMODERATION2', [
4410 '#GROUPS_LIST#' => implode(
', ', $groupNameList)
4412 $resultFields[
'ERROR_MESSAGE_PUBLIC'] = $resultFields[
'ERROR_MESSAGE'];
4417 $resultFields[
'ERROR_MESSAGE'] = Loc::getMessage(
'SONET_HELPER_NO_PERMISSIONS');
4424 $destinationList = array_filter($destinationList,
static function (
$code) {
4429 !empty($newUserIdList)
4430 && Loader::includeModule(
'extranet')
4433 $visibleUserIdList = \CExtranet::getMyGroupsUsersSimple(
SITE_ID);
4435 if (!empty(array_diff($newUserIdList, $visibleUserIdList)))
4437 $resultFields[
'ERROR_MESSAGE'] = Loc::getMessage(
'SONET_HELPER_NO_PERMISSIONS');
4444 && in_array(
"UA", $destinationList,
true)
4447 foreach ($destinationList as
$key => $value)
4449 if ($value ===
"UA")
4451 unset($destinationList[
$key]);
4460 empty($destinationList)
4461 || in_array(
"UA", $destinationList,
true)
4464 $resultFields[
"ERROR_MESSAGE"] .= Loc::getMessage(
"BLOG_BPE_EXTRANET_ERROR");
4467 elseif (empty($destinationList))
4469 $resultFields[
"ERROR_MESSAGE"] .= Loc::getMessage(
"BLOG_BPE_DESTINATION_EMPTY");
4472 return $destinationList;
4477 static $allowedTypes =
array(
4498 || !in_array(
$type, $allowedTypes,
true)
4506 && (int)
$params[
'POST_ID'] > 0
4513 && in_array(
$type,
array(
'post_general',
'post',
'post_comments',
'post_urlpreview'))
4524 $result =
"/blog/socnet_post/".(int)($postId / 100).
"/".$postId.
"/";
4526 case 'post_general':
4527 $result =
"/blog/socnet_post/gen/".(int)($postId / 100).
"/".$postId;
4529 case 'post_urlpreview':
4530 $result =
"/blog/socnet_post/urlpreview/".(int)($postId / 100).
"/".$postId;
4532 case 'posts_popular':
4533 $result =
"/".$siteId.
"/blog/popular_posts/";
4536 $result =
"/".$siteId.
"/blog/last_messages_list/";
4538 case 'posts_last_blog':
4539 $result =
"/".$siteId.
"/blog/last_messages/";
4541 case 'post_comments':
4542 $result =
"/blog/comment/".(int)($postId / 100).
"/".$postId.
"/";
4563 if (!is_array($logIdList))
4565 $logIdList = [ $logIdList ];
4568 if (empty($logIdList))
4573 $ratingId = \CRatings::getAuthorityRating();
4574 if ((
int)$ratingId <= 0)
4579 $result = array_fill_keys($logIdList, []);
4605 if (ModuleManager::isModuleInstalled(
'intranet'))
4608 SELECT /*+ NO_DERIVED_CONDITION_PUSHDOWN() */
4609 RS1.ENTITY_ID as USER_ID,
4611 MAX(RS1.VOTES) as WEIGHT
4613 b_rating_subordinate RS1,
4615 INNER JOIN b_sonet_log SL
4616 ON SL.RATING_TYPE_ID = RV1.ENTITY_TYPE_ID
4617 AND SL.RATING_ENTITY_ID = RV1.ENTITY_ID
4618 AND SL.ID IN ('.implode(
',', $logIdList).
')
4620 RS1.ENTITY_ID = RV1.USER_ID
4621 AND RS1.RATING_ID = '.(
int)$ratingId.
'
4623 SL.ID, RS1.ENTITY_ID
4632 SELECT /*+ NO_DERIVED_CONDITION_PUSHDOWN() */
4633 RV1.USER_ID as USER_ID,
4638 INNER JOIN b_sonet_log SL
4639 ON SL.RATING_TYPE_ID = RV1.ENTITY_TYPE_ID
4640 AND SL.RATING_ENTITY_ID = RV1.ENTITY_ID
4641 AND SL.ID IN ('.implode(
',', $logIdList).
')
4648 $userWeightData = [];
4655 while ($voteFields =
$res->fetch())
4657 $voteUserId = (int)$voteFields[
'USER_ID'];
4658 $voteLogId = (int)$voteFields[
'LOG_ID'];
4662 && $voteUserId === (
int)
$USER->getId()
4668 if ($voteLogId !== $currentLogId)
4672 $logUserData[$voteLogId] = [];
4675 $currentLogId = $voteLogId;
4677 if (in_array($voteUserId, $logUserData[$voteLogId],
true))
4684 if ($cnt > ($hasMine ? $topCount+1 : $topCount))
4689 $logUserData[$voteLogId][] = $voteUserId;
4690 if (!isset($userWeightData[$voteUserId]))
4692 $userWeightData[$voteUserId] = (float)$voteFields[
'WEIGHT'];
4698 if (!empty($userWeightData))
4702 '@ID' => array_keys($userWeightData)
4704 'select' => [
'ID',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'LOGIN',
'PERSONAL_PHOTO',
'PERSONAL_GENDER' ]
4707 while ($userFields =
$res->fetch())
4709 $userData[$userFields[
"ID"]] = [
4710 'NAME_FORMATTED' => \CUser::formatName(
4711 \CSite::getNameFormat(
false),
4715 'PERSONAL_PHOTO' => [
4716 'ID' => $userFields[
'PERSONAL_PHOTO'],
4719 'PERSONAL_GENDER' => $userFields[
'PERSONAL_GENDER']
4722 if ((
int)$userFields[
'PERSONAL_PHOTO'] > 0)
4724 $imageFile = \CFile::getFileArray($userFields[
"PERSONAL_PHOTO"]);
4725 if ($imageFile !==
false)
4727 $file = \CFile::resizeImageGet(
4730 'width' => $avatarSize,
4731 'height' => $avatarSize,
4736 $userData[$userFields[
"ID"]][
'PERSONAL_PHOTO'][
'SRC'] = $file[
'src'];
4742 foreach ($logUserData as $logId => $userIdList)
4746 foreach ($userIdList as
$userId)
4750 'NAME_FORMATTED' => $userData[
$userId][
'NAME_FORMATTED'],
4751 'PERSONAL_PHOTO' => $userData[
$userId][
'PERSONAL_PHOTO'][
'ID'],
4752 'PERSONAL_PHOTO_SRC' => $userData[
$userId][
'PERSONAL_PHOTO'][
'SRC'],
4753 'PERSONAL_GENDER' => $userData[
$userId][
'PERSONAL_GENDER'],
4754 'WEIGHT' => $userWeightData[
$userId]
4763 static function(
$a, $b)
4766 !isset(
$a[
'WEIGHT'], $b[
'WEIGHT'])
4767 ||
$a[
'WEIGHT'] === $b[
'WEIGHT']
4772 return (
$a[
'WEIGHT'] > $b[
'WEIGHT']) ? -1 : 1;
4790 !\CSocNetUser::isCurrentUserModuleAdmin(
$siteId,
false)
4791 && Loader::includeModule(
'extranet')
4792 && !\CExtranet::isIntranetUser()
4802 $logAuthorList =
array(),
4803 $logDestUserList =
array();
4807 $typeList = (
$params[
'typeList'] ?? []);
4809 $followByWF = !empty(
$params[
'followByWF']);
4811 if (!is_array($typeList))
4813 $typeList =
array($typeList);
4826 if (in_array(
'FOLLOW', $typeList))
4828 $followRes = \CSocNetLogFollow::set(
4835 mb_strtoupper(
$params[
'followDate']) ===
'CURRENT'
4836 ? ConvertTimeStamp(time() + \CTimeZone::getOffset(),
"FULL",
$siteId)
4846 if (in_array(
'COUNTER_COMMENT_PUSH', $typeList))
4848 if (!isset($logAuthorList[$logId]))
4854 'select' =>
array(
'USER_ID')
4856 if ($logFields =
$res->fetch())
4858 $logAuthorList[$logId] = $logFields[
'USER_ID'];
4862 if (!isset($logDestUserList[$logId]))
4864 $logDestUserList[$logId] =
array();
4869 'select' =>
array(
'GROUP_CODE')
4871 while ($logRightFields =
$res->fetch())
4873 if (preg_match(
'/^U(\d+)$/', $logRightFields[
'GROUP_CODE'],
$matches))
4875 $logDestUserList[$logId][] =
$matches[1];
4881 $userId != $logAuthorList[$logId]
4882 && !in_array(
$userId, $logDestUserList[$logId])
4895 in_array(
'FOLLOW', $typeList)
4903 $forumMetaData = \CSocNetLogTools::getForumCommentMetaData($eventFields[
"EVENT_ID"]);
4907 && $eventFields[
"SOURCE_ID"] > 0
4911 "ENTITY_TYPE" => $forumMetaData[1],
4912 "ENTITY_XML_ID" => $forumMetaData[0].
"_".$eventFields[
"SOURCE_ID"],
4913 "NOTIFY_TAGS" => $forumMetaData[2]
4919 $eventFields[
"EVENT_ID"] ===
'calendar'
4920 && !empty($eventFields[
"PARAMS"])
4921 && ($calendarEventParams = unserialize(
htmlspecialcharsback($eventFields[
"PARAMS"]), [
'allowed_classes' =>
false ]))
4922 && !empty($calendarEventParams[
'COMMENT_XML_ID'])
4925 $result[
"ENTITY_XML_ID"] = $calendarEventParams[
'COMMENT_XML_ID'];
4928 elseif ($eventFields[
"EVENT_ID"] ===
'photo')
4931 "ENTITY_TYPE" =>
'PA',
4932 "ENTITY_XML_ID" =>
'PHOTO_ALBUM_'.$eventFields[
"ID"],
4939 "ENTITY_TYPE" => mb_substr(mb_strtoupper($eventFields[
"EVENT_ID"]).
"_".$eventFields[
"ID"], 0, 2),
4940 "ENTITY_XML_ID" => mb_strtoupper($eventFields[
"EVENT_ID"]).
"_".$eventFields[
"ID"],
4946 mb_strtoupper($eventFields[
"ENTITY_TYPE"]) ===
"CRMACTIVITY"
4947 && Loader::includeModule(
'crm')
4948 && ($activityFields = \CCrmActivity::getById($eventFields[
"ENTITY_ID"],
false))
4950 $activityFields[
"TYPE_ID"] == \CCrmActivityType::Task
4952 (
int)$activityFields[
'TYPE_ID'] === \CCrmActivityType::Provider
4953 && $activityFields[
'PROVIDER_ID'] === Task::getId()
4958 $result[
"ENTITY_XML_ID"] =
"TASK_".$activityFields[
"ASSOCIATED_ENTITY_ID"];
4961 $eventFields[
"ENTITY_TYPE"] ===
"WF"
4962 && is_numeric($eventFields[
"SOURCE_ID"])
4963 && (
int)$eventFields[
"SOURCE_ID"] > 0
4964 && Loader::includeModule(
'bizproc')
4968 $result[
"ENTITY_XML_ID"] =
"WF_".$workflowId;
4976 static $canCommentCached = [];
4979 $workgroupId = (isset(
$params[
'workgroupId']) ? (int)
$params[
'workgroupId'] : 0);
4982 || $workgroupId <= 0
4988 $cacheKey =
$userId.
'_'.$workgroupId;
4990 if (!isset($canCommentCached[$cacheKey]))
4992 $canCommentCached[$cacheKey] = (
4998 return $canCommentCached[$cacheKey];
5003 return Option::get(
'socialnetwork',
'livefeed_allow_tasks',
true);
5008 $perms = (string)(
$params[
'perms'] ??
'');
5009 $crm = (bool)(
$params[
'crm'] ??
false);
5012 'DEST_DATA' =>
'DEST_CODES',
5013 'GRAT_DEST_DATA' =>
'GRAT_DEST_CODES',
5016 foreach ($mapping as $from => $to)
5018 if (isset($postFields[$from]))
5022 $entities = Json::decode($postFields[$from]);
5029 $postFields[$to] = array_merge(
5030 ($postFields[$to] ?? []),
5031 \
Bitrix\
Main\
UI\EntitySelector\Converter::convertToFinderCodes($entities)
5037 'DEST_CODES' =>
'SPERM',
5038 'GRAT_DEST_CODES' =>
'GRAT',
5039 'EVENT_DEST_CODES' =>
'EVENT_PERM'
5042 foreach ($mapping as $from => $to)
5044 if (isset($postFields[$from]))
5047 !isset($postFields[$to])
5048 || !is_array($postFields[$to])
5051 $postFields[$to] = [];
5054 foreach ($postFields[$from] as $destCode)
5056 if ($destCode ===
'UA')
5058 if (empty($postFields[$to][
'UA']))
5060 $postFields[$to][
'UA'] = [];
5062 $postFields[$to][
'UA'][] =
'UA';
5066 if (empty($postFields[$to][
'UE']))
5068 $postFields[$to][
'UE'] = [];
5070 $postFields[$to][
'UE'][] =
$matches[1];
5074 if (empty($postFields[$to][
'U']))
5076 $postFields[$to][
'U'] = [];
5078 $postFields[$to][
'U'][] =
'U' .
$matches[1];
5081 $from ===
'DEST_CODES'
5083 && preg_match(
'/^UP(\d+)$/i', $destCode,
$matches)
5084 && Loader::includeModule(
'blog')
5087 if (empty($postFields[$to][
'UP']))
5089 $postFields[$to][
'UP'] = [];
5091 $postFields[$to][
'UP'][] =
'UP' .
$matches[1];
5095 if (empty($postFields[$to][
'SG']))
5097 $postFields[$to][
'SG'] = [];
5099 $postFields[$to][
'SG'][] =
'SG' .
$matches[1];
5103 if (empty($postFields[$to][
'DR']))
5105 $postFields[$to][
'DR'] = [];
5107 $postFields[$to][
'DR'][] =
'DR' .
$matches[1];
5109 elseif ($crm && preg_match(
'/^CRMCONTACT(\d+)$/i', $destCode,
$matches))
5111 if (empty($postFields[$to][
'CRMCONTACT']))
5113 $postFields[$to][
'CRMCONTACT'] = [];
5115 $postFields[$to][
'CRMCONTACT'][] =
'CRMCONTACT' .
$matches[1];
5117 elseif ($crm && preg_match(
'/^CRMCOMPANY(\d+)$/i', $destCode,
$matches))
5119 if (empty($postFields[$to][
'CRMCOMPANY']))
5121 $postFields[$to][
'CRMCOMPANY'] = [];
5123 $postFields[$to][
'CRMCOMPANY'][] =
'CRMCOMPANY' .
$matches[1];
5125 elseif ($crm && preg_match(
'/^CRMLEAD(\d+)$/i', $destCode,
$matches))
5127 if (empty($postFields[$to][
'CRMLEAD']))
5129 $postFields[$to][
'CRMLEAD'] = [];
5131 $postFields[$to][
'CRMLEAD'][] =
'CRMLEAD' .
$matches[1];
5133 elseif ($crm && preg_match(
'/^CRMDEAL(\d+)$/i', $destCode,
$matches))
5135 if (empty($postFields[$to][
'CRMDEAL']))
5137 $postFields[$to][
'CRMDEAL'] = [];
5139 $postFields[$to][
'CRMDEAL'][] =
'CRMDEAL' .
$matches[1];
5143 unset($postFields[$from]);
5155 $firstMenuItemCode = (string)(
$params[
'firstMenuItemCode'] ??
'');
5156 $canViewTasks = (bool)(
$params[
'canView'][
'tasks'] ??
false);
5165 if ($firstMenuItemCode !==
'')
5168 mb_strpos(
$page, $firstMenuItemCode) !==
false
5169 || in_array(
$page, [
'group',
'group_general',
'group_tasks' ])
5175 $page ===
'group_tasks'
5181 ||
$page ===
'group_general'
5192 'CARD' => (string)($componentResult[
'PATH_TO_GROUP_CARD'] ??
''),
5193 'EDIT' => (string)($componentResult[
'PATH_TO_GROUP_EDIT'] ??
''),
5194 'COPY' => (string)($componentResult[
'PATH_TO_GROUP_COPY'] ??
''),
5195 'DELETE' => (string)($componentResult[
'PATH_TO_GROUP_DELETE'] ??
''),
5196 'LEAVE' => (string)($componentResult[
'PATH_TO_USER_LEAVE_GROUP'] ??
''),
5197 'JOIN' => (string)($componentResult[
'PATH_TO_USER_REQUEST_GROUP'] ??
''),
5198 'MEMBERS' => (string)($componentResult[
'PATH_TO_GROUP_USERS'] ??
''),
5199 'REQUESTS_IN' => (string)($componentResult[
'PATH_TO_GROUP_REQUESTS'] ??
''),
5200 'REQUESTS_OUT' => (string)($componentResult[
'PATH_TO_GROUP_REQUESTS_OUT'] ??
''),
5201 'FEATURES' => (string)($componentResult[
'PATH_TO_GROUP_FEATURES'] ??
''),
5207 return array_filter($componentParameters,
static function (
$key) {
5279 return (in_array(
$key, [
5284 }, ARRAY_FILTER_USE_KEY);
5295 foreach ($sourceParametersList as $source)
5297 if (isset($source[
'signedParameters']) && is_string($source[
'signedParameters']))
5301 $componentParameters = ParameterSigner::unsignParameters(
5302 self::getWorkgroupSliderMenuSignedParametersSalt(),
5303 $source[
'signedParameters']
5305 $componentParameters[
'IFRAME'] =
'Y';
5306 return $componentParameters;
5320 return 'bitrix:socialnetwork.group.card.menu';
5330 $filePath = \CFile::getPath($fileId);
5331 if ((
string)$filePath ===
'')
5336 $signer = new \Bitrix\Main\Security\Sign\Signer;
5337 return $signer->sign(serialize([ $fileId, $filePath ]),
'workgroup_avatar_token');
5352 if (ModuleManager::isModuleInstalled(
'intranet'))
5364 $defaultProperties = [
5373 "PERSONAL_BIRTHDAY",
5379 $defaultProperties = [];
5383 'SHOW_FIELDS_TOOLTIP' => (
$params[
'SHOW_FIELDS_TOOLTIP'] ?? unserialize(Option::get(
'socialnetwork',
'tooltip_fields', serialize($defaultFields)), [
'allowed_classes' =>
false])),
5384 'USER_PROPERTY_TOOLTIP' => (
$params[
'USER_PROPERTY_TOOLTIP'] ?? unserialize(Option::get(
'socialnetwork',
'tooltip_properties', serialize($defaultProperties)), [
'allowed_classes' =>
false])),
5390 $workgroupName = (string)(
$params[
'WORKGROUP_NAME'] ??
'');
5391 $workgroupId = (int)(
$params[
'WORKGROUP_ID'] ?? 0);
5394 $workgroupName ===
''
5398 $groupFields = \CSocNetGroup::getById($workgroupId,
true);
5399 if (!empty($groupFields))
5401 $workgroupName = $groupFields[
'NAME'];
5405 return Loc::getMessage(
'SONET_HELPER_PAGE_TITLE_WORKGROUP_TEMPLATE', [
5406 '#WORKGROUP#' => $workgroupName,
5407 '#TITLE#' => (
$params[
'TITLE'] ??
''),
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
const BLOG_PUBLISH_STATUS_READY
const BLOG_PUBLISH_STATUS_PUBLISH
if(!Loader::includeModule('messageservice')) $provider
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static increment($params=array())
static getById($postId=0, $params=array())
static signParameters($componentName, $parameters)
static convertRights($rights, $excludeCodes=[])
static merge(array $data)
static getList(array $parameters=array())
static update($primary, array $data)
static checkProfileRedirect($userId=0)
static getBlogCommentListCount($postId)
static getSonetGroupAvailable($params=array(), &$limitReached=false)
static checkCanCommentInWorkgroup($params)
static getWorkgroupSEFUrl($params=[])
static getLivefeedRatingData($params=[])
static $commentListsCache
static setBlogPostLimitedViewStatus($params=array())
static getExtranetUserIdList()
static addContextToUrl($url, $context)
static getWorkgroupSliderMenuUrlList(array $componentResult=[])
static $destinationsCache
static checkEmptyParamString(&$params, $paramName, $defaultValue)
static getWorkgroupSliderMenuUnsignedParameters(array $sourceParametersList=[])
static checkLivefeedTasksAllowed()
static convertBlogPostPermToDestinationList($params, &$resultFields)
static setComponentOption($list, $params=array())
static hasTextInlineImage(string $text='', array $ufData=[])
static notifyBlogPostCreated($params=array())
static $commentCountCache
static getWorkgroupSliderMenuSignedParametersSalt()
static getBlogCommentListData($postId, $params, $languageId, &$authorIdList=[])
static isCurrentUserExtranet($params=[])
static getBlogPostCacheDir($params=array())
static getAttachmentsData($valueList, $siteId=false)
static convertSelectorRequestData(array &$postFields=[], array $params=[])
static getBlogAuthorData($authorId, $params)
static checkPredefinedAuthIdList($authIdList=array())
static checkBlogPostDestinationList($params, &$resultFields)
static getWorkgroupAvatarToken($fileId=0)
static addLiveSourceComment(array $params=[])
static listWorkgroupSliderMenuSignedParameters(array $componentParameters=[])
static checkTooltipComponentParams($params)
static getUrlPreviewContent($uf, $params=array())
static getAllowToAllDestination($userId=0)
static formatDateTimeToGMT($dateTimeSource, $authorId)
static getSpacesSEFUrl($params=[])
static processBlogPostShare($fields, $params)
static getUserSonetGroupIdList($userId=false, $siteId=false)
static checkEmptyParamInteger(&$params, $paramName, $defaultValue)
static getReplyToUrl($url, $userId, $entityType, $entityId, $siteId, $backUrl=null)
static hasCommentSource($params)
static getBlogCommentData($commentId, $languageId)
static getBlogPostLimitedViewStatus($params=array())
static getBlogPostDestinations($postId)
static getUrlPreviewValue($text, $html=true)
static createUserBlog($params)
const MAIN_SELECTOR_GROUPS_CACHE_TAG
static convertDiskFileBBCode($text, $entityType, $entityId, $authorId, $attachmentList=[])
static getBlogPostData($postId, $languageId)
static getUserSEFUrl($params=array())
static processBlogPostNewMailUser(&$HTTPPost, &$componentResult)
static getExtranetSonetGroupIdList()
static getEmailUserIdList()
static addLiveComment($comment=[], $logEntry=[], $commentEvent=[], $params=[])
static getWorkgroupSliderMenuSignedParameters(array $params)
static canAddComment($logEntry=array(), $commentEvent=array())
static userLogSubscribe($params=array())
static getLivefeedStepper()
static getSonetBlogGroupIdList($params)
static fillSelectedUsersToInvite($HTTPPost, $componentParams, &$componentResult)
static processBlogPostNewCrmContact(&$HTTPPost, &$componentResult)
static isCurrentPageFirst(array $params=[])
static getWorkgroupPageTitle(array $params=[])
static getLFCommentsParams($eventFields=array())
static getBlogPostSocNetPerms($params=array())
static processBlogPostNewMailUserDestinations(&$destinationList)
static convertMailDiskFileBBCode($text='', $attachmentList=[])
static init(array $params)
static getContentId($event=[])
static set($params=array())
const TYPE_COUNTER_COMMENT_PUSH
static getSocNetPerms($ID, $useCache=true)
static getWorkflowByIntegerId($integerId)
static makePathFromTemplate($template, $arParams=array())
static killAllTags($text)
if(!is_array($prop["VALUES"])) $tmp
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
global $USER_FIELD_MANAGER
if($request->getPost('Update') !==null) elseif( $request->getPost( 'Apply') !==null) elseif($request->getPost('RestoreDefaults') !==null) $backUrl
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
const BX_RESIZE_IMAGE_EXACT
const BX_RESIZE_IMAGE_PROPORTIONAL
const SITE_DIR(!defined('LANG'))
ExecuteModuleEventEx($arEvent, $arParams=[])
htmlspecialcharsback($str)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
BXClearCache($full=false, $initdir='')
check_email($email, $strict=false, $domainCheck=false)
MakeTimeStamp($datetime, $format=false)
LocalRedirect($url, $skip_security_check=false, $status="302 Found")
TruncateText($strText, $intLen)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
const SONET_RELATIONS_TYPE_ALL