Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
comment.php
1
<?php
2
namespace
Bitrix\Forum\Copy\Implement
;
3
4
use
Bitrix\Main\Copy\Container
;
5
use
Bitrix\Main\Copy\CopyImplementer
;
6
use
Bitrix\Main\Error
;
7
use
Bitrix\Main\Result
;
8
9
class
Comment
extends
CopyImplementer
10
{
11
const
COMMENT_COPY_ERROR
=
"COMMENT_COPY_ERROR"
;
12
13
protected
$ufEntityObject
=
"FORUM_MESSAGE"
;
14
protected
$ufDiskFileField
=
"UF_FORUM_MESSAGE_DOC"
;
15
21
public
function
add
(
Container
$container, array $fields)
22
{
23
$messageId = \CForumMessage::add($fields);
24
25
if
(!$messageId)
26
{
27
$this->result->addError(
new
Error
(
"Error creating a new comment"
, self::COMMENT_COPY_ERROR));
28
}
29
30
return
$messageId;
31
}
32
33
public
function
update
($commentId, array $fields)
34
{
35
return \CForumMessage::update($commentId, $fields);
36
}
37
45
public
function
getFields
(
Container
$container, $entityId)
46
{
47
$message = \CForumMessage::getByIDEx($entityId);
48
return
($message ? $message : []);
49
}
50
58
public
function
prepareFieldsToCopy
(
Container
$container, array $fields)
59
{
60
unset($fields[
"ID"
]);
61
62
if
($container->
getParentId
())
63
{
64
$fields[
"TOPIC_ID"
] = $container->
getParentId
();
65
}
66
67
$dictionary = $container->
getDictionary
();
68
69
if
(!empty($dictionary[
"XML_ID"
]))
70
{
71
$fields[
"XML_ID"
] = $dictionary[
"XML_ID"
];
72
}
73
74
return
$fields;
75
}
76
85
public
function
copyChildren
(
Container
$container, $entityId, $copiedEntityId)
86
{
87
$this->
copyUfFields
($entityId, $copiedEntityId, $this->ufEntityObject);
88
89
return
new
Result
();
90
}
91
99
public
function
updateAttachedIdsInText
(
int
$id, array $attachedIds, callable $auxiliaryCallback): void
100
{
101
list($field, $text) = $this->
getText
($id);
102
103
$detailText = call_user_func_array($auxiliaryCallback, [
104
$text,
105
$this->ufEntityObject,
106
$id,
107
$this->ufDiskFileField,
108
$attachedIds
109
]);
110
111
$this->
update
($id, [$field => $detailText]);
112
}
113
114
protected
function
getText
($commentId)
115
{
116
$queryObject = \CForumMessage::getlist([], [
117
"ID"
=> $commentId],
false
, 0, [
"SELECT"
=> [
"POST_MESSAGE"
]]);
118
119
if
($fields = $queryObject->fetch())
120
{
121
return
[
"POST_MESSAGE"
, $fields[
"POST_MESSAGE"
]];
122
}
123
else
124
{
125
return
[
"POST_MESSAGE"
,
""
];
126
}
127
}
128
}
Bitrix\Forum\Copy\Implement\Comment
Definition
comment.php:10
Bitrix\Forum\Copy\Implement\Comment\$ufEntityObject
$ufEntityObject
Definition
comment.php:13
Bitrix\Forum\Copy\Implement\Comment\getText
getText($commentId)
Definition
comment.php:114
Bitrix\Forum\Copy\Implement\Comment\$ufDiskFileField
$ufDiskFileField
Definition
comment.php:14
Bitrix\Forum\Copy\Implement\Comment\getFields
getFields(Container $container, $entityId)
Definition
comment.php:45
Bitrix\Forum\Copy\Implement\Comment\updateAttachedIdsInText
updateAttachedIdsInText(int $id, array $attachedIds, callable $auxiliaryCallback)
Definition
comment.php:99
Bitrix\Forum\Copy\Implement\Comment\COMMENT_COPY_ERROR
const COMMENT_COPY_ERROR
Definition
comment.php:11
Bitrix\Forum\Copy\Implement\Comment\add
add(Container $container, array $fields)
Definition
comment.php:21
Bitrix\Forum\Copy\Implement\Comment\update
update($commentId, array $fields)
Definition
comment.php:33
Bitrix\Forum\Copy\Implement\Comment\copyChildren
copyChildren(Container $container, $entityId, $copiedEntityId)
Definition
comment.php:85
Bitrix\Forum\Copy\Implement\Comment\prepareFieldsToCopy
prepareFieldsToCopy(Container $container, array $fields)
Definition
comment.php:58
Bitrix\Main\Copy\Container
Definition
container.php:12
Bitrix\Main\Copy\Container\getParentId
getParentId()
Definition
container.php:70
Bitrix\Main\Copy\Container\getDictionary
getDictionary()
Definition
container.php:89
Bitrix\Main\Copy\CopyImplementer
Definition
copyimplementer.php:11
Bitrix\Main\Copy\CopyImplementer\copyUfFields
copyUfFields(int $entityId, int $copiedEntityId, string $ufObject)
Definition
copyimplementer.php:67
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Forum\Copy\Implement
Definition
comment.php:2
modules
forum
lib
copy
implement
comment.php
Создано системой
1.10.0