Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
post.php
1
<?php
2
namespace
Bitrix\Socialnetwork\Ui\Preview
;
3
4
use
Bitrix\Im\User
;
5
use
Bitrix\Main\Loader
;
6
7
class
Post
8
{
14
public
static
function
buildPreview
(array $params)
15
{
16
global $APPLICATION;
17
if
(!Loader::includeModule(
'blog'
))
18
return
null
;
19
20
ob_start();
21
$APPLICATION->includeComponent(
22
'bitrix:socialnetwork.blog.post.preview'
,
23
''
,
24
$params
25
);
26
return
ob_get_clean();
27
}
28
34
public
static
function
getImAttach
(array $params)
35
{
36
if
(!Loader::includeModule(
'im'
))
37
return
false
;
38
39
if
(!Loader::includeModule(
'blog'
))
40
return
false
;
41
42
$cursor = \CBlogPost::getList(
43
array(),
44
array(
"ID"
=> $params[
"postId"
]),
45
false
,
46
false
,
47
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"
)
48
);
49
$post = $cursor->fetch();
50
if
(!$post)
51
return
false
;
52
53
// For some reason, blog stores specialchared text.
54
$post[
'DETAIL_TEXT'
] = htmlspecialcharsback($post[
'DETAIL_TEXT'
]);
55
if
($post[
'MICRO'
] ===
'Y'
)
56
$post[
'TITLE'
] =
null
;
57
58
$parser = new \blogTextParser();
59
$post[
'PREVIEW_TEXT'
] = TruncateText($parser->killAllTags($post[
"DETAIL_TEXT"
]), 200);
60
$user = User::getInstance($post[
'AUTHOR'
]);
61
62
$attach = new \CIMMessageParamAttach(1,
'#E30000'
);
63
$attach->addUser(array(
64
'NAME'
=> $user->getFullName(),
65
'AVATAR'
=> $user->getAvatar(),
66
));
67
68
if
($post[
'TITLE'
] !=
''
)
69
{
70
$attach->addMessage(
'[b]'
. $post[
'TITLE'
] .
'[/b]'
);
71
}
72
$attach->addMessage($post[
'PREVIEW_TEXT'
]);
73
74
return
$attach;
75
}
76
77
public
static
function
getImRich
(array $params)
78
{
79
if
(!Loader::includeModule(
'im'
))
80
{
81
return
false
;
82
}
83
84
if
(!Loader::includeModule(
'blog'
))
85
{
86
return
false
;
87
}
88
89
if
(!class_exists(
'\Bitrix\Im\V2\Entity\Url\RichData'
))
90
{
91
return
false
;
92
}
93
94
$cursor = \CBlogPost::getList(
95
[],
96
[
'ID'
=> $params[
'postId'
]],
97
false
,
98
false
,
99
[
'TITLE'
,
'MICRO'
,
'DETAIL_TEXT'
]
100
);
101
$post = $cursor->fetch();
102
if
(!$post)
103
{
104
return
false
;
105
}
106
107
// For some reason, blog stores specialchared text.
108
$post[
'DETAIL_TEXT'
] = htmlspecialcharsback($post[
'DETAIL_TEXT'
]);
109
if
($post[
'MICRO'
] ===
'Y'
)
110
{
111
$post[
'TITLE'
] =
null
;
112
}
113
114
$parser = new \blogTextParser();
115
$post[
'PREVIEW_TEXT'
] = TruncateText($parser->killAllTags($post[
'DETAIL_TEXT'
]), 200);
116
117
$rich = new \Bitrix\Im\V2\Entity\Url\RichData();
118
119
return
$rich
120
->setName($post[
'TITLE'
])
121
->setDescription($post[
'PREVIEW_TEXT'
])
122
->setType(\
Bitrix
\Im\V2\
Entity
\Url\RichData::POST_TYPE)
123
;
124
}
125
132
public
static
function
checkUserReadAccess
(array $params, $userId)
133
{
134
if
(!Loader::includeModule(
'blog'
))
135
return
false
;
136
137
$permissions = \CBlogPost::getSocNetPostPerms($params[
'postId'
],
true
, $userId);
138
return
($permissions >= BLOG_PERMS_READ);
139
}
140
141
}
Bitrix\Im\User
Definition
user.php:10
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Socialnetwork\Ui\Preview\Post
Definition
post.php:8
Bitrix\Socialnetwork\Ui\Preview\Post\checkUserReadAccess
static checkUserReadAccess(array $params, $userId)
Definition
post.php:132
Bitrix\Socialnetwork\Ui\Preview\Post\buildPreview
static buildPreview(array $params)
Definition
post.php:14
Bitrix\Socialnetwork\Ui\Preview\Post\getImRich
static getImRich(array $params)
Definition
post.php:77
Bitrix\Socialnetwork\Ui\Preview\Post\getImAttach
static getImAttach(array $params)
Definition
post.php:34
Bitrix\Socialnetwork\Ui\Preview
Definition
post.php:2
Bitrix
modules
socialnetwork
lib
ui
preview
post.php
Создано системой
1.10.0