5use Bitrix\Blog\Integration;
26 $blogModulePermissions = CMain::getGroupRight(
"blog");
27 if ($blogModulePermissions >=
"W")
44 if ($arBlogUser && $arBlogUser[
"ALLOW_POST"] !=
"Y")
54 if ((
int)$arPost[
'AUTHOR_ID'] ===
$userId)
67 $blogModulePermissions = CMain::getGroupRight(
"blog");
68 if ($blogModulePermissions >=
"W")
85 if ($arBlogUser && $arBlogUser[
"ALLOW_POST"] !=
"Y")
101 if ((
int)$arPost[
'AUTHOR_ID'] ===
$userId)
114 $arAvailPerms = array_keys(
$GLOBALS[
"AR_BLOG_PERMS"]);
115 $blogModulePermissions = CMain::getGroupRight(
'blog');
116 if ($blogModulePermissions >=
"W")
118 return $arAvailPerms[
count($arAvailPerms) - 1];
124 return $arAvailPerms[0];
129 return $arAvailPerms[
count($arAvailPerms) - 1];
137 if ($arBlogUser && $arBlogUser[
"ALLOW_POST"] !=
"Y")
145 return $arAvailPerms[0];
154 return $arAvailPerms[0];
162 $arAvailPerms = array_keys(
$GLOBALS[
"AR_BLOG_PERMS"]);
164 $blogModulePermissions = CMain::getGroupRight(
"blog");
165 if ($blogModulePermissions >=
"W")
167 return $arAvailPerms[
count($arAvailPerms) - 1];
174 return $arAvailPerms[0];
179 if ($arBlog[
"ENABLE_COMMENTS"] !=
"Y")
181 return $arAvailPerms[0];
186 return $arAvailPerms[
count($arAvailPerms) - 1];
194 if ($arBlogUser && $arBlogUser[
"ALLOW_POST"] !=
"Y")
202 return $arAvailPerms[0];
214 return $arAvailPerms[0];
217 return $arAvailPerms[0];
286 if ((
$arFields[
"DETAIL_TEXT_TYPE"] ??
'') <>
'')
291 $arStatus = array_keys(
$GLOBALS[
"AR_BLOG_PUBLISH_STATUS"]);
293 $arFields[
"PUBLISH_STATUS"] = $arStatus[0];
300 && (
$arFields[
"ENABLE_TRACKBACK"] ??
'') !=
"Y"
301 && (
$arFields[
"ENABLE_TRACKBACK"] ??
'') !=
"N"
312 && (
$arFields[
"ENABLE_COMMENTS"] ??
'') !=
"Y"
313 && (
$arFields[
"ENABLE_COMMENTS"] ??
'') !=
"N"
321 $res = CFile::CheckImageFile(
$arFields[
"ATTACH_IMG"], 0, 0, 0);
350 if (in_array(mb_strtolower(
$arFields[
"CODE"]),
$GLOBALS[
"AR_BLOG_POST_RESERVED_CODES"]))
363 $arFilter[
"BLOG_ID"] = $arPost[
"BLOG_ID"];
398 if(!is_array($arPerms))
404 $arInsertedGroups =
array();
405 foreach ($arPerms as
$key => $value)
410 "BLOG_ID" => $arPost[
"BLOG_ID"],
411 "USER_GROUP_ID" =>
$key,
412 "PERMS_TYPE" => $permsType,
413 "POST_ID" => $arPost[
"ID"],
419 if ($arGroupPerms = $dbGroupPerms->Fetch())
433 "BLOG_ID" => $arPost[
"BLOG_ID"],
434 "USER_GROUP_ID" =>
$key,
435 "PERMS_TYPE" => $permsType,
436 "POST_ID" => $arPost[
"ID"],
443 $arInsertedGroups[] =
$key;
449 "BLOG_ID" => $arPost[
"BLOG_ID"],
450 "PERMS_TYPE" => $permsType,
452 "!USER_GROUP_ID" => $arInsertedGroups,
456 array(
"ID",
"USER_GROUP_ID",
"PERMS")
463 "BLOG_ID" => $arPost[
"BLOG_ID"],
464 "USER_GROUP_ID" =>
$arResult[
"USER_GROUP_ID"],
465 "PERMS_TYPE" => $permsType,
466 "POST_ID" => $arPost[
"ID"],
472 if ($arGroupPerms = $dbGroupPerms->Fetch())
486 "BLOG_ID" => $arPost[
"BLOG_ID"],
487 "USER_GROUP_ID" =>
$arResult[
"USER_GROUP_ID"],
488 "PERMS_TYPE" => $permsType,
489 "POST_ID" => $arPost[
"ID"],
508 foreach(
GetModuleEvents(
"blog",
"OnBeforePostDelete",
true) as $arEvent)
529 array(
"POST_ID" =>
$ID,
"BLOG_ID" => $arPost[
"BLOG_ID"]),
542 array(
"POST_ID" =>
$ID,
"BLOG_ID" => $arPost[
"BLOG_ID"]),
555 array(
"POST_ID" =>
$ID,
"BLOG_ID" => $arPost[
"BLOG_ID"]),
568 "FROM b_blog_post P, b_file F ".
569 "WHERE P.ID = ".$ID.
" ".
570 " AND P.ATTACH_IMG = F.ID ";
571 $z =
$DB->Query($strSql);
572 while (
$zr =
$z->Fetch())
573 CFile::Delete(
$zr[
"ID"]);
577 unset(static::$arBlogPostCache[
$ID]);
581 $result =
$DB->Query(
"DELETE FROM b_blog_post WHERE ID = ".
$ID,
true);
583 if (intval($arBlog[
"LAST_POST_ID"]) ==
$ID)
589 while($aImg =
$res->Fetch())
598 if (CModule::IncludeModule(
"search"))
608 if(defined(
"BX_COMP_MANAGED_CACHE"))
620 public static function PreparePath($blogUrl, $postID = 0,
$siteID = False, $is404 = True, $userID = 0, $groupID = 0)
622 $blogUrl = Trim($blogUrl);
623 $postID = intval($postID);
624 $groupID = intval($groupID);
625 $userID = intval($userID);
633 while (
$arPath = $dbPath->Fetch())
714 if(!is_array($_SESSION[
"BLOG_COUNTER"]))
715 $_SESSION[
"BLOG_COUNTER"] = Array();
716 if(in_array(
$ID, $_SESSION[
"BLOG_COUNTER"]))
718 $_SESSION[
"BLOG_COUNTER"][] =
$ID;
720 "UPDATE b_blog_post SET ".
721 " VIEWS = ".$DB->IsNull(
"VIEWS", 0).
" + 1 ".
736 $arImages = $arOwner = Array();
738 $text4mail = $serverName = $AuthorName =
"";
743 $arBlog[
"EMAIL_NOTIFY"] ==
"Y"
744 &&
$arParams[
"user_id"] != $arBlog[
"OWNER_ID"]
750 $res = CUser::GetByID($arBlog[
"OWNER_ID"]);
751 $arOwner =
$res->GetNext();
752 $dbUser = CUser::GetByID(
$arParams[
"user_id"]);
753 $arUser = $dbUser->Fetch();
756 $text4mail = $arPost[
"DETAIL_TEXT"];
757 if($arPost[
"DETAIL_TEXT_TYPE"] ==
"html")
763 while ($arImage =
$res->Fetch())
765 $arImages[$arImage[
'ID']] = $arImage[
'FILE_ID'];
768 $text4mail = $parserBlog->convert4mail($text4mail, $arImages);
769 $serverName = ((defined(
"SITE_SERVER_NAME") && SITE_SERVER_NAME <>
'') ? SITE_SERVER_NAME : COption::GetOptionString(
"main",
"server_name",
""));
774 && $arBlog[
"EMAIL_NOTIFY"] ==
"Y"
775 &&
$arParams[
"user_id"] != $arBlog[
"OWNER_ID"]
776 && intval($arBlog[
"OWNER_ID"]) > 0
783 "BLOG_ID" => $arBlog[
"ID"],
784 "BLOG_NAME" => htmlspecialcharsBack($arBlog[
"NAME"]),
785 "BLOG_URL" => $arBlog[
"URL"],
786 "MESSAGE_TITLE" => $arPost[
"TITLE"],
787 "MESSAGE_TEXT" => $text4mail,
788 "MESSAGE_DATE" =>
GetTime(
MakeTimeStamp($arPost[
"DATE_PUBLISH"])-CTimeZone::GetOffset(),
"FULL"),
789 "MESSAGE_PATH" =>
"http://".$serverName.CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack(
$arParams[
"PATH_TO_POST"]),
array(
"blog" => $arBlog[
"URL"],
"post_id" => $arPost[
"ID"],
"user_id" => $arBlog[
"OWNER_ID"],
"group_id" =>
$arParams[
"SOCNET_GROUP_ID"])),
790 "AUTHOR" => $AuthorName,
791 "EMAIL_FROM" => COption::GetOptionString(
"main",
"email_from",
"nobody@nobody.com"),
792 "EMAIL_TO" => $arOwner[
"EMAIL"],
800 && CModule::IncludeModule(
"socialnetwork")
804 if($arPost[
"DETAIL_TEXT_TYPE"] ==
"html" &&
$arParams[
"allowHTML"] ==
"Y" && $arBlog[
"ALLOW_HTML"] ==
"Y")
806 $arAllow =
array(
"HTML" =>
"Y",
"ANCHOR" =>
"Y",
"IMG" =>
"Y",
"SMILES" =>
"N",
"NL2BR" =>
"N",
"VIDEO" =>
"Y",
"QUOTE" =>
"Y",
"CODE" =>
"Y");
809 $arAllow[
"VIDEO"] =
"N";
811 $text4message = $parserBlog->convert($arPost[
"DETAIL_TEXT"],
false, $arImages, $arAllow);
815 $arAllow =
array(
"HTML" =>
"N",
"ANCHOR" =>
"N",
"BIU" =>
"N",
"IMG" =>
"N",
"QUOTE" =>
"N",
"CODE" =>
"N",
"FONT" =>
"N",
"TABLE" =>
"N",
"LIST" =>
"N",
"SMILES" =>
"N",
"NL2BR" =>
"N",
"VIDEO" =>
"N");
816 $text4message = $parserBlog->convert($arPost[
"DETAIL_TEXT"],
false, $arImages, $arAllow,
array(
"isSonetLog"=>
true));
821 isset($arPost[
"UF_BLOG_POST_IMPRTNT"])
822 && intval($arPost[
"UF_BLOG_POST_IMPRTNT"]) > 0
827 ($arPost[
"DATE_PUBLISH"] ??
'') <>
''
829 MakeTimeStamp($arPost[
"DATE_PUBLISH"], CSite::GetDateFormat(
"FULL",
SITE_ID)) > time()+CTimeZone::GetOffset()
830 ?
$DB->CharToDateFunction($arPost[
"DATE_PUBLISH"],
"FULL",
SITE_ID)
831 :
$DB->CurrentTimeFunction()
834 $DB->CurrentTimeFunction()
836 "TITLE_TEMPLATE" =>
"#USER_NAME# ".GetMessage(
"BLG_SONET_TITLE"),
837 "TITLE" => $arPost[
"TITLE"],
838 "MESSAGE" => $text4message,
839 "TEXT_MESSAGE" => $text4mail,
840 "MODULE_ID" =>
"blog",
841 "CALLBACK_FUNC" =>
false,
842 "SOURCE_ID" => $arPost[
"ID"],
843 "ENABLE_COMMENTS" => (array_key_exists(
"ENABLE_COMMENTS", $arPost) && $arPost[
"ENABLE_COMMENTS"] ==
"N" ?
"N" :
"Y"),
846 $arSoFields[
"RATING_TYPE_ID"] =
"BLOG_POST";
847 $arSoFields[
"RATING_ENTITY_ID"] = intval($arPost[
"ID"]);
852 $arSoFields[
"ENTITY_ID"] =
$arParams[
"SOCNET_GROUP_ID"];
853 $arSoFields[
"URL"] = CComponentEngine::MakePathFromTemplate(
$arParams[
"PATH_TO_POST"],
array(
"blog" => $arBlog[
"URL"],
"user_id" => $arBlog[
"OWNER_ID"],
"group_id" =>
$arParams[
"SOCNET_GROUP_ID"],
"post_id" => $arPost[
"ID"]));
858 $arSoFields[
"ENTITY_ID"] = $arBlog[
"OWNER_ID"];
859 $arSoFields[
"URL"] = CComponentEngine::MakePathFromTemplate(
862 "blog" => $arBlog[
"URL"],
863 "user_id" => $arBlog[
"OWNER_ID"],
864 "group_id" =>
$arParams[
"SOCNET_GROUP_ID"] ??
null,
865 "post_id" => $arPost[
"ID"],
872 $arSoFields[
"USER_ID"] =
$arParams[
"user_id"];
876 $arSoFields[
"TAG"] =
$post->getTags();
880 if (intval($logID) > 0)
883 'postId' => $arPost[
"ID"],
884 'authorId' => $arPost[
"AUTHOR_ID"],
887 $postFields =
$post->getFields();
888 $inlineAttachedObjectsIdList =
array();
890 if (preg_match_all(
'/\[DISK\s+FILE\s+ID\s*=\s*([n]*\d+)\s*\]/isu', $postFields[
'DETAIL_TEXT'],
$matches))
896 foreach($inlineFileList as
$key => $value)
899 preg_match(
'/^n(\d+)/isu', $value,
$matches)
904 $res = \Bitrix\Disk\AttachedObject::getList(
array(
906 '=ENTITY_TYPE' => \
Bitrix\
Disk\Uf\BlogPostConnector::className(),
907 'ENTITY_ID' => $postFields[
'ID'],
910 'select' =>
array(
'ID'),
912 foreach (
$res as $attachedObjectFields)
914 $inlineAttachedObjectsIdList[] = $attachedObjectFields[
'ID'];
923 $hasVideoTransforming = (
924 !empty($inlineAttachedObjectsIdList)
926 'attachedIdList' => $inlineAttachedObjectsIdList,
930 if ($hasVideoTransforming)
932 $socnetPerms =
array(
"SA",
"U".$arPost[
"AUTHOR_ID"]);
935 CSocNetLogRights::deleteByLogID($logID);
936 CSocNetLogRights::add($logID, $socnetPerms);
938 $updateFields =
array(
939 "TRANSFORM" => ($hasVideoTransforming ?
'Y' :
'N'),
942 if (Loader::includeModule(
"extranet"))
944 $updateFields[
"SITE_ID"] = CExtranet::getSitesByLogDestinations($socnetPerms, $arPost[
"AUTHOR_ID"],
$siteId);
947 CSocNetLog::update($logID, $updateFields);
949 if (Loader::includeModule(
'crm'))
951 CCrmLiveFeedComponent::processCrmBlogPostRights($logID, $arSoFields, $arPost,
'new');
955 'socnetPerms' => $socnetPerms,
957 'logEventId' => $arSoFields[
"EVENT_ID"],
959 !empty(
$arParams[
"SEND_COUNTER_TO_AUTHOR"])
960 &&
$arParams[
"SEND_COUNTER_TO_AUTHOR"] ==
"Y"
964 if ($hasVideoTransforming)
966 CUserOptions::setOption(
"socialnetwork",
"~log_videotransform_popup_show",
"Y");
967 CUserOptions::setOption(
"socialnetwork",
"~log_videotransform_post_url", $arSoFields[
"URL"]);
968 CUserOptions::setOption(
"socialnetwork",
"~log_videotransform_post_id", $arPost[
"ID"]);
980 static $blogPostEventIdList =
null;
982 if (!CModule::IncludeModule(
'socialnetwork'))
989 preg_match(
"#^(.*?)<cut[\s]*(/>|>).*?$#is", $arPost[
"DETAIL_TEXT"], $arMatches);
990 if (
count($arMatches) <= 0)
992 preg_match(
"#^(.*?)\[cut[\s]*(/\]|\]).*?$#is", $arPost[
"DETAIL_TEXT"], $arMatches);
995 $cut_suffix = (
count($arMatches) > 0 ?
"#CUT#" :
"");
999 while ($arImage =
$res->Fetch())
1001 $arImages[$arImage[
'ID']] = $arImage[
'FILE_ID'];
1005 ($arPost[
"DETAIL_TEXT_TYPE"] ??
null) ===
"html"
1007 && $arBlog[
"ALLOW_HTML"] ===
"Y"
1010 $arAllow =
array(
"HTML" =>
"Y",
"ANCHOR" =>
"Y",
"IMG" =>
"Y",
"SMILES" =>
"N",
"NL2BR" =>
"N",
"VIDEO" =>
"Y",
"QUOTE" =>
"Y",
"CODE" =>
"Y");
1013 $arAllow[
"VIDEO"] =
"N";
1015 $text4message = $parserBlog->convert($arPost[
"DETAIL_TEXT"],
true, $arImages, $arAllow);
1019 $arAllow =
array(
"HTML" =>
"N",
"ANCHOR" =>
"N",
"BIU" =>
"N",
"IMG" =>
"N",
"QUOTE" =>
"N",
"CODE" =>
"N",
"FONT" =>
"N",
"TABLE" =>
"N",
"LIST" =>
"N",
"SMILES" =>
"N",
"NL2BR" =>
"N",
"VIDEO" =>
"N");
1020 $text4message = $parserBlog->convert($arPost[
"DETAIL_TEXT"],
true, $arImages, $arAllow,
array(
"isSonetLog"=>
true));
1023 $text4message .= $cut_suffix;
1027 isset($arPost[
'UF_BLOG_POST_IMPRTNT'])
1028 && (
int)$arPost[
'UF_BLOG_POST_IMPRTNT'] > 0
1034 isset($arPost[
'UF_GRATITUDE'])
1035 && (
int)$arPost[
'UF_GRATITUDE'] > 0
1041 isset($arPost[
'UF_BLOG_POST_VOTE'])
1042 && (
int)$arPost[
'UF_BLOG_POST_VOTE'] > 0
1048 $arSoFields =
array(
1049 "TITLE_TEMPLATE" =>
"#USER_NAME# ".
GetMessage(
"BLG_SONET_TITLE"),
1050 "TITLE" => $arPost[
"TITLE"],
1051 "MESSAGE" => $text4message,
1052 "TEXT_MESSAGE" => $text4message,
1053 "ENABLE_COMMENTS" => (
1054 array_key_exists(
"ENABLE_COMMENTS", $arPost)
1055 && $arPost[
"ENABLE_COMMENTS"] ===
"N"
1059 "EVENT_ID" => $eventId,
1062 if ($blogPostEventIdList ===
null)
1064 $blogPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\BlogPost;
1065 $blogPostEventIdList = $blogPostLivefeedProvider->getEventId();
1069 array(
"ID" =>
"DESC"),
1071 "EVENT_ID" => $blogPostEventIdList,
1072 "SOURCE_ID" => $postID,
1076 array(
"ID",
"ENTITY_TYPE",
"ENTITY_ID",
"EVENT_ID",
"USER_ID")
1078 if ($arLog =
$dbRes->Fetch())
1083 $profileBlogPost =
false;
1084 foreach($socnetPerms as
$perm)
1088 $profileBlogPost =
true;
1095 && !in_array(
"U".$arPost[
"AUTHOR_ID"], $socnetPerms)
1098 $socnetPerms[] =
"U".$arPost[
"AUTHOR_ID"];
1099 if (CModule::IncludeModule(
"extranet"))
1102 "SITE_ID" => CExtranet::GetSitesByLogDestinations($socnetPerms, $arPost[
"AUTHOR_ID"], (
$arParams[
'SITE_ID'] ??
false)),
1105 $socnetPerms[] =
"SA";
1108 \CSocNetLogRights::deleteByLogID($arLog[
"ID"]);
1109 \CSocNetLogRights::add($arLog[
"ID"], $socnetPerms);
1111 if (Loader::includeModule(
'crm'))
1113 CCrmLiveFeedComponent::processCrmBlogPostRights($arLog[
"ID"], $arLog, $arPost,
'edit');
1118 public static function DeleteLog($postID, $bMicroblog =
false)
1122 static $blogPostEventIdList =
null;
1124 if (!CModule::IncludeModule(
'socialnetwork'))
1132 "POST_ID" => $postID,
1139 while ($arComment = $dbComment->Fetch())
1142 array(
"ID" =>
"DESC"),
1144 "EVENT_ID" => Array(
"blog_comment",
"blog_comment_micro"),
1145 "SOURCE_ID" => $arComment[
"ID"],
1155 if ($blogPostEventIdList ===
null)
1157 $blogPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\BlogPost;
1158 $blogPostEventIdList = $blogPostLivefeedProvider->getEventId();
1162 array(
"ID" =>
"DESC"),
1164 "EVENT_ID" => $blogPostEventIdList,
1165 "SOURCE_ID" => $postID,
1178 !empty($arPostFields[
'UF_GRATITUDE'])
1179 && !empty($arPostFields[
'UF_GRATITUDE'][
'VALUE'])
1180 && intval($arPostFields[
'UF_GRATITUDE'][
'VALUE']) > 0
1181 && Loader::includeModule(
'iblock')
1184 \CIBlockElement::delete(intval($arPostFields[
'UF_GRATITUDE'][
'VALUE']));
1191 $blogID = intval($blogID);
1193 $code = preg_replace(
"/[^a-zA-Z0-9_-]/is",
"", Trim(
$code));
1194 if(
$code ==
'' || intval($blogID) <= 0)
1198 !empty(static::$arBlogPostIdCache[$blogID.
"_".
$code])
1199 && intval(static::$arBlogPostIdCache[$blogID.
"_".
$code]) > 0)
1201 return static::$arBlogPostIdCache[$blogID.
"_".
$code];
1206 if(intval($blogID) > 0)
1209 if($arPost = $dbPost->Fetch())
1211 static::$arBlogPostIdCache[$blogID.
"_".
$code] = $arPost[
"ID"];
1212 $postID = $arPost[
"ID"];
1221 $postID = intval($postID);
1222 $code = preg_replace(
"/[^a-zA-Z0-9_-]/is",
"", trim(
$code ??
''));
1223 if(
$code ==
'' && intval($postID) <= 0)
1236 if(intval(
$ID) <= 0)
1252 || in_array(
'UA', $perms,
true)
1253 || in_array(
'G2', $perms,
true)
1257 $perms1 = CBlogPost::GetSocnetGroups(
"U", $arPost[
"AUTHOR_ID"]);
1258 foreach($perms1 as
$val)
1273 $perms = array_unique($perms);
1275 foreach($perms as
$val)
1305 $permsNew = CBlogPost::GetSocnetGroups(
"G", $scID);
1306 foreach($permsNew as $val1)
1326 if(defined(
"BX_COMP_MANAGED_CACHE"))
1343 $strSql =
"DELETE FROM b_blog_socnet_rights WHERE POST_ID=".$ID;
1344 $DB->Query($strSql);
1353 static $allowedTypes =
false;
1355 if ($allowedTypes ===
false)
1357 $allowedTypes = Array(
"D",
"U",
"UP",
"SG",
"DR",
"G",
"AU");
1360 $allowedTypes[] =
"CRMCONTACT";
1364 if(intval(
$ID) > 0 && $entityType <>
'' &&
$entity <> '' && in_array($entityType, $allowedTypes))
1366 $arSCFields = Array(
"POST_ID" =>
$ID,
"ENTITY_TYPE" => $entityType,
"ENTITY_ID" => intval($entityID),
"ENTITY" =>
$entity);
1367 $arSCInsert =
$DB->PrepareInsert(
"b_blog_socnet_rights", $arSCFields);
1369 if ($arSCInsert[0] <>
'')
1372 "INSERT INTO b_blog_socnet_rights(".$arSCInsert[0].
") ".
1373 "VALUES(".$arSCInsert[1].
")";
1374 $DB->Query($strSql);
1381 public static function GetSocNetGroups($entity_type, $entity_id, $operation =
"view_post")
1383 $entity_id = intval($entity_id);
1386 if(!CModule::IncludeModule(
"socialnetwork"))
1392 if($entity_type ==
"G")
1394 $prefix =
"SG".$entity_id.
"_";
1395 $letter = CSocNetFeaturesPerms::GetOperationPerm(
SONET_ENTITY_GROUP, $entity_id, $feature, $operation);
1400 $prefix =
"SU".$entity_id.
"_";
1401 $letter = CSocNetFeaturesPerms::GetOperationPerm(
SONET_ENTITY_USER, $entity_id, $feature, $operation);
1430 $result[] =
'O'.$prefix.SONET_ROLES_ALL;
1431 $result[] =
'O'.$prefix.SONET_ROLES_AUTHORIZED;
1432 $result[] = $prefix.SONET_ROLES_USER;
1433 $result[] = $prefix.SONET_ROLES_MODERATOR;
1434 $result[] = $prefix.SONET_ROLES_OWNER;
1437 $result[] =
'O'.$prefix.SONET_ROLES_AUTHORIZED;
1438 $result[] = $prefix.SONET_ROLES_USER;
1439 $result[] = $prefix.SONET_ROLES_MODERATOR;
1440 $result[] = $prefix.SONET_ROLES_OWNER;
1443 $result[] =
'O'.$prefix.SONET_ROLES_AUTHORIZED;
1444 $result[] = $prefix.SONET_ROLES_USER;
1445 $result[] = $prefix.SONET_ROLES_MODERATOR;
1446 $result[] = $prefix.SONET_ROLES_OWNER;
1449 $result[] = $prefix.SONET_ROLES_MODERATOR;
1450 $result[] = $prefix.SONET_ROLES_OWNER;
1453 $result[] = $prefix.SONET_ROLES_OWNER;
1469 $cacheTtl = defined(
"BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
1470 $cacheId =
'blog_post_getsocnetperms_'.$ID;
1471 $cacheDir =
'/blog/getsocnetperms/'.$ID;
1475 $obCache->InitCache($cacheTtl, $cacheId, $cacheDir)
1483 $obCache->StartDataCache();
1485 $strSql =
"SELECT SR.ENTITY_ID, SR.ENTITY_TYPE, SR.ENTITY FROM b_blog_socnet_rights SR
1486 INNER JOIN b_blog_post P ON (P.ID = SR.POST_ID)
1487 WHERE SR.POST_ID=".$ID.
" ORDER BY SR.ENTITY ASC";
1494 if(defined(
"BX_COMP_MANAGED_CACHE"))
1514 $strSql =
"SELECT SR.ENTITY_TYPE, SR.ENTITY_ID, SR.ENTITY,
1515 U.NAME as U_NAME, U.LAST_NAME as U_LAST_NAME, U.SECOND_NAME as U_SECOND_NAME, U.LOGIN as U_LOGIN, U.PERSONAL_PHOTO as U_PERSONAL_PHOTO, U.EXTERNAL_AUTH_ID as U_EXTERNAL_AUTH_ID,
1517 FROM b_blog_socnet_rights SR
1518 INNER JOIN b_blog_post P
1519 ON (P.ID = SR.POST_ID)
1521 ON (U.ID = SR.ENTITY_ID AND SR.ENTITY_TYPE = 'U')
1522 LEFT JOIN b_iblock_section EL
1523 ON (EL.ID = SR.ENTITY_ID AND SR.ENTITY_TYPE = 'DR' AND EL.ACTIVE = 'Y')
1525 SR.POST_ID = " .
$ID .
"
1559 $strSql =
"SELECT SR.ENTITY FROM b_blog_socnet_rights SR
1560 INNER JOIN b_blog_post P ON (P.ID = SR.POST_ID)
1561 WHERE SR.POST_ID=".$ID.
"
1562 ORDER BY SR.ENTITY ASC";
1575 $entity_id = intval($entity_id);
1576 $perms = CBlogPost::GetSocnetGroups($entity_type, $entity_id, $operation);
1579 if($entity_type ==
"G")
1580 $type = $type2 =
"SG";
1581 $DB->Query(
"DELETE FROM b_blog_socnet_rights
1583 ENTITY_TYPE = '".
$type.
"'
1584 AND ENTITY_ID = ".$entity_id.
"
1585 AND ENTITY <> '".$type2.$entity_id.
"'
1586 AND ENTITY <> '".
$type.$entity_id.
"'
1588 foreach($perms as
$val)
1590 $DB->Query(
"INSERT INTO b_blog_socnet_rights (POST_ID, ENTITY_TYPE, ENTITY_ID, ENTITY)
1591 SELECT SR.POST_ID, SR.ENTITY_TYPE, SR.ENTITY_ID, '".
$DB->ForSql(
$val).
"' FROM b_blog_socnet_rights SR
1592 WHERE SR.ENTITY = '".$type2.$entity_id.
"'");
1599 $entity_id = intval($entity_id);
1605 if($entity_type ==
"G")
1606 $type = $type2 =
"SG";
1610 SELECT SR.POST_ID, SR.ENTITY, SR.ENTITY_ID, SR.ENTITY_TYPE FROM b_blog_socnet_rights SR
1612 SR.POST_ID IN (SELECT POST_ID FROM b_blog_socnet_rights WHERE ENTITY_TYPE='".
$type.
"' AND ENTITY_ID=".$entity_id.
" AND ENTITY = '".
$type.$entity_id.
"')
1613 AND SR.ENTITY <> '".$type2.$entity_id.
"'
1632 $cId = md5(serialize(func_get_args()));
1636 && isset($postId[
"POST_ID"])
1643 $postAuthor = (isset(
$arParams[
"POST_AUTHOR_ID"]) ?
$arParams[
"POST_AUTHOR_ID"] : 0);
1646 $bIgnoreAdmin = (isset(
$arParams[
"IGNORE_ADMIN"]) ?
$arParams[
"IGNORE_ADMIN"] :
false);
1650 $bPublic = $logId = $bIgnoreAdmin =
false;
1663 $postId = intval($postId);
1669 if (!empty(static::$arSocNetPostPermsCache[$cId]))
1671 return static::$arSocNetPostPermsCache[$cId];
1674 if (!CModule::IncludeModule(
"socialnetwork"))
1680 $arAvailPerms = array_keys(
$GLOBALS[
"AR_BLOG_PERMS"]);
1684 if (CSocNetUser::IsCurrentUserModuleAdmin())
1686 $perms = $arAvailPerms[
count($arAvailPerms) - 1];
1691 && CSocNetUser::IsUserModuleAdmin(
$userId)
1694 $perms = $arAvailPerms[
count($arAvailPerms) - 1];
1697 if(intval($postAuthor) <= 0)
1709 $arPost = $dbPost->Fetch();
1713 $arPost[
"AUTHOR_ID"] = $postAuthor;
1716 if (($arPost[
"AUTHOR_ID"] ??
null) ==
$userId)
1723 $arPerms = CBlogPost::GetSocNetPerms($postId);
1730 $rsUsers = CUser::GetList(
1737 "FIELDS" =>
array(
"ID",
"EXTERNAL_AUTH_ID"),
1738 "SELECT" =>
array(
"UF_DEPARTMENT"),
1742 if($arUser = $rsUsers->Fetch())
1744 if ($arUser[
"EXTERNAL_AUTH_ID"] ==
'email')
1747 isset($arPerms[
"U"])
1748 && isset($arPerms[
"U"][
$userId])
1756 !is_array($arUser[
"UF_DEPARTMENT"])
1757 || empty($arUser[
"UF_DEPARTMENT"])
1758 || intval($arUser[
"UF_DEPARTMENT"][0]) <= 0
1760 && CModule::IncludeModule(
'extranet')
1761 && ($extranet_site_id = CExtranet::GetExtranetSiteID())
1766 $arPostSite =
array();
1768 while ($arLogSite = $rsLogSite->Fetch())
1770 $arPostSite[] = $arLogSite[
"LID"];
1773 if (!in_array($extranet_site_id, $arPostSite))
1790 $arEntities = Array();
1791 if (!empty(static::$arUACCache[
$userId]))
1793 $arEntities = static::$arUACCache[
$userId];
1801 preg_match(
'/^DR([0-9]+)/',
$code, $match)
1802 || preg_match(
'/^D([0-9]+)/',
$code, $match)
1803 || preg_match(
'/^IU([0-9]+)/',
$code, $match)
1808 elseif (preg_match(
'/^SG([0-9]+)_([A-Z])/',
$code, $match))
1810 $arEntities[
"SG"][$match[1]][$match[2]] = $match[2];
1813 static::$arUACCache[
$userId] = $arEntities;
1816 foreach($arPerms as $t =>
$val)
1818 foreach(
$val as $id =>
$p)
1836 if (!\
Bitrix\Main\ModuleManager::isModuleInstalled(
'intranet'))
1842 $currentUserType = self::getCurrentUserType(
$userId);
1844 if ($currentUserType ===
'employee')
1849 $currentUserType ===
'extranet'
1850 && Loader::includeModule(
'extranet')
1851 && ($extranetSiteId = CExtranet::getExtranetSiteId())
1856 '=SOURCE_ID' => $postId,
1859 'select' => [
'ID' ],
1861 if ($logFields =
$res->fetch())
1865 '=LOG_ID' => $logFields[
'ID'],
1866 '=SITE_ID' => $extranetSiteId,
1868 'select' => [
'LOG_ID' ],
1885 if(!empty($arEntities[
"SG"][$id]))
1887 foreach($arEntities[
"SG"][$id] as
$gr)
1889 if(in_array(
"SG".$id.
"_".
$gr,
$p))
1898 if($t ==
"DR" && !empty($arEntities[
"DR"]))
1900 if(in_array(
"DR".$id, $arEntities[
"DR"]))
1916 && !empty($arPerms[
'SG'])
1919 $openedWorkgroupsList = [];
1920 foreach ($arPerms[
'SG'] as $arSGPerm)
1922 if (empty($arSGPerm))
1927 foreach($arSGPerm as $sgPerm)
1934 $openedWorkgroupsList[] = (int)
$matches[1];
1941 !empty($openedWorkgroupsList)
1942 && Loader::includeModule(
'socialnetwork')
1945 !\
Bitrix\Main\ModuleManager::isModuleInstalled(
'intranet')
1946 || self::getCurrentUserType(
$userId) ===
'employee'
1959 $arGroupsId = Array();
1960 if(!empty($arPerms[
"SG"]))
1962 foreach($arPerms[
"SG"] as $gid =>
$val)
1964 if(!empty($arEntities[
"SG"][$gid]))
1965 $arGroupsId[] = $gid;
1969 $operation = Array(
"full_post",
"moderate_post",
"write_post",
"premoderate_post");
1970 if(!empty($arGroupsId))
1972 foreach($operation as $v)
1979 foreach(
$f as $gid =>
$val)
1981 if(in_array(
$val, $arEntities[
"SG"][$gid]))
1988 case "moderate_post":
1994 case "premoderate_post":
2007 $res = \Bitrix\Socialnetwork\WorkgroupTable::getList([
2009 '@ID' => $arGroupsId,
2024 static::$arSocNetPostPermsCache[$cId] = $perms;
2029 private static function getCurrentUserType(
$userId)
2031 static $currentUserType =
null;
2039 $currentUserType ===
null
2040 && Loader::includeModule(
'intranet')
2043 $res = \Bitrix\Intranet\UserTable::getList([
2047 'select' => [
'ID',
'USER_TYPE' ],
2049 if ($userFields =
$res->fetch())
2051 $currentUserType = $userFields[
'USER_TYPE'];
2055 return $currentUserType;
2060 static $blogPostEventIdList =
null;
2062 $arUserIDSent =
array();
2064 if (!CModule::IncludeModule(
"im"))
2066 return $arUserIDSent;
2085 if(!empty(
$arParams[
"TO_SOCNET_RIGHTS"]))
2087 foreach(
$arParams[
"TO_SOCNET_RIGHTS"] as $v)
2089 if(mb_substr($v, 0, 1) ==
"U")
2091 $u = intval(mb_substr($v, 1));
2094 && !in_array($u, $arUsers)
2096 !array_key_exists(
"U",
$arParams[
"TO_SOCNET_RIGHTS_OLD"])
2097 || empty(
$arParams[
"TO_SOCNET_RIGHTS_OLD"][
"U"][$u])
2108 if (!empty($arUsers))
2115 "!=EXTERNAL_AUTH_ID" =>
'email',
2117 'select' =>
array(
"ID"),
2122 while ($arUser = $rsUser->fetch())
2124 $arUsers[] = $arUser[
"ID"];
2128 $arMessageFields =
array(
2131 "FROM_USER_ID" =>
$arParams[
"FROM_USER_ID"],
2133 "NOTIFY_ANSWER" =>
"Y",
2134 "NOTIFY_MODULE" =>
"blog",
2135 "PARSE_LINK" =>
"N",
2138 $aditGM = $authorName = $authorAvatarUrl =
"";
2139 if(intval(
$arParams[
"FROM_USER_ID"]) > 0)
2141 $dbUser = CUser::GetByID(
$arParams[
"FROM_USER_ID"]);
2142 if($arUser = $dbUser->Fetch())
2144 if($arUser[
"PERSONAL_GENDER"] ==
"F")
2146 $aditGM =
"_FEMALE";
2149 if (!empty($arUser[
"PERSONAL_PHOTO"]))
2151 $avatarSize = (isset(
$arParams[
"PUSH_AVATAR_SIZE"]) && intval(
$arParams[
"PUSH_AVATAR_SIZE"]) > 0 ? intval(
$arParams[
"PUSH_AVATAR_SIZE"]) : 100);
2152 $imageResized = CFile::resizeImageGet(
2153 $arUser[
"PERSONAL_PHOTO"],
2155 "width" => $avatarSize,
2156 "height" => $avatarSize,
2168 ? CUser::FormatName(CSite::GetNameFormat(), $arUser,
true)
2174 if (CModule::IncludeModule(
"socialnetwork"))
2176 if ($blogPostEventIdList ===
null)
2178 $blogPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\BlogPost;
2179 $blogPostEventIdList = $blogPostLivefeedProvider->getEventId();
2185 "EVENT_ID" => $blogPostEventIdList,
2192 if ($arLog = $rsLog->Fetch())
2194 $arMessageFields[
"LOG_ID"] = $arLog[
"ID"];
2198 $arTitle = self::processNotifyTitle(
$arParams[
"TITLE"]);
2200 $arParams[
"TITLE_OUT"] = $arTitle[
'TITLE_OUT'];
2201 $bTitleEmpty = $arTitle[
'IS_TITLE_EMPTY'];
2203 $serverName = (CMain::IsHTTPS() ?
"https" :
"http").
"://".((defined(
"SITE_SERVER_NAME") && SITE_SERVER_NAME <>
'') ? SITE_SERVER_NAME : COption::GetOptionString(
"main",
"server_name",
""));
2208 $user_path = COption::GetOptionString(
"socialnetwork",
"user_page",
false,
SITE_ID);
2211 && mb_strpos(
$arParams[
"URL"], $user_path) === 0
2221 if(!is_array(
$arParams[
"MENTION_ID_OLD"] ??
null))
2226 $userIdsToMentions = $arNewRights = [];
2239 "NEED_FULL" =>
true,
2241 "IGNORE_ADMIN" =>
true,
2249 $userIdsToMentions[] =
$val;
2254 $userIdsToMentions = array_unique($userIdsToMentions);
2257 foreach($userIdsToMentions as $userIdToMention)
2259 $userIdToMention = (int)$userIdToMention;
2260 $arMessageFields[
"TO_USER_ID"] = $userIdToMention;
2274 mb_strpos(
$url,
"http://") === 0
2275 || mb_strpos(
$url,
"https://") === 0
2285 $arMessageFields[
"PUSH_PARAMS"] =
array(
2286 "ACTION" =>
"mention",
2289 if (!empty($authorAvatarUrl))
2291 $arMessageFields[
"PUSH_PARAMS"][
"ADVANCED_PARAMS"] =
array(
2292 'avatarUrl' => $authorAvatarUrl,
2293 'senderName' => $authorName,
2299 $arMessageFields[
"NOTIFY_EVENT"] =
"mention";
2300 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|POST_MENTION|".$arParams[
"ID"];
2301 $arMessageFields[
"NOTIFY_SUB_TAG"] =
"BLOG|POST_MENTION|" .
$arParams[
"ID"] .
'|' . $userIdToMention;
2305 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2306 "BLG_GP_IM_6".$aditGM,
2312 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2313 "BLG_GP_IM_6".$aditGM,
2318 ).
" ".$serverName.$url.
"";
2319 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2320 "BLG_GP_PUSH_6".$aditGM,
2322 "#name#" => $authorName,
2330 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2331 "BLG_GP_IM_6A".$aditGM,
2333 "#post#" =>
"<a href=\"".
$url.
"\" class=\"bx-notifier-item-action\">". Loc::getMessage(
"BLG_GP_IM_6B",
null, $languageId) .
"</a>",
2337 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2338 "BLG_GP_IM_6A".$aditGM,
2340 "#post#" => Loc::getMessage(
"BLG_GP_IM_6B",
null, $languageId),
2343 ).
" ".$serverName.$url.
"";
2344 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2345 "BLG_GP_PUSH_6A".$aditGM,
2347 "#name#" => $authorName,
2348 "#post#" => Loc::getMessage(
"BLG_GP_IM_6B",
null, $languageId),
2356 $arMessageFields[
"NOTIFY_EVENT"] =
"mention_comment";
2357 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|COMMENT_MENTION|".$arParams[
"ID"].
'|'.
$arParams[
"COMMENT_ID"];
2358 $arMessageFields[
"NOTIFY_SUB_TAG"] =
"BLOG|COMMENT_MENTION|".$arParams[
"COMMENT_ID"].
'|'.$userIdToMention;
2360 $commentCropped = truncateText(
$arParams[
"BODY"], 100);
2364 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2365 "BLG_GP_IM_71".$aditGM,
2368 "#comment#" => $commentCropped,
2372 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2373 "BLG_GP_IM_71".$aditGM,
2379 ).
" ".$serverName.$url.
"";
2380 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2381 "BLG_GP_PUSH_71".$aditGM,
2383 "#name#" => $authorName,
2385 "#comment#" => $commentCropped,
2392 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2393 "BLG_GP_IM_71A".$aditGM,
2395 "#post#" =>
"<a href=\"".
$url.
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_7B",
null, $languageId).
"</a>",
2396 "#comment#" => $commentCropped,
2400 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2401 "BLG_GP_IM_71A".$aditGM,
2403 "#post#" => Loc::getMessage(
"BLG_GP_IM_7B",
null, $languageId),
2406 ).
" ".$serverName.$url.
"";
2407 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2408 "BLG_GP_PUSH_71A".$aditGM,
2410 "#name#" => $authorName,
2411 "#post#" => Loc::getMessage(
"BLG_GP_IM_7B",
null, $languageId),
2412 "#comment#" => $commentCropped,
2419 $arMessageFields[
"PUSH_PARAMS"][
"TAG"] = $arMessageFields[
"NOTIFY_TAG"];
2421 $ID = CIMNotify::Add($arMessageFields);
2422 $arUserIDSent[] = $userIdToMention;
2426 && (
int)$arMessageFields[
"LOG_ID"] > 0
2429 foreach(
GetModuleEvents(
"blog",
"OnBlogPostMentionNotifyIm",
true) as $arEvent)
2437 $notifySubTag =
false;
2439 if (!empty($arUsers))
2443 $arMessageFields[
"PUSH_PARAMS"] =
array(
2447 if (!empty($authorAvatarUrl))
2449 $arMessageFields[
"PUSH_PARAMS"][
"ADVANCED_PARAMS"] =
array(
2450 'avatarUrl' => $authorAvatarUrl,
2451 'senderName' => $authorName,
2455 $arMessageFields[
"NOTIFY_EVENT"] =
"post";
2457 $notifySubTag = $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|POST|".$arParams[
"ID"];
2461 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2462 "BLG_GP_IM_1_MSGVER_1".$aditGM,
2468 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2469 "BLG_GP_IM_1_MSGVER_1".$aditGM,
2474 ).
" ".$serverName.$arParams[
"URL"].
"";
2475 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2476 "BLG_GP_PUSH_1".$aditGM,
2478 "#name#" => $authorName,
2486 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2487 "BLG_GP_IM_1A".$aditGM,
2489 "#post#" =>
"<a href=\"".
$arParams[
"URL"].
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_1B",
null, $languageId).
"</a>",
2493 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2494 "BLG_GP_IM_1A".$aditGM,
2496 "#post#" => Loc::getMessage(
"BLG_GP_IM_1B",
null, $languageId),
2498 ).
" ".$serverName.$arParams[
"URL"].
"";
2499 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2500 "BLG_GP_PUSH_1A".$aditGM,
2502 "#name#" => $authorName,
2503 "#post#" => Loc::getMessage(
"BLG_GP_IM_1B",
null, $languageId),
2511 $arMessageFields[
"PUSH_PARAMS"] =
array(
2512 "ACTION" =>
"comment",
2515 if (!empty($authorAvatarUrl))
2517 $arMessageFields[
"PUSH_PARAMS"][
"ADVANCED_PARAMS"] =
array(
2518 'avatarUrl' => $authorAvatarUrl,
2519 'senderName' => $authorName,
2523 $arMessageFields[
"NOTIFY_EVENT"] =
"comment";
2525 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|COMMENT|".$arParams[
"ID"].
'|'.
$arParams[
"COMMENT_ID"];
2526 $notifySubTag =
"BLOG|COMMENT|".$arParams[
"COMMENT_ID"];
2528 $commentCropped = truncateText(
$arParams[
"BODY"], 100);
2532 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2533 "BLG_GP_IM_41".$aditGM,
2536 "#comment#" => $commentCropped,
2540 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2541 "BLG_GP_IM_41".$aditGM,
2547 ).
" ".$serverName.$arParams[
"URL"].
"\n\n".
$arParams[
"BODY"];
2548 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2549 "BLG_GP_PUSH_41".$aditGM,
2551 "#name#" => $authorName,
2553 "#comment#" => $commentCropped,
2558 $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR"] = fn (?
string $languageId =
null) => Loc::getMessage(
2559 "BLG_GP_IM_51".$aditGM,
2562 "#comment#" => $commentCropped,
2566 $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2567 "BLG_GP_IM_51".$aditGM,
2573 ).
" ".$serverName.$arParams[
"URL"].
"\n\n".
$arParams[
"BODY"];
2574 $arMessageFields[
"PUSH_MESSAGE_AUTHOR"] = fn (?
string $languageId =
null) => Loc::getMessage(
2575 "BLG_GP_PUSH_51".$aditGM,
2577 "#name#" => $authorName,
2579 "#comment#" => $commentCropped,
2586 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2587 "BLG_GP_IM_41A".$aditGM,
2589 "#post#" =>
"<a href=\"".
$arParams[
"URL"].
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_4B",
null, $languageId).
"</a>",
2590 "#comment#" => $commentCropped,
2594 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2595 "BLG_GP_IM_41A".$aditGM,
2597 "#post#" => Loc::getMessage(
"BLG_GP_IM_4B",
null, $languageId),
2601 ).
" ".$serverName.$arParams[
"URL"].
"\n\n".
$arParams[
"BODY"];
2602 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2603 "BLG_GP_PUSH_41A".$aditGM,
2605 "#name#" => $authorName,
2606 "#post#" => Loc::getMessage(
"BLG_GP_IM_4B",
null, $languageId),
2607 "#comment#" => $commentCropped,
2612 $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR"] = fn (?
string $languageId =
null) => Loc::getMessage(
2613 "BLG_GP_IM_51A".$aditGM,
2615 "#post#" =>
"<a href=\"".
$arParams[
"URL"].
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_5B",
null, $languageId).
"</a>",
2616 "#comment#" => $commentCropped,
2620 $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2621 "BLG_GP_IM_51A".$aditGM,
2623 "#post#" => Loc::getMessage(
"BLG_GP_IM_5B",
null, $languageId),
2627 ).
" ".$serverName.$arParams[
"URL"].
"\n\n".
$arParams[
"BODY"];
2628 $arMessageFields[
"PUSH_MESSAGE_AUTHOR"] = fn (?
string $languageId =
null) => Loc::getMessage(
2629 "BLG_GP_PUSH_51A".$aditGM,
2631 "#name#" => $authorName,
2632 "#post#" => Loc::getMessage(
"BLG_GP_IM_5B",
null, $languageId),
2633 "#comment#" => $commentCropped,
2641 $arMessageFields[
"PUSH_PARAMS"] =
array(
2642 "ACTION" =>
"share",
2645 if (!empty($authorAvatarUrl))
2647 $arMessageFields[
"PUSH_PARAMS"][
"ADVANCED_PARAMS"] =
array(
2648 'avatarUrl' => $authorAvatarUrl,
2649 'senderName' => $authorName,
2653 $arMessageFields[
"NOTIFY_EVENT"] =
"share";
2654 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|SHARE|".$arParams[
"ID"];
2655 $notifySubTag =
"BLOG|POST|".$arParams[
"ID"];
2659 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2660 "BLG_GP_IM_8".$aditGM,
2666 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2667 "BLG_GP_IM_8".$aditGM,
2672 ).
" ".$serverName.$arParams[
"URL"].
"";
2673 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2674 "BLG_GP_PUSH_8".$aditGM,
2676 "#name#" => $authorName,
2684 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2685 "BLG_GP_IM_8A".$aditGM,
2687 "#post#" =>
"<a href=\"".
$arParams[
"URL"].
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_8B",
null, $languageId).
"</a>",
2691 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2692 "BLG_GP_IM_8A".$aditGM,
2694 "#post#" => Loc::getMessage(
"BLG_GP_IM_8B",
null, $languageId),
2697 ).
" ".$serverName.$arParams[
"URL"].
"";
2698 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2699 "BLG_GP_PUSH_8A".$aditGM,
2701 "#name#" => $authorName,
2702 "#post#" => Loc::getMessage(
"BLG_GP_IM_8B",
null, $languageId),
2710 $arMessageFields[
"PUSH_PARAMS"] =
array(
2711 "ACTION" =>
"share2users",
2714 if (!empty($authorAvatarUrl))
2716 $arMessageFields[
"PUSH_PARAMS"][
"ADVANCED_PARAMS"] =
array(
2717 'avatarUrl' => $authorAvatarUrl,
2718 'senderName' => $authorName,
2722 $arMessageFields[
"NOTIFY_EVENT"] =
"share2users";
2723 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|SHARE2USERS|".$arParams[
"ID"];
2724 $notifySubTag =
"BLOG|POST|".$arParams[
"ID"];
2728 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2729 "BLG_GP_IM_9".$aditGM,
2735 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2736 "BLG_GP_IM_9".$aditGM,
2741 ).
" ".$serverName.$arParams[
"URL"].
"";
2742 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2743 "BLG_GP_PUSH_9".$aditGM,
2745 "#name#" => $authorName,
2753 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2754 "BLG_GP_IM_9A".$aditGM,
2756 "#post#" =>
"<a href=\"".
$arParams[
"URL"].
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_9B",
null, $languageId).
"</a>",
2760 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2761 "BLG_GP_IM_9A".$aditGM,
2763 "#post#" => Loc::getMessage(
"BLG_GP_IM_9B",
null, $languageId),
2766 ).
" ".$serverName.$arParams[
"URL"].
"";
2767 $arMessageFields[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2768 "BLG_GP_PUSH_9A".$aditGM,
2770 "#name#" => $authorName,
2771 "#post#" => Loc::getMessage(
"BLG_GP_IM_9B",
null, $languageId),
2778 $arMessageFields[
"PUSH_PARAMS"][
"TAG"] = $arMessageFields[
"NOTIFY_TAG"];
2785 in_array(
$userId, $arUserIDSent)
2807 mb_strpos(
$url,
"http://") === 0
2808 || mb_strpos(
$url,
"https://") === 0
2817 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2818 "BLG_GP_IM_1_MSGVER_1".$aditGM,
2822 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2823 "BLG_GP_IM_1_MSGVER_1".$aditGM,
2826 ).
" (".$serverName.$url.
")";
2830 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2831 "BLG_GP_IM_1A".$aditGM,
2832 Array(
"#post#" =>
"<a href=\"".
$url.
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_1B",
null, $languageId).
"</a>"),
2835 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2836 "BLG_GP_IM_1A".$aditGM,
2837 Array(
"#post#" => Loc::getMessage(
"BLG_GP_IM_1B",
null, $languageId)),
2839 ).
" (".$serverName.$url.
")";
2844 $commentCropped = truncateText(
$arParams[
"BODY"], 100);
2848 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
"BLG_GP_IM_41".$aditGM,
array(
2850 "#comment#" => $commentCropped,
2852 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
"BLG_GP_IM_41".$aditGM,
array(
2855 ), $languageId).
" ".$serverName.$url;
2856 $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR"] = fn (?
string $languageId =
null) => Loc::getMessage(
"BLG_GP_IM_51".$aditGM,
array(
2858 "#comment#" => $commentCropped,
2860 $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
"BLG_GP_IM_51".$aditGM,
array(
2863 ), $languageId).
" ".$serverName.$url;
2867 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
"BLG_GP_IM_41A".$aditGM,
array(
2868 "#post#" =>
"<a href=\"".
$url.
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_4B",
null, $languageId).
"</a>",
2869 "#comment#" => $commentCropped,
2871 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
"BLG_GP_IM_41A".$aditGM,
array(
2872 "#post#" => Loc::getMessage(
"BLG_GP_IM_4B",
null, $languageId),
2874 ), $languageId).
" ".$serverName.$url;
2875 $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR"] = fn (?
string $languageId =
null) => Loc::getMessage(
"BLG_GP_IM_51A".$aditGM,
array(
2876 "#post#" =>
"<a href=\"".
$url.
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_5B",
null, $languageId).
"</a>",
2877 "#comment#" => $commentCropped,
2879 $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
"BLG_GP_IM_51A".$aditGM,
array(
2880 "#post#" => Loc::getMessage(
"BLG_GP_IM_5B",
null, $languageId),
2882 ), $languageId).
" ".$serverName.$url;
2889 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2890 "BLG_GP_IM_8".$aditGM,
2894 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2895 "BLG_GP_IM_8".$aditGM,
2898 ).
" ".$serverName.$url.
"";
2902 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2903 "BLG_GP_IM_8A".$aditGM,
2904 Array(
"#post#" =>
"<a href=\"".
$url.
"\" class=\"bx-notifier-item-action\">".Loc::getMessage(
"BLG_GP_IM_8B",
null, $languageId).
"</a>"),
2907 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2908 "BLG_GP_IM_8A".$aditGM,
2909 Array(
"#post#" => Loc::getMessage(
"BLG_GP_IM_8B",
null, $languageId)),
2911 ).
" ".$serverName.$url.
"";
2918 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2919 "BLG_GP_IM_9".$aditGM,
2923 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2924 "BLG_GP_IM_9".$aditGM,
2927 ).
" ".$serverName.$url.
"";
2931 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
2932 "BLG_GP_IM_9A".$aditGM,
2933 Array(
"#post#" =>
"<a href=\"".
$url.
"\" class=\"bx-notifier-item-action\">"
2943 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
2944 "BLG_GP_IM_9A".$aditGM,
2945 Array(
"#post#" => Loc::getMessage(
"BLG_GP_IM_9B",
null, $languageId)),
2947 ).
" ".$serverName.$url.
"";
2952 $arMessageFieldsTmp = $arMessageFields;
2957 $arMessageFieldsTmp[
"NOTIFY_MESSAGE"] = $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR"];
2958 $arMessageFieldsTmp[
"NOTIFY_MESSAGE_OUT"] = $arMessageFields[
"NOTIFY_MESSAGE_AUTHOR_OUT"];
2959 $arMessageFieldsTmp[
"PUSH_MESSAGE"] = $arMessageFields[
"PUSH_MESSAGE_AUTHOR"];
2963 $arMessageFieldsTmp[
"TO_USER_ID"] =
$userId;
2966 $arMessageFieldsTmp[
"NOTIFY_SUB_TAG"] = $notifySubTag.
"|".
$userId;
2969 CIMNotify::Add($arMessageFieldsTmp);
2977 && !empty(
$arParams[
"TO_SOCNET_RIGHTS"])
2980 $arGroupsId =
array();
2981 foreach(
$arParams[
"TO_SOCNET_RIGHTS"] as $perm_tmp)
2985 || preg_match(
'/^SG(\d+)$/', $perm_tmp,
$matches)
2992 !array_key_exists(
"SG",
$arParams[
"TO_SOCNET_RIGHTS_OLD"])
2993 || empty(
$arParams[
"TO_SOCNET_RIGHTS_OLD"][
"SG"][$group_id_tmp])
2997 $arGroupsId[] = $group_id_tmp;
3002 if (!empty($arGroupsId))
3004 $arTitle = self::processNotifyTitle(
$arParams[
"TITLE"]);
3005 $title = $arTitle[
'TITLE'];
3006 $title_out = $arTitle[
'TITLE_OUT'];
3008 $arNotifyParams =
array(
3009 "LOG_ID" => $arMessageFields[
"LOG_ID"],
3010 "GROUP_ID" => $arGroupsId,
3011 "NOTIFY_MESSAGE" =>
"",
3012 "FROM_USER_ID" =>
$arParams[
"FROM_USER_ID"],
3014 "MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
3015 "SONET_IM_NEW_POST",
3016 Array(
"#title#" =>
"[URL=#URL#]".
$title.
"[/URL]"),
3019 "MESSAGE_OUT" => fn (?
string $languageId =
null) => Loc::getMessage(
3020 "SONET_IM_NEW_POST",
3021 Array(
"#title#" => $title_out),
3024 "MESSAGE_CHAT" =>
GetMessage(
"SONET_IM_NEW_POST_CHAT".$aditGM, Array(
3025 "#title#" =>
"[URL=#URL#]".$title_out.
"[/URL]",
3027 "EXCLUDE_USERS" => array_merge([
$arParams[
"FROM_USER_ID"]], $arUserIDSent),
3028 "PERMISSION" =>
array(
3029 "FEATURE" =>
"blog",
3030 "OPERATION" =>
"view_post",
3034 $arUserIDSentBySubscription = CSocNetSubscription::NotifyGroup($arNotifyParams);
3035 if (!$arUserIDSentBySubscription)
3037 $arUserIDSentBySubscription =
array();
3039 $arUserIDSent = array_merge($arUserIDSent, $arUserIDSentBySubscription);
3046 && !empty(
$arParams[
'GRAT_DATA'][
'USERS'])
3047 && is_array(
$arParams[
'GRAT_DATA'][
'USERS'])
3050 $arMessageFieldsGrat = $arMessageFields;
3051 $arMessageFieldsGrat[
"NOTIFY_EVENT"] =
'grat';
3052 $arMessageFieldsGrat[
"NOTIFY_TAG"] =
"BLOG|POST|".$arParams[
"ID"];
3053 $arMessageFieldsGrat[
"PUSH_PARAMS"] = [
3055 "TAG" => $arMessageFieldsGrat[
"NOTIFY_TAG"],
3057 if (!empty($authorAvatarUrl))
3059 $arMessageFieldsGrat[
"PUSH_PARAMS"][
"ADVANCED_PARAMS"] =
array(
3060 'avatarUrl' => $authorAvatarUrl,
3061 'senderName' => $authorName,
3065 $arMessageFieldsGrat[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
'SONET_IM_POST_GRAT_NEW', [
3066 "#link_post_start#" =>
"<a href=\"".$urlOriginal.
"\" class=\"bx-notifier-item-action\">",
3067 "#link_post_end#" =>
"</a>",
3071 $arMessageFieldsGrat[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
'SONET_IM_POST_GRAT_NEW', [
3072 "#link_post_start#" =>
"",
3073 "#link_post_end#" =>
"",
3075 ], $languageId).
" ".$serverName.$urlOriginal.
"";
3076 $arMessageFieldsGrat[
"PUSH_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
'SONET_PUSH_POST_GRAT_NEW', [
3077 "#name#" => $authorName,
3082 foreach($gratUsers as $gratUserId)
3085 in_array($gratUserId, $arUserIDSent)
3086 ||
$arParams[
"FROM_USER_ID"] == $gratUserId
3094 "NEED_FULL" =>
true,
3095 "USER_ID" => $gratUserId,
3096 "IGNORE_ADMIN" =>
true,
3104 $arMessageFieldsTmp = $arMessageFieldsGrat;
3105 $arMessageFieldsTmp[
'TO_USER_ID'] = $gratUserId;
3106 $arMessageFieldsTmp[
'NOTIFY_SUB_TAG'] =
"BLOG|POST|".$arParams[
"ID"].
"|".$gratUserId;
3108 CIMNotify::Add($arMessageFieldsTmp);
3109 $arUserIDSent[] = $gratUserId;
3113 return $arUserIDSent;
3119 Loader::includeModule(
'extranet')
3121 && class_exists(
'Bitrix\Extranet\Service\ServiceContainer')
3126 $collaberService = Extranet\Service\ServiceContainer::getInstance()->getCollaberService();
3128 catch (Exception $exception)
3133 $users = array_filter(
3144 $arUserIDSent =
array();
3145 $moderatorList =
array();
3148 !Loader::includeModule(
"im")
3149 || !Loader::includeModule(
"socialnetwork")
3152 return $arUserIDSent;
3157 return $arUserIDSent;
3162 && is_array(
$arParams[
"TO_SOCNET_RIGHTS"])
3163 && !empty(
$arParams[
"TO_SOCNET_RIGHTS"])
3166 $arGroupChecked =
array();
3172 $sonetGroupId = intval(
$matches[1]);
3174 if (in_array($sonetGroupId, $arGroupChecked))
3179 $arGroupChecked[] = $sonetGroupId;
3181 if ($sonetGroupId > 0)
3183 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(
3187 (
$arParams[
'TYPE'] ===
'POST' ?
'moderate_post' :
'moderate_comment')
3190 if ($featureOperationPerms)
3192 $res = \Bitrix\Socialnetwork\UserToGroupTable::getList(
array(
3194 '<=ROLE' => $featureOperationPerms,
3195 'GROUP_ID' => $sonetGroupId,
3196 '=GROUP.ACTIVE' =>
'Y',
3198 'select' =>
array(
'USER_ID'),
3200 while ($relation =
$res->fetch())
3202 if (!isset($moderatorList[$relation[
'USER_ID']]))
3204 $moderatorList[$relation[
'USER_ID']] =
array(
3205 'USER_ID' => $relation[
'USER_ID'],
3206 'GROUP_ID' => $sonetGroupId,
3216 if (!empty($moderatorList))
3218 $arMessageFields =
array(
3221 "NOTIFY_MODULE" =>
"blog",
3224 $arTitle = self::processNotifyTitle(
$arParams[
"TITLE"]);
3226 $arParams[
"TITLE_OUT"] = $arTitle[
'TITLE_OUT'];
3227 $bTitleEmpty = $arTitle[
'IS_TITLE_EMPTY'];
3228 $serverName = (CMain::IsHTTPS() ?
"https" :
"http").
"://".((defined(
"SITE_SERVER_NAME") && SITE_SERVER_NAME <>
'') ? SITE_SERVER_NAME : COption::GetOptionString(
"main",
"server_name",
""));
3233 $arMessageFields[
"NOTIFY_EVENT"] =
"moderate_post";
3234 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|MODERATE_POST|".$arParams[
"POST_ID"];
3236 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
3237 (!$bTitleEmpty ?
"SONET_IM_NEW_POST_TO_MODERATE_W_TITLE" :
"SONET_IM_NEW_POST_TO_MODERATE_WO_TITLE"),
3239 "#link_mod_start#" =>
"<a href=\"#MODERATION_URL#\" class=\"bx-notifier-item-action\">",
3240 "#link_mod_end#" =>
"</a>",
3246 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
3247 (!$bTitleEmpty ?
"SONET_IM_NEW_POST_TO_MODERATE_W_TITLE" :
"SONET_IM_NEW_POST_TO_MODERATE_WO_TITLE"),
3249 "#link_mod_start#" =>
"",
3250 "#link_mod_end#" =>
"",
3254 ).
" #SERVER_NAME##MODERATION_URL#";
3258 $arMessageFields[
"NOTIFY_EVENT"] =
"moderate_comment";
3259 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|COMMENT|".$arParams[
"POST_ID"].
'|'.
$arParams[
"COMMENT_ID"];
3261 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
3262 (!$bTitleEmpty ?
"SONET_IM_NEW_COMMENT_TO_MODERATE_W_TITLE" :
"SONET_IM_NEW_COMMENT_TO_MODERATE_WO_TITLE"),
3264 "#link_com_start#" =>
"<a href=\"#COMMENT_URL#\" class=\"bx-notifier-item-action\">",
3265 "#link_com_end#" =>
"</a>",
3271 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
3272 (!$bTitleEmpty ?
"SONET_IM_NEW_COMMENT_TO_MODERATE_W_TITLE" :
"SONET_IM_NEW_COMMENT_TO_MODERATE_WO_TITLE"),
3274 "#link_com_start#" =>
"",
3275 "#link_com_end#" =>
"",
3279 ).
" #SERVER_NAME##COMMENT_URL#";
3282 foreach($moderatorList as $moderator)
3284 $moderatorId = $moderator[
'USER_ID'];
3285 $groupId = $moderator[
'GROUP_ID'];
3287 if ($moderatorId !=
$arParams[
"FROM_USER_ID"])
3289 $arMessageFieldsCurrent = $arMessageFields;
3290 $arMessageFieldsCurrent[
"TO_USER_ID"] = $moderatorId;
3292 $userModerationUrl = str_replace(
'#group_id#', $groupId, $moderationUrl);
3293 $userCommentUrl =
$arParams[
'COMMENT_URL'] ??
null;
3299 "MODERATION_URL" => $userModerationUrl,
3306 $userModerationUrl =
$arTmp[
"URLS"][
"MODERATION_URL"];
3307 $userCommentUrl =
$arTmp[
"URLS"][
"COMMENT_URL"];
3310 mb_strpos($userModerationUrl,
"http://") === 0
3311 || mb_strpos($userModerationUrl,
"https://") === 0
3317 $notifyMessage = clone $arMessageFields[
"NOTIFY_MESSAGE"];
3318 $notifyMessageOut = clone $arMessageFields[
"NOTIFY_MESSAGE_OUT"];
3320 $arMessageFieldsCurrent[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => str_replace(
3321 array(
'#MODERATION_URL#',
'#COMMENT_URL#'),
3322 array($userModerationUrl, $userCommentUrl),
3323 $notifyMessage($languageId)
3325 $arMessageFieldsCurrent[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => str_replace(
3326 array(
'#MODERATION_URL#',
'#SERVER_NAME#',
'#COMMENT_URL#'),
3327 array($userModerationUrl, $serverName, $userCommentUrl),
3328 $notifyMessageOut($languageId)
3331 CIMNotify::Add($arMessageFieldsCurrent);
3333 $arUserIDSent[] = $moderatorId;
3338 return $arUserIDSent;
3344 !Loader::includeModule(
"im")
3345 || !Loader::includeModule(
"socialnetwork")
3356 $arTitle = self::processNotifyTitle(
$arParams[
"TITLE"]);
3358 $arParams[
"TITLE_OUT"] = $arTitle[
'TITLE_OUT'];
3359 $bTitleEmpty = $arTitle[
'IS_TITLE_EMPTY'];
3360 $serverName = (CMain::IsHTTPS() ?
"https" :
"http").
"://".((defined(
"SITE_SERVER_NAME") && SITE_SERVER_NAME <>
'') ? SITE_SERVER_NAME : COption::GetOptionString(
"main",
"server_name",
""));
3362 $arMessageFields =
array(
3365 "NOTIFY_MODULE" =>
"blog",
3366 "TO_USER_ID" =>
$arParams[
"TO_USER_ID"],
3371 $arMessageFields[
"NOTIFY_EVENT"] =
"published_post";
3372 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|POST|".$arParams[
"POST_ID"];
3374 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
3375 (!$bTitleEmpty ?
"SONET_IM_NEW_POST_PUBLISHED_W_TITLE" :
"SONET_IM_NEW_POST_PUBLISHED_WO_TITLE"),
3377 "#link_post_start#" =>
"<a href=\"#POST_URL#\" class=\"bx-notifier-item-action\">",
3378 "#link_post_end#" =>
"</a>",
3384 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
3385 (!$bTitleEmpty ?
"SONET_IM_NEW_POST_PUBLISHED_W_TITLE" :
"SONET_IM_NEW_POST_PUBLISHED_WO_TITLE"),
3387 "#link_post_start#" =>
"",
3388 "#link_post_end#" =>
"",
3392 ).
" #SERVER_NAME##POST_URL#";
3396 $arMessageFields[
"NOTIFY_EVENT"] =
"published_comment";
3397 $arMessageFields[
"NOTIFY_TAG"] =
"BLOG|COMMENT|".$arParams[
"POST_ID"].
"|".
$arParams[
"COMMENT_ID"];
3399 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => Loc::getMessage(
3400 (!$bTitleEmpty ?
"SONET_IM_NEW_COMMENT_PUBLISHED_W_TITLE" :
"SONET_IM_NEW_COMMENT_PUBLISHED_WO_TITLE"),
3402 "#link_com_start#" =>
"<a href=\"#COMMENT_URL#\" class=\"bx-notifier-item-action\">",
3403 "#link_com_end#" =>
"</a>",
3409 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => Loc::getMessage(
3410 (!$bTitleEmpty ?
"SONET_IM_NEW_COMMENT_PUBLISHED_W_TITLE" :
"SONET_IM_NEW_COMMENT_PUBLISHED_WO_TITLE"),
3412 "#link_com_start#" =>
"",
3413 "#link_com_end#" =>
"",
3417 ).
" #SERVER_NAME##COMMENT_URL#";
3427 "POST_URL" => $userPostUrl,
3428 "COMMENT_URL" => $userCommentUrl,
3434 $userPostUrl =
$arTmp[
"URLS"][
"POST_URL"];
3435 $userCommentUrl =
$arTmp[
"URLS"][
"COMMENT_URL"];
3438 mb_strpos($userPostUrl,
"http://") === 0
3439 || mb_strpos($userPostUrl,
"https://") === 0
3445 $notifyMessage = clone $arMessageFields[
"NOTIFY_MESSAGE"];
3446 $notifyMessageOut = clone $arMessageFields[
"NOTIFY_MESSAGE_OUT"];
3448 $arMessageFields[
"NOTIFY_MESSAGE"] = fn (?
string $languageId =
null) => str_replace(
3449 array(
'#POST_URL#',
'#COMMENT_URL#'),
3450 array($userPostUrl, $userCommentUrl),
3451 $notifyMessage($languageId)
3453 $arMessageFields[
"NOTIFY_MESSAGE_OUT"] = fn (?
string $languageId =
null) => str_replace(
3454 array(
'#POST_URL#',
'#SERVER_NAME#',
'#COMMENT_URL#'),
3455 array($userPostUrl, $serverName, $userCommentUrl),
3456 $notifyMessageOut($languageId)
3459 CIMNotify::Add($arMessageFields);
3465 private static function processNotifyTitle(
$title)
3472 'IS_TITLE_EMPTY' => (trim(
$title,
" \t\n\r\0\x0B\xA0" ) ==
''),
3478 if (!CModule::IncludeModule(
'mail'))
3504 $nameTemplate = CSite::GetNameFormat(
"",
$arFields[
"siteId"]);
3509 $rsAuthor = CUser::GetById(
$arFields[
"authorId"]);
3510 $arAuthor = $rsAuthor->Fetch();
3511 $authorName = CUser::FormatName(
3520 $authorName =
'"'.$authorName.
'"';
3539 || !in_array(mb_strtoupper(
$arFields[
"type"]),
array(
"POST",
"POST_SHARE",
"COMMENT"))
3545 $arEmail = \Bitrix\Mail\User::getUserData(
$arFields[
"userId"], $nameTemplate);
3546 if (empty($arEmail))
3557 $arTitle = self::processNotifyTitle($arBlogPost[
"TITLE"]);
3558 $postTitle = $arTitle[
'TITLE'];
3560 switch(mb_strtoupper(
$arFields[
"type"]))
3563 $mailMessageId =
"<BLOG_COMMENT_".$arFields[
"commentId"].
"@".
$GLOBALS[
"SERVER_NAME"].
">";
3564 $mailTemplateType =
"BLOG_SONET_NEW_COMMENT";
3567 $mailMessageId =
"<BLOG_POST_".$arFields[
"postId"].
"@".
$GLOBALS[
"SERVER_NAME"].
">";
3568 $mailTemplateType =
"BLOG_SONET_POST_SHARE";
3571 $mailMessageId =
"<BLOG_POST_".$arFields[
"postId"].
"@".
$GLOBALS[
"SERVER_NAME"].
">";
3572 $mailTemplateType =
"BLOG_SONET_NEW_POST";
3575 $mailMessageInReplyTo =
"<BLOG_POST_".$arFields[
"postId"].
"@".
$GLOBALS[
"SERVER_NAME"].
">";
3576 $defaultEmailFrom = \Bitrix\Mail\User::getDefaultEmailFrom();
3578 foreach ($arEmail as
$userId => $arUser)
3580 $email = $arUser[
"EMAIL"];
3581 $nameFormatted = str_replace(
array(
'<',
'>',
'"'),
'', $arUser[
"NAME_FORMATTED"]);
3591 $res = \Bitrix\Mail\User::getReplyTo(
3607 $authorName = str_replace(
array(
'<',
'>',
'"'),
'', $authorName);
3612 "=Reply-To" => $authorName.
' <'.$replyTo.
'>',
3613 "=Message-Id" => $mailMessageId,
3614 "=In-Reply-To" => $mailMessageInReplyTo == $mailMessageId ?
'' : $mailMessageInReplyTo,
3615 "EMAIL_FROM" => $authorName.
' <'.$defaultEmailFrom.
'>',
3616 "EMAIL_TO" => (!empty($nameFormatted) ?
''.$nameFormatted.
' <'.
$email.
'>' :
$email),
3618 "COMMENT_ID" => (isset(
$arFields[
"commentId"]) ? intval(
$arFields[
"commentId"]) :
false),
3619 "POST_ID" => intval(
$arFields[
"postId"]),
3620 "POST_TITLE" => $postTitle,
3629 mb_strtoupper(
$arFields[
"type"]) ==
'COMMENT'
3630 && Loader::includeModule(
'crm')
3633 CCrmLiveFeedComponent::processCrmBlogComment(
array(
3634 "AUTHOR" => isset($arAuthor) ? $arAuthor :
false,
3635 "POST_ID" => intval(
$arFields[
"postId"]),
3636 "COMMENT_ID" => intval(
$arFields[
"commentId"]),
3637 "USER_ID" => array_keys($arEmail),
3647 $postId = intval($postId);
3651 $DB->Query(
"DELETE FROM b_blog_socnet_rights WHERE POST_ID = ".$postId);
3657 $arMentionedUserID =
array();
3661 preg_match_all(
"/\[user\s*=\s*([^\]]*)\](.+?)\[\/user\]/isu",
$arFields[
"DETAIL_TEXT"], $arMention);
3662 if (!empty($arMention))
3664 $arMentionedUserID = array_merge($arMentionedUserID, $arMention[1]);
3672 && isset($arPostUF[
"UF_GRATITUDE"])
3673 && is_array($arPostUF[
"UF_GRATITUDE"])
3674 && isset($arPostUF[
"UF_GRATITUDE"][
"VALUE"])
3675 && intval($arPostUF[
"UF_GRATITUDE"][
"VALUE"]) > 0
3676 && CModule::IncludeModule(
"iblock")
3680 !is_array(
$GLOBALS[
"CACHE_HONOUR"])
3681 || !array_key_exists(
"honour_iblock_id",
$GLOBALS[
"CACHE_HONOUR"])
3682 || intval(
$GLOBALS[
"CACHE_HONOUR"][
"honour_iblock_id"]) <= 0
3685 $rsIBlock = CIBlock::GetList(
array(),
array(
"=CODE" =>
"honour",
"=TYPE" =>
"structure"));
3692 if (intval(
$GLOBALS[
"CACHE_HONOUR"][
"honour_iblock_id"]) > 0)
3694 $rsElementProperty = CIBlockElement::GetProperty(
3695 $GLOBALS[
"CACHE_HONOUR"][
"honour_iblock_id"],
3696 $arPostUF[
"UF_GRATITUDE"][
"VALUE"]
3698 while ($arElementProperty = $rsElementProperty->GetNext())
3701 $arElementProperty[
"CODE"] ==
"USERS"
3702 && intval($arElementProperty[
"VALUE"]) > 0
3705 $arMentionedUserID[] = $arElementProperty[
"VALUE"];
3711 return $arMentionedUserID;
const BLOG_PERMS_MODERATE
const BLOG_PERMS_PREMODERATE
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getStatus($params=array())
static increment($params=array())
const EVENT_ID_POST_IMPORTANT
static getById($postId=0, $params=array())
static get($moduleId, $name, $default="", $siteId=false)
static getList(array $parameters=array())
static getBlogPostSocNetPerms($params=array())
static IsBlogOwner($ID, $userID)
static $arSocNetPostPermsCache
static CanUserDeletePost($id, $userId)
PreparePath2Post($realUrl, $url, $arParams=array())
static UpdateLog($postID, $arPost, $arBlog, $arParams)
static GetSocNetPermsName($ID)
static ChangeSocNetPermission($entity_type, $entity_id, $operation)
static DeleteSocNetPostPerms($postId)
static Notify($arPost, $arBlog, $arParams)
static GetBlogUserCommentPerms($id, $userId)
static NotifyImPublish($arParams=array())
static SetPostPerms($ID, $arPerms=array(), $permsType=BLOG_PERMS_POST)
static AddSocNetPerms($ID, $perms=array(), $arPost=array())
static GetPostID($postID, $code, $allowCode=false)
static CanUserEditPost($id, $userId)
static DeleteLog($postID, $bMicroblog=false)
static getSocNetPerms($ID, $useCache=true)
static GetID($code, $blogID)
static $arBlogPostIdCache
static getFullGroupRoleSet($role="", $prefix="")
static CheckFields($ACTION, &$arFields, $ID=0)
static UpdateSocNetPerms($ID, $perms=array(), $arPost=array())
static filterUsersToNotify(array $users)
static GetMentionedUserID($arFields)
static __AddSocNetPerms($ID, $entityType="", $entityID=0, $entity=null)
static GetBlogUserPostPerms($id, $userId)
static PreparePath($blogUrl, $postID=0, $siteID=False, $is404=True, $userID=0, $groupID=0)
static NotifyImReady($arParams=array())
static NotifyMail($arFields)
static GetSocNetGroups($entity_type, $entity_id, $operation="view_post")
static GetSocNetPostPerms( $postId=0, $bNeedFull=false, $userId=false, $postAuthor=0)
static NotifyIm($arParams)
static GetSocNetPostsPerms($entity_type, $entity_id)
static GetSocNetPermsCode($ID)
static GetUserPerms($arGroups, $blogID, $postID=0, $permsType=BLOG_PERMS_POST, $selectType=BLOG_BY_BLOG_USER_ID)
static GetUserNameEx($arUser, $arBlogUser, $arParams)
static GetUserGroups($ID, $blogID, $joinStatus="", $selectType=BLOG_BY_BLOG_USER_ID, $bUrl=false)
static GetByID($ID, $selectType=BLOG_BY_BLOG_USER_ID)
static Index($MODULE_ID, $ITEM_ID, $arFields, $bOverWrite=false, $SEARCH_SESS_ID='')
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static GetList( $arOrder=["ID"=> "DESC"], $arFilter=[], $arGroupBy=false, $arNavStartParams=false, $arSelectFields=[])
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static htmlspecialcharsExArray($array)
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static Update($ID, $arFields)
static Add($arFields, $bSendEvent=true)
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array(), $arParams=array())
static Update($ID, $arFields)
</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
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
const BX_RESIZE_IMAGE_EXACT
const SITE_DIR(!defined('LANG'))
ExecuteModuleEventEx($arEvent, $arParams=[])
htmlspecialcharsback($str)
IsModuleInstalled($module_id)
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
GetTime($timestamp, $type="SHORT", $site=false, $bSearchInSitesOnly=false)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
BXClearCache($full=false, $initdir='')
check_email($email, $strict=false, $domainCheck=false)
MakeTimeStamp($datetime, $format=false)
if(intval($iTestTransaction) > 0) $arTmp
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."%"
const SONET_ROLES_AUTHORIZED
const SONET_ROLES_MODERATOR
$GLOBALS['_____370096793']