- Модуль: vote
- Путь к файлу: ~/bitrix/modules/vote/classes/general/vote.php
- Класс: CAllVote
- Вызов: CAllVote::keepVoting
static function keepVoting()
{
global $USER;
/** @var $r BitrixMainHttpRequest */
$r = BitrixMainContext::getCurrent()->getRequest();
$request = array_merge($r->getQueryList()->toArray(), $r->getPostList()->toArray());
if ($request["AJAX_POST"] == "Y")
CUtil::decodeURIComponent($request);
$PUBLIC_VOTE_ID = intval($request["PUBLIC_VOTE_ID"]);
$errorCollection = new BitrixMainErrorCollection();
try
{
if (empty($request["vote"]) || $PUBLIC_VOTE_ID <= 0 || !check_bitrix_sessid())
throw new BitrixMainArgumentException(GetMessage("VOTE_NOT_FOUND"), "bad_params");
$vote = new BitrixVoteVote($PUBLIC_VOTE_ID);
if (CVote::UserGroupPermission($vote["CHANNEL_ID"]) < 2)
throw new BitrixMainAccessDeniedException();
$channel = $vote->getChannel();
if ($channel["USE_CAPTCHA"] == "Y" && !$USER->IsAuthorized())
{
include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/captcha.php");
$cpt = new CCaptcha();
if ((!empty($request["captcha_code"]) && !$cpt->CheckCodeCrypt($request["captcha_word"], $request["captcha_code"])) ||
empty($request["captcha_code"]) && !$cpt->CheckCode($request["captcha_word"], 0))
{
$GLOBALS["BAD_CAPTCHA"] = "Y";
throw new BitrixMainArgumentException(GetMessage("VOTE_BAD_CAPTCHA"), "captcha");
}
}
if (!$vote->voteFor($request))
$errorCollection->add($vote->getErrors());
else
$GLOBALS["VOTING_ID"] = $vote->getId();
}
catch (Exception $e)
{
$errorCollection->add(array(new BitrixMainError($e->getMessage(), $e->getCode())));
}
if ($errorCollection->isEmpty())
{
$GLOBALS["VOTING_OK"] = "Y";
return true;
}
global $APPLICATION, $VOTING_OK;
$VOTING_OK = "N";
$m = [];
for ($errorCollection->rewind(); $errorCollection->valid(); $errorCollection->next())
$m[] = $errorCollection->current()->getMessage();
$APPLICATION->ThrowException(implode("", $m), "CVote::KeepVoting");
return false;
}