- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/comments/task/commentposter.php
- Класс: BitrixTasksCommentsTaskCommentPoster
- Вызов: CommentPoster::prepareCrmElementChanges
private function prepareCrmElementChanges(array $values): array
{
$collection = [];
$oldElements = (explode(',', $values['FROM_VALUE']) ?: []);
$newElements = (explode(',', $values['TO_VALUE']) ?: []);
$uniqueElements = array_unique(array_merge($oldElements, $newElements));
sort($uniqueElements);
foreach ($uniqueElements as $element)
{
[$type, $id] = explode('_', $element);
$typeId = CCrmOwnerType::ResolveID(CCrmOwnerTypeAbbr::ResolveName($type));
$title = CCrmOwnerType::GetCaption($typeId, $id);
$url = CCrmOwnerType::GetEntityShowPath($typeId, $id);
if (!isset($collection[$type]))
{
$collection[$type] = [];
}
$title = ($title ?: $element);
if ($title)
{
$title = htmlspecialcharsbx($title);
$collection[$type][$element] = "{$title}";
}
}
$result = [];
$noValue = Loc::getMessage('COMMENT_POSTER_COMMENT_TASK_UPDATE_CHANGES_FIELD_VALUE_NO');
foreach ($collection as $type => $typeElements)
{
$old = array_intersect_key($typeElements, array_flip($oldElements));
$new = array_intersect_key($typeElements, array_flip($newElements));
if (!array_diff_key($old, $new) && !array_diff_key($new, $old))
{
continue;
}
$result[$type] = [
'OLD' => (empty($old) ? $noValue : implode(', ', $old)),
'NEW' => (empty($new) ? $noValue : implode(', ', $new)),
];
}
return $result;
}