32 global $USER, $CACHE_MANAGER, $APPLICATION;
35 is_set($params,
'SITE_ID')
36 && !empty($params[
'SITE_ID'])
42 isset($params[
'USER_ID'])
43 && (int)$params[
'USER_ID'] > 0
49 if (!Loader::includeModule(
'blog'))
51 $APPLICATION->throwException(
Loc::getMessage(
'SOCIALNETWORK_ITEM_HELPER_BLOG_MODULE_NOT_INSTALLED'),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_MODULE_BLOG_NOT_INSTALLED');
55 $blogGroupId = Option::get(
'socialnetwork',
'userbloggroup_id',
false, $siteId);
56 if (empty($blogGroupId))
61 if (!empty($blogGroupIdList))
63 $blogGroupId = array_shift($blogGroupIdList);
67 $blog = Blog::getByUser([
68 'GROUP_ID' => $blogGroupId,
70 'USER_ID' => $authorId,
76 $APPLICATION->throwException(
'Blog not found',
'SONET_CONTROLLER_LIVEFEED_BLOG_NOT_FOUND');
80 $connection = \Bitrix\Main\Application::getConnection();
81 $helper = $connection->getSqlHelper();
84 'BLOG_ID' => $blog[
'ID'],
85 'AUTHOR_ID' => $authorId,
86 '=DATE_CREATE' => $helper->getCurrentDateTimeFunction(),
87 '=DATE_PUBLISH' => $helper->getCurrentDateTimeFunction(),
89 'TITLE' => (($params[
'POST_TITLE'] ??
'') <>
'' ? $params[
'POST_TITLE'] :
''),
90 'DETAIL_TEXT' => $params[
'POST_MESSAGE'],
91 'DETAIL_TEXT_TYPE' =>
'text',
92 'PUBLISH_STATUS' => BLOG_PUBLISH_STATUS_PUBLISH,
95 'HAS_SOCNET_ALL' =>
'N'
99 ModuleManager::isModuleInstalled(
'mail')
100 && ModuleManager::isModuleInstalled(
'intranet')
102 !Loader::includeModule(
'bitrix24')
103 || \CBitrix24::isEmailConfirmed()
108 !empty($params[
'DEST'])
109 && is_array($params[
'DEST'])
113 'ERROR_MESSAGE' =>
false,
114 'PUBLISH_STATUS' => $postFields[
'PUBLISH_STATUS']
117 if ($emailUserAllowed)
119 $destinationList = $params[
'DEST'];
121 $params[
'DEST'] = array_unique($destinationList);
125 'DEST' => $params[
'DEST'],
126 'SITE_ID' => $siteId,
127 'AUTHOR_ID' => $authorId,
128 'MOBILE' => ($params[
'MOBILE'] ??
'N'),
131 if ($resultFields[
'ERROR_MESSAGE_PUBLIC'] ??
null)
136 if ($resultFields[
'ERROR_MESSAGE'])
138 $APPLICATION->throwException($resultFields[
'ERROR_MESSAGE']);
142 $postFields[
'PUBLISH_STATUS'] = $resultFields[
'PUBLISH_STATUS'];
145 !empty($params[
'SPERM'])
149 if ($emailUserAllowed)
151 $pseudoHttpPostFields = [
152 'SPERM' => $params[
'SPERM'],
153 'INVITED_USER_NAME' => (!empty($params[
'INVITED_USER_NAME']) && is_array($params[
'INVITED_USER_NAME']) ? $params[
'INVITED_USER_NAME'] : []),
154 'INVITED_USER_LAST_NAME' => (!empty($params[
'INVITED_USER_NAME']) && is_array($params[
'INVITED_USER_LAST_NAME']) ? $params[
'INVITED_USER_LAST_NAME'] : []),
155 'INVITED_USER_CRM_ENTITY' => (!empty($params[
'INVITED_USER_CRM_ENTITY']) && is_array($params[
'INVITED_USER_CRM_ENTITY']) ? $params[
'INVITED_USER_CRM_ENTITY'] : []),
156 'INVITED_USER_CREATE_CRM_CONTACT' => (!empty($params[
'INVITED_USER_CREATE_CRM_CONTACT']) && is_array($params[
'INVITED_USER_CREATE_CRM_CONTACT']) ? $params[
'INVITED_USER_CREATE_CRM_CONTACT'] : []),
159 'ALLOW_EMAIL_INVITATION' => true
162 if (!empty($temporaryParams[
'ERROR_MESSAGE']))
164 $APPLICATION->throwException($temporaryParams[
'ERROR_MESSAGE'],
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_ADD_ERROR');
168 $params[
'SPERM'] = $pseudoHttpPostFields[
'SPERM'];
172 'ERROR_MESSAGE' =>
false,
173 'PUBLISH_STATUS' => $postFields[
'PUBLISH_STATUS'],
177 'PERM' => $params[
'SPERM'],
179 'AUTHOR_ID' => $authorId,
183 $postFields[
'PUBLISH_STATUS'] = $resultFields[
'PUBLISH_STATUS'];
184 if (!empty($resultFields[
'ERROR_MESSAGE']))
186 $APPLICATION->throwException($resultFields[
'ERROR_MESSAGE'],
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_ADD_ERROR');
191 !Loader::includeModule(
'extranet')
192 || \CExtranet::isIntranetUser()
195 $postFields[
'SOCNET_RIGHTS'] = [
'UA' ];
198 if (empty($postFields[
'SOCNET_RIGHTS']))
200 $APPLICATION->throwException(
'No destination specified',
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_ADD_ERROR');
204 if ((
string)$postFields[
'TITLE'] ===
'')
206 $postFields[
'MICRO'] =
'Y';
207 $postFields[
'TITLE'] = preg_replace([
"/\n+/is" . BX_UTF_PCRE_MODIFIER,
"/\s+/is" . BX_UTF_PCRE_MODIFIER ],
' ', \blogTextParser::killAllTags($postFields[
'DETAIL_TEXT']));
208 $postFields[
'TITLE'] = trim($postFields[
'TITLE'],
" \t\n\r\0\x0B\xA0");
212 isset($params[
'IMPORTANT'])
213 && $params[
'IMPORTANT'] ===
'Y'
216 $postFields[
'UF_BLOG_POST_IMPRTNT'] =
true;
218 if (!empty($params[
'IMPORTANT_DATE_END']))
220 $endDate = \CRestUtil::unConvertDate($params[
'IMPORTANT_DATE_END']);
223 $postFields[
'UF_IMPRTANT_DATE_END'] = \Bitrix\Main\Type\DateTime::createFromUserTime($endDate);
228 if (isset($params[
'GRATITUDE_MEDAL'], $params[
'GRATITUDE_EMPLOYEES']))
230 $gratitudeElementId = \Bitrix\Socialnetwork\Helper\Gratitude::create([
231 'medal' => $params[
'GRATITUDE_MEDAL'],
232 'employees' => $params[
'GRATITUDE_EMPLOYEES']
234 if ($gratitudeElementId)
236 $postFields[
'UF_GRATITUDE'] = $gratitudeElementId;
241 !empty($params[
'UF_BLOG_POST_VOTE'])
242 && !empty($params[
'UF_BLOG_POST_VOTE_' . $params[
'UF_BLOG_POST_VOTE'] .
'_DATA'])
245 $postFields[
'UF_BLOG_POST_VOTE'] = $params[
'UF_BLOG_POST_VOTE'];
246 $GLOBALS[
'UF_BLOG_POST_VOTE_' . $params[
'UF_BLOG_POST_VOTE'] .
'_DATA'] = $params[
'UF_BLOG_POST_VOTE_' . $params[
'UF_BLOG_POST_VOTE'] .
'_DATA'];
249 if (!empty($params[
'BACKGROUND_CODE']))
251 $postFields[
'BACKGROUND_CODE'] = $params[
'BACKGROUND_CODE'];
255 isset($params[
'PARSE_PREVIEW'])
256 && $params[
'PARSE_PREVIEW'] ===
'Y'
257 && !empty($postFields[
'DETAIL_TEXT'])
261 $postFields[
'UF_BLOG_POST_URL_PRV'] = $urlPreviewValue;
264 $result = \CBlogPost::add($postFields);
268 $APPLICATION->throwException(
'Blog post hasn\'t been added',
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_ADD_ERROR');
274 'authorId' => $postFields[
'AUTHOR_ID']
277 \Bitrix\Main\FinderDestTable::merge([
278 'CONTEXT' =>
'blog_post',
283 isset($params[
'IMPORTANT'])
284 && $params[
'IMPORTANT'] ===
'Y'
287 \CBlogUserOptions::setOption($result,
'BLOG_POST_IMPRTNT',
'Y', $authorId);
289 if (defined(
'BX_COMP_MANAGED_CACHE'))
291 $CACHE_MANAGER->clearByTag(
'blogpost_important_all');
295 $categoryIdListFromPostData = BlogPostEdit\Tag::getTagsFromPostData([
296 'blogId' => $blog[
'ID'],
297 'tags' => $params[
'TAGS'] ??
'',
299 $newCategoryIdList = BlogPostEdit\Tag::parseTagsFromFields([
300 'blogCategoryIdList' => $categoryIdListFromPostData,
301 'postFields' => $postFields,
302 'blogId' => $blog[
'ID'],
304 $categoryIdList = array_merge($categoryIdListFromPostData, $newCategoryIdList);
305 if (!empty($categoryIdList))
307 \CBlogPostCategory::deleteByPostID($result);
308 foreach ($categoryIdList as $categoryId)
310 \CBlogPostCategory::add([
311 'BLOG_ID' => $postFields[
'BLOG_ID'],
312 'POST_ID' => $result,
313 'CATEGORY_ID' => $categoryId
320 'CATEGORY_ID' => implode(
',', $categoryIdList),
327 Option::get(
'disk',
'successfully_converted',
false)
328 && Loader::includeModule(
'disk')
329 && ($storage = \
Bitrix\Disk\Driver::getInstance()->getStorageByUserId($authorId))
330 && ($folder = $storage->getFolderForUploadedFiles())
336 isset($params[
'FILES'])
337 && is_array($params[
'FILES'])
341 foreach ($params[
'FILES'] as $fileData)
343 $fileFields = \CRestUtil::saveFile($fileData);
345 if (is_array($fileFields))
347 $file = $folder->uploadFile(
350 'NAME' => $fileFields[
'name'],
351 'CREATED_BY' => $authorId
359 $filesList[] = FileUserType::NEW_FILE_PREFIX . $file->getId();
365 isset($params[
'UF_BLOG_POST_FILE'])
366 && is_array($params[
'UF_BLOG_POST_FILE'])
369 $filesList = $params[
'UF_BLOG_POST_FILE'];
372 if (!empty($filesList))
378 'UF_BLOG_POST_FILE' => $filesList
384 $pathToPost = \Bitrix\Socialnetwork\Helper\Path::get(
'userblogpost_page', $siteId);
386 $postFields[
'ID'] = $result;
388 $postUrl = \CComponentEngine::makePathFromTemplate(htmlspecialcharsBack($pathToPost), [
389 'post_id' => $result,
390 'user_id' => $blog[
'OWNER_ID']
393 if ($postFields[
'PUBLISH_STATUS'] === BLOG_PUBLISH_STATUS_PUBLISH)
397 'allowVideo' => Option::get(
'blog',
'allow_video',
'Y'),
398 'PATH_TO_POST' => $pathToPost,
399 'user_id' => $authorId,
400 'NAME_TEMPLATE' => \CSite::getNameFormat(
null, $siteId),
403 $logId = \CBlogPost::notify($postFields, $blog, $paramsNotify);
406 && ($post = Post::getById($result))
409 \CSocNetLog::update($logId, [
410 'EVENT_ID' => self::getBlogPostEventId([
411 'postId' => $post->getId()
413 'SOURCE_ID' => $result,
414 'TAG' => $post->getTags(),
419 'TYPE' =>
'posts_last',
423 $mentionList = \Bitrix\Socialnetwork\Helper\Mention::getUserIds($postFields[
'DETAIL_TEXT']);
428 'TITLE' => $postFields[
'TITLE'],
429 'AUTHOR_ID' => $authorId
432 'postUrl' => $postUrl,
433 'socnetRights' => ($logId ?
LogRight::get($logId) : $postFields[
'SOCNET_RIGHTS']),
434 'socnetRightsOld' => [],
435 'mentionListOld' => [],
436 'mentionList' => $mentionList
440 $postFields[
'PUBLISH_STATUS'] === BLOG_PUBLISH_STATUS_READY
441 && !empty($postFields[
'SOCNET_RIGHTS'])
444 \CBlogPost::notifyImReady([
446 'POST_ID' => $result,
447 'TITLE' => $postFields[
'TITLE'],
448 'POST_URL' => $postUrl,
449 'FROM_USER_ID' => $authorId,
450 'TO_SOCNET_RIGHTS' => $postFields[
'SOCNET_RIGHTS']
453 $resultFields[
'WARNING_MESSAGE_PUBLIC'] =
Loc::getMessage(
'SOCIALNETWORK_ITEM_HELPER_MODERATION_WARNING');
456 foreach ($postFields[
'SOCNET_RIGHTS'] as $destination)
458 if (preg_match(
'/^SG(\d+)/i', $destination, $matches))
460 \CSocNetGroup::setLastActivity($matches[1]);
469 global $USER, $USER_FIELD_MANAGER, $APPLICATION, $CACHE_MANAGER;
471 $postId = (int) ($params[
'POST_ID'] ??
null);
475 $APPLICATION->throwException(
'Wrong post ID',
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_UPDATE_ERROR');
479 if (!Loader::includeModule(
'blog'))
481 $APPLICATION->throwException(
Loc::getMessage(
'SOCIALNETWORK_ITEM_HELPER_BLOG_MODULE_NOT_INSTALLED'),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_UPDATE_ERROR');
486 isset($params[
'USER_ID'])
487 && (int)$params[
'USER_ID'] > 0
494 is_set($params,
'SITE_ID')
495 && !empty($params[
'SITE_ID'])
501 'USER_ID' => $currentUserId,
505 if ($currentUserPerm <= Permissions::WRITE)
507 $APPLICATION->throwException(
'No write perms',
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_UPDATE_ERROR');
511 $postFields = Post::getById($postId)->getFields();
512 if (empty($postFields))
514 $APPLICATION->throwException(
'No post found',
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_UPDATE_ERROR');
518 $blog = Blog::getByUser([
519 'GROUP_ID' => Option::get(
'socialnetwork',
'userbloggroup_id',
false, $siteId),
520 'SITE_ID' => $siteId,
521 'USER_ID' => $postFields[
'AUTHOR_ID']
526 $APPLICATION->throwException(
'No blog found',
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_UPDATE_ERROR');
531 'PUBLISH_STATUS' => $postFields[
'PUBLISH_STATUS']
534 $updateFields[
'TITLE'] =
'';
535 $updateFields[
'MICRO'] =
'N';
537 if (isset($params[
'POST_TITLE']))
539 $updateFields[
'TITLE'] = $params[
'POST_TITLE'];
543 (
string)$updateFields[
'TITLE'] ===
''
544 && isset($params[
'POST_MESSAGE'])
547 $updateFields[
'MICRO'] =
'Y';
548 $updateFields[
'TITLE'] = preg_replace([
"/\n+/is" . BX_UTF_PCRE_MODIFIER,
"/\s+/is" . BX_UTF_PCRE_MODIFIER ],
' ', \blogTextParser::killAllTags($params[
'POST_MESSAGE']));
549 $updateFields[
'TITLE'] = trim($updateFields[
'TITLE'],
" \t\n\r\0\x0B\xA0");
552 if (($params[
'POST_MESSAGE'] ??
'') <>
'')
554 $updateFields[
'DETAIL_TEXT'] = $params[
'POST_MESSAGE'];
557 if (!empty($params[
'DEST']))
560 ModuleManager::isModuleInstalled(
'mail')
561 && ModuleManager::isModuleInstalled(
'intranet')
563 !Loader::includeModule(
'bitrix24')
564 || \CBitrix24::isEmailConfirmed()
568 $destinationList = $params[
'DEST'];
570 $params[
'DEST'] = array_unique($destinationList);
574 'ERROR_MESSAGE' =>
false,
575 'PUBLISH_STATUS' => $updateFields[
'PUBLISH_STATUS']
579 'DEST' => $params[
'DEST'],
580 'SITE_ID' => $siteId,
581 'AUTHOR_ID' => $postFields[
'AUTHOR_ID'],
582 'MOBILE' => ($params[
'MOBILE'] ??
'N'),
585 if ($resultFields[
'ERROR_MESSAGE_PUBLIC'] ??
null)
590 if ($resultFields[
'ERROR_MESSAGE'])
592 $APPLICATION->throwException($resultFields[
'ERROR_MESSAGE'],
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_UPDATE_ERROR');
596 $updateFields[
'PUBLISH_STATUS'] = $resultFields[
'PUBLISH_STATUS'];
599 if (isset($params[
'IMPORTANT']))
601 if ($params[
'IMPORTANT'] ===
'Y')
603 $updateFields[
'UF_BLOG_POST_IMPRTNT'] =
true;
605 if (!empty($params[
'IMPORTANT_DATE_END']))
607 $endDate = \CRestUtil::unConvertDate($params[
'IMPORTANT_DATE_END']);
610 $updateFields[
'UF_IMPRTANT_DATE_END'] = \Bitrix\Main\Type\DateTime::createFromUserTime($endDate);
616 $updateFields[
'UF_BLOG_POST_IMPRTNT'] =
false;
617 $updateFields[
'UF_IMPRTANT_DATE_END'] =
false;
621 $categoryIdListFromPostData = BlogPostEdit\Tag::getTagsFromPostData([
622 'blogId' => $blog[
'ID'],
623 'tags' => $params[
'TAGS'] ??
'',
626 $newCategoryIdList = BlogPostEdit\Tag::parseTagsFromFields([
627 'blogCategoryIdList' => $categoryIdListFromPostData,
628 'postFields' => $postFields,
629 'blogId' => $blog[
'ID'],
631 $categoryIdList = array_merge($categoryIdListFromPostData, $newCategoryIdList);
632 if (!empty($categoryIdList))
634 \CBlogPostCategory::deleteByPostID($postId);
635 foreach ($categoryIdList as $categoryId)
637 \CBlogPostCategory::add([
638 'BLOG_ID' => $postFields[
'BLOG_ID'],
639 'POST_ID' => $postId,
640 'CATEGORY_ID' => $categoryId
644 $updateFields[
'CATEGORY_ID'] = implode(
',', $categoryIdList);
645 $updateFields[
'HAS_TAGS'] =
'Y';
648 if (isset($params[
'GRATITUDE_MEDAL']))
651 !empty($params[
'GRATITUDE_MEDAL'])
652 && isset($params[
'GRATITUDE_EMPLOYEES'])
655 $gratitudeElementId = \Bitrix\Socialnetwork\Helper\Gratitude::create([
656 'medal' => $params[
'GRATITUDE_MEDAL'],
657 'employees' => $params[
'GRATITUDE_EMPLOYEES']
659 if ($gratitudeElementId)
661 $updateFields[
'UF_GRATITUDE'] = $gratitudeElementId;
662 $updateFields[
'HAS_PROPS'] =
'Y';
667 $updateFields[
'UF_GRATITUDE'] =
false;
671 if (isset($params[
'UF_BLOG_POST_VOTE']))
674 !empty($params[
'UF_BLOG_POST_VOTE'])
675 && !empty($params[
'UF_BLOG_POST_VOTE_' . $params[
'UF_BLOG_POST_VOTE'] .
'_DATA'])
678 $updateFields[
'UF_BLOG_POST_VOTE'] = $params[
'UF_BLOG_POST_VOTE'];
679 $GLOBALS[
'UF_BLOG_POST_VOTE_' . $params[
'UF_BLOG_POST_VOTE'] .
'_DATA'] = $params[
'UF_BLOG_POST_VOTE_' . $params[
'UF_BLOG_POST_VOTE'] .
'_DATA'];
680 $updateFields[
'HAS_PROPS'] =
'Y';
684 $updateFields[
'UF_BLOG_POST_VOTE'] =
false;
688 if (isset($params[
'BACKGROUND_CODE']))
690 $updateFields[
'BACKGROUND_CODE'] = (!empty($params[
'BACKGROUND_CODE']) ? $params[
'BACKGROUND_CODE'] :
false);
694 isset($params[
'PARSE_PREVIEW'])
695 && $params[
'PARSE_PREVIEW'] ===
'Y'
696 && !empty($updateFields[
'DETAIL_TEXT'])
700 $updateFields[
'UF_BLOG_POST_URL_PRV'] = $urlPreviewValue;
701 $updateFields[
'HAS_PROPS'] =
'Y';
704 if ($result = \CBlogPost::update($postId, $updateFields))
707 Option::get(
'disk',
'successfully_converted',
false)
708 && Loader::includeModule(
'disk')
709 && ($storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($postFields[
'AUTHOR_ID']))
710 && ($folder = $storage->getFolderForUploadedFiles())
715 $needToDelete =
false;
719 !empty($params[
'FILES'])
720 || !empty($params[
'UF_BLOG_POST_FILE'])
725 $postUF = $USER_FIELD_MANAGER->getUserFields(
'BLOG_POST', $postId, LANGUAGE_ID);
727 !empty($postUF[
'UF_BLOG_POST_FILE'])
728 && !empty($postUF[
'UF_BLOG_POST_FILE'][
'VALUE'])
731 $filesList = array_merge($filesList, $postUF[
'UF_BLOG_POST_FILE'][
'VALUE']);
734 if (!empty($params[
'FILES']))
736 foreach ($params[
'FILES'] as $key => $fileData)
740 && in_array($key, $filesList)
743 foreach ($filesList as $i => $v)
747 unset($filesList[$i]);
748 $needToDelete =
true;
754 $fileFields = \CRestUtil::saveFile($fileData);
756 if (is_array($fileFields))
758 $file = $folder->uploadFile(
761 'NAME' => $fileFields[
'name'],
762 'CREATED_BY' => $postFields[
'AUTHOR_ID']
770 $filesList[] = FileUserType::NEW_FILE_PREFIX . $file->getId();
777 isset($params[
'UF_BLOG_POST_FILE'])
778 && is_array($params[
'UF_BLOG_POST_FILE'])
782 count($params[
'UF_BLOG_POST_FILE']) === 1
783 && $params[
'UF_BLOG_POST_FILE'][0] ===
'empty'
787 $needToDelete =
true;
791 $filesList = array_unique(array_merge($filesList, array_map(
static function($value) {
793 preg_match(
'/^' . FileUserType::NEW_FILE_PREFIX .
'(\d+)$/i', $value)
797 }, $params[
'UF_BLOG_POST_FILE'])));
802 !empty($params[
'UF_BLOG_POST_FILE'])
806 $filesList = array_unique(array_merge($filesList, array_map(
static function($value) {
808 preg_match(
'/^' . FileUserType::NEW_FILE_PREFIX .
'(\d+)$/i', $value)
812 }, $params[
'UF_BLOG_POST_FILE'])));
820 \CBlogPost::update($postId, [
822 'UF_BLOG_POST_FILE' => $filesList
832 'TYPE' =>
'post_general',
836 'TYPE' =>
'posts_popular',
840 $updateFields[
'AUTHOR_ID'] = $postFields[
'AUTHOR_ID'];
842 if ($postFields[
'PUBLISH_STATUS'] === BLOG_PUBLISH_STATUS_PUBLISH)
844 if ($updateFields[
'PUBLISH_STATUS'] === BLOG_PUBLISH_STATUS_DRAFT)
846 \CBlogPost::deleteLog($postId);
848 elseif ($updateFields[
'PUBLISH_STATUS'] === BLOG_PUBLISH_STATUS_PUBLISH)
850 \CBlogPost::updateLog($postId, $updateFields, $blog, [
851 'allowVideo' => Option::get(
'blog',
'allow_video',
'Y'),
852 'PATH_TO_SMILE' =>
false
858 isset($params[
'IMPORTANT'])
859 && $params[
'IMPORTANT'] ===
'Y'
862 \CBlogUserOptions::setOption($result,
'BLOG_POST_IMPRTNT',
'Y', $currentUserId);
864 if (defined(
'BX_COMP_MANAGED_CACHE'))
866 $CACHE_MANAGER->clearByTag(
'blogpost_important_all');
960 global $USER, $APPLICATION;
962 if (!Loader::includeModule(
'blog'))
964 $APPLICATION->throwException(
Loc::getMessage(
'SOCIALNETWORK_ITEM_HELPER_BLOG_MODULE_NOT_INSTALLED'),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_ERROR');
969 isset($params[
'USER_ID'])
970 && (int)$params[
'USER_ID'] > 0
972 ? (int)$params[
'USER_ID']
973 : (int)$USER->getId()
976 $postId = (int)($params[
'POST_ID'] ?? 0);
979 $APPLICATION->throwException(
'Wrong post ID',
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_ERROR');
984 \CSocNetUser::isUserModuleAdmin($currentUserId, SITE_ID)
985 || \CMain::getGroupRight(
'blog') >=
'W'
988 return Permissions::FULL;
991 $postItem = Post::getById($postId);
992 $postFields = $postItem->getFields();
994 if ((
int)$postFields[
'AUTHOR_ID'] === $currentUserId)
996 $result = Permissions::FULL;
1000 $permsResult = $postItem->getSonetPerms([
1001 'CHECK_FULL_PERMS' =>
true
1003 $result = $permsResult[
'PERM'];
1005 $result <= Permissions::READ
1006 && $permsResult[
'READ_BY_OSG']
1009 $result = Permissions::READ;