- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_comments.php
- Класс: CAllSocNetLogComments
- Вызов: CAllSocNetLogComments::UpdateLogData
static function UpdateLogData($log_id, $bSetDate = true, $bSetDateByLastComment = false)
{
$dbResult = CSocNetLogComments::GetList(array(), array("LOG_ID" => $log_id), array());
$comments_count = $dbResult;
$res = LogTable::getList(array(
'filter' => array(
"ID" => $log_id
),
'select' => array("ID", "LOG_DATE")
));
while ($logFields = $res->fetch())
{
$arFields = array("COMMENTS_COUNT" => $comments_count);
if ($bSetDateByLastComment)
{
$resComments = LogCommentTable::getList(array(
'order' => array(
"LOG_DATE" => "DESC"
),
'filter' => array(
"LOG_ID" => $log_id
),
'select' => array("ID", "LOG_DATE")
));
$arFields["LOG_UPDATE"] = (
($commentFields = $resComments->fetch())
? $commentFields["LOG_DATE"]
: $logFields["LOG_DATE"]
);
}
elseif ($bSetDate)
{
$connection = BitrixMainApplication::getConnection();
$helper = $connection->getSqlHelper();
$arFields["LOG_UPDATE"] = new SqlExpression($helper->getCurrentDateTimeFunction());
}
LogTable::update($logFields["ID"], $arFields);
CSocNetLogFollow::DeleteByLogID($log_id, "Y", true); // not only delete but update to NULL for existing records
}
}