- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/tasknotifications.php
- Класс: CTaskNotifications
- Вызов: CTaskNotifications::addAnswer
static function addAnswer($taskId, $text)
{
if (self::useNewNotifications())
{
$task = BitrixTasksInternalsRegistryTaskRegistry::getInstance()->getObject((int)$taskId, true);
if (!$task)
{
return;
}
$controller = new BitrixTasksInternalsNotificationController();
$controller->onNotificationReply($task, $text);
$controller->push();
return;
}
$task = new CTaskItem($taskId, $GLOBALS['USER']->GetId());
$commentId = CTaskCommentItem::add($task, array(
'POST_MESSAGE' => $text
));
if (
$commentId > 0
&& BitrixMainLoader::includeModule('socialnetwork')
)
{
$res = BitrixSocialnetworkLogCommentTable::getList(array(
'filter' => array(
'EVENT_ID' => array('crm_activity_add_comment', 'tasks_comment'),
'SOURCE_ID' => $commentId
),
'select' => array('ID', 'LOG_ID')
));
if ($logCommentFields = $res->fetch())
{
$res = BitrixSocialnetworkLogTable::getList(array(
'filter' => array(
"=ID" => $logCommentFields['LOG_ID']
),
'select' => array("ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "SOURCE_ID")
));
if ($logEntry = $res->fetch())
{
$logCommentFields = BitrixSocialnetworkItemLogComment::getById($logCommentFields['ID'])->getFields();
$res = CSite::getByID(SITE_ID);
$site = $res->fetch();
$userPage = Option::get('socialnetwork', 'user_page', $site['DIR'] . 'company/personal/');
$userPath = $userPage.'user/'.$logEntry['USER_ID'].'/';
BitrixSocialnetworkComponentHelper::addLiveComment(
$logCommentFields,
$logEntry,
CSocNetLogTools::findLogCommentEventByLogEventID($logEntry["EVENT_ID"]),
array(
"ACTION" => 'ADD',
"SOURCE_ID" => $logCommentFields['SOURCE_ID'],
"TIME_FORMAT" => CSite::getTimeFormat(),
"PATH_TO_USER" => $userPath,
"NAME_TEMPLATE" => CSite::getNameFormat(null, SITE_ID),
"SHOW_LOGIN" => "N",
"AVATAR_SIZE" => 100,
"LANGUAGE_ID" => $site["LANGUAGE_ID"],
"SITE_ID" => SITE_ID,
"PULL" => "Y",
)
);
}
}
}
return $commentId;
}