- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/lib/ui/preview/post.php
- Класс: BitrixSocialnetworkUiPreviewPost
- Вызов: Post::getImAttach
static function getImAttach(array $params)
{
if (!Loader::includeModule('im'))
return false;
if (!Loader::includeModule('blog'))
return false;
$cursor = CBlogPost::getList(
array(),
array("ID" => $params["postId"]),
false,
false,
array("ID", "BLOG_ID", "PUBLISH_STATUS", "TITLE", "AUTHOR", "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")
);
$post = $cursor->fetch();
if(!$post)
return false;
// For some reason, blog stores specialchared text.
$post['DETAIL_TEXT'] = htmlspecialcharsback($post['DETAIL_TEXT']);
if ($post['MICRO'] === 'Y')
$post['TITLE'] = null;
$parser = new blogTextParser();
$post['PREVIEW_TEXT'] = TruncateText($parser->killAllTags($post["DETAIL_TEXT"]), 200);
$user = User::getInstance($post['AUTHOR']);
$attach = new CIMMessageParamAttach(1, '#E30000');
$attach->addUser(array(
'NAME' => $user->getFullName(),
'AVATAR' => $user->getAvatar(),
));
if($post['TITLE'] != '')
{
$attach->addMessage('[b]' . $post['TITLE'] . '[/b]');
}
$attach->addMessage($post['PREVIEW_TEXT']);
return $attach;
}