- Модуль: vote
- Путь к файлу: ~/bitrix/modules/vote/lib/attachment/controller.php
- Класс: BitrixVoteAttachmentController
- Вызов: Controller::processActionVote
protected function processActionVote()
{
if ($this->checkRequiredGetParams(array("attachId")))
{
if (!$this->attach->canRead($this->getUser()->getId()))
throw new AccessDeniedException();
$request = $this->request->getPostList()->toArray();
if ($this->isAjaxRequest())
CUtil::decodeURIComponent($request);
//TODO decide what should we do with captcha in attaches
if ($this->attach->voteFor($request))
{
if (BitrixMainLoader::includeModule("pull"))
{
$result = array();
foreach ($this->attach["QUESTIONS"] as $question)
{
$result[$question["ID"]] = array(
"ANSWERS" => array()
);
foreach ($question["ANSWERS"] as $answer)
{
$result[$question["ID"]]["ANSWERS"][$answer["ID"]] = array(
"PERCENT" => $answer["PERCENT"],
"USERS" => [],
"COUNTER" => $answer["COUNTER"]
);
}
}
CPullWatch::AddToStack("VOTE_".$this->attach["VOTE_ID"],
Array(
"module_id" => "vote",
"command" => "voting",
"params" => Array(
"VOTE_ID" => $this->attach["VOTE_ID"],
"AUTHOR_ID" => $this->getUser()->getId(),
"COUNTER" => $this->attach["COUNTER"],
"QUESTIONS" => $result
)
)
);
}
$this->sendJsonSuccessResponse(array(
"action" => $this->getAction(),
"data" => array(
"attach" => array(
"ID" => $this->attach["ID"],
"VOTE_ID" => $this->attach["VOTE_ID"],
"COUNTER" => $this->attach["COUNTER"],
"QUESTIONS" => $this->attach["QUESTIONS"]
)
)
));
}
elseif (($errors = $this->attach->getErrors()) && !empty($errors))
$this->errorCollection->add($errors);
else
throw new ArgumentException(GetMessage("V_ERROR_4501"));
}
}