Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
comment.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Controller\Livefeed
;
4
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Socialnetwork\Controller\Base
;
8
use
Bitrix\Socialnetwork\LogCommentTable
;
9
10
class
Comment
extends
Base
11
{
12
public
function
getSourceAction
(array $params = []): ?array
13
{
14
$postId = (int)($params[
'postId'
] ?? 0);
15
$commentId = (int)($params[
'commentId'
] ?? 0);
16
17
if
($commentId <= 0)
18
{
19
$this->
addError
(
new
Error
(
Loc::getMessage
(
'SONET_CONTROLLER_LIVEFEED_COMMENT_COMMENT_EMPTY'
),
'SONET_CONTROLLER_LIVEFEED_COMMENT_COMMENT_EMPTY'
));
20
return
null
;
21
}
22
23
if
($postId <= 0)
24
{
25
$res =
LogCommentTable::getList
([
26
'filter'
=> [
27
'=ID'
=> $commentId
28
],
29
'select'
=> [
'LOG_ID'
]
30
]);
31
if
($logComment = $res->fetch())
32
{
33
$postId = (int)$logComment[
'LOG_ID'
];
34
}
35
}
36
37
if
($postId <= 0)
38
{
39
$this->
addError
(
new
Error
(
Loc::getMessage
(
'SONET_CONTROLLER_LIVEFEED_COMMENT_POST_NOT_FOUND'
),
'SONET_CONTROLLER_LIVEFEED_COMMENT_POST_NOT_FOUND'
));
40
return
null
;
41
}
42
43
$commentData = \CSocNetLogComponent::getCommentByRequest($commentId, $postId,
'edit'
);
44
if
($commentData)
45
{
46
$result = [
47
'id'
=> (int)$commentData[
'ID'
],
48
'message'
=> str_replace(
"<br />"
,
"\n"
, $commentData[
'MESSAGE'
]),
49
'sourceId'
=> (
50
(int)$commentData[
'SOURCE_ID'
] > 0
51
? (
int
)$commentData[
'SOURCE_ID'
]
52
: (int)$commentData[
'ID'
]
53
),
54
'UF'
=> (
55
!empty($commentData[
'UF'
])
56
? $commentData[
'UF'
]
57
: []
58
)
59
];
60
}
61
else
62
{
63
$this->
addError
(
new
Error
(
Loc::getMessage
(
'SONET_CONTROLLER_LIVEFEED_COMMENT_COMMENT_NOT_FOUND'
),
'SONET_CONTROLLER_LIVEFEED_COMMENT_COMMENT_NOT_FOUND'
));
64
return
null
;
65
}
66
67
return
$result;
68
}
69
}
Bitrix\Main\Engine\ActionFilter\Base
Definition
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Definition
base.php:80
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Definition
datamanager.php:441
Bitrix\Socialnetwork\Controller\Livefeed\Comment
Definition
comment.php:11
Bitrix\Socialnetwork\Controller\Livefeed\Comment\getSourceAction
getSourceAction(array $params=[])
Definition
comment.php:12
Bitrix\Socialnetwork\LogCommentTable
Definition
logcomment.php:30
Bitrix\Socialnetwork\Controller\Livefeed
Definition
blogpost.php:3
modules
socialnetwork
lib
controller
livefeed
comment.php
Создано системой
1.10.0