Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
comment.php
1<?php
2
4
9
10class 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 {
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}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())