- Модуль: vote
- Путь к файлу: ~/bitrix/modules/vote/lib/attachment/controller.php
- Класс: BitrixVoteAttachmentController
- Вызов: Controller::processActionGetVoted
protected function processActionGetVoted()
{
if (!$this->checkRequiredGetParams(array("answerId")))
return;
$answerId = intval($this->request->getQuery("answerId"));
if ($answerId <= 0)
throw new ArgumentNullException("Answer ID is required.");
$attach = $this->attach;
$userId = $this->getUser()->getId();
if (!$attach->canRead($userId))
throw new AccessDeniedException();
$belong = false;
foreach ($attach["QUESTIONS"] as $qID => $question)
{
if (array_key_exists($answerId, $question["ANSWERS"]))
{
$belong = true;
break;
}
}
if (!$belong)
throw new AccessDeniedException();
$nameTemplate = $this->request->getPost("nameTemplate") ?: CSite::getNameFormat(null, $this->request->getPost("SITE_ID"));
$iNumPage = $this->request->getPost("iNumPage");
$nPageSize = 50;
$items = array();
$result = self::getVoted(
array(
"voteId" => $attach->getVoteId(),
"answerId" => $answerId),
array(
"iNumPage" => $iNumPage,
"nPageSize" => $nPageSize,
"bShowAll" => false)
);
if ($result["hiddenItems"] > 0)
{
$items[] = array(
"ID" => "HIDDEN",
"COUNT" => $result["hiddenItems"],
"FULL_NAME" => Loc::getMessage("VOTE_HIDDEN_VOTES_COUNT", ["#COUNT#" => $result["hiddenItems"]]),
);
}
foreach ($result["items"] as $k => $res)
{
$items[] = array(
"ID" => $res["ID"],
"TYPE" => $res["TYPE"],
"PHOTO" => $res["PHOTO"],
"PHOTO_SRC" => $res["PHOTO_SRC"],
"FULL_NAME" => CUser::formatName($nameTemplate, $res),
);
}
$result["items"] = $items;
$result["pageSize"] = $nPageSize;
$result["iNumPage"] = $iNumPage;
$this->sendJsonSuccessResponse(array(
"action" => $this->getAction(),
"data" => $result
));
}