- Модуль: vote
- Путь к файлу: ~/bitrix/modules/vote/lib/attachment/controller.php
- Класс: BitrixVoteAttachmentController
- Вызов: Controller::processActionGetMobileVoted
protected function processActionGetMobileVoted()
{
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"));
$result = self::getVoted(
array(
"voteId" => $attach->getVoteId(),
"answerId" => $answerId),
array(
"iNumPage" => 1,
"nPageSize" => 50,
"bShowAll" => true)
);
$items = array();
foreach ($result["items"] as $k => $res)
{
$url = CComponentEngine::MakePathFromTemplate(
"/mobile/users/?user_id=#user_id#",
array("UID" => $res["ID"], "user_id" => $res["ID"],
"USER_ID" => $res["ID"])
);
$items[] = array(
"ID" => $res["ID"],
"NAME" => CUser::FormatName($nameTemplate, $res, true, false),
"IMAGE" => $res["PHOTO_SRC"],
"TAGS" => $res["TAGS"],
"WORK_POSITION" => $res["WORK_POSITION"],
"WORK_DEPARTMENTS" => $res["WORK_DEPARTMENTS"],
"URL" => $url,
'PAGE' => [
'bx24ModernStyle' => true,
'url' => $url,
'useTitle' => true,
]
);
}
$result["items"] = $items;
$this->sendJsonSuccessResponse(array(
"action" => $this->getAction(),
"data" => array(
"voted" => $items
),
"names" => array(
"voted" => "Voted users"
)
));
}