User_IsAuthorization()) { if ($oTopic=$oEngine->Topic_GetTopicById($idTopic)) { if ($oTopic->getType()=='question') { //голосовал уже или нет $oUserCurrent=$oEngine->User_GetUserCurrent(); if (!($oTopicQuestionVote=$oEngine->Topic_GetTopicQuestionVote($oTopic->getId(),$oUserCurrent->getId()))) { $aAnswer=$oTopic->getQuestionAnswers(); if (isset($aAnswer[$idAnswer]) or $idAnswer==-1) { if ($idAnswer==-1) { $oTopic->setQuestionCountVoteAbstain($oTopic->getQuestionCountVoteAbstain()+1); } else { $oTopic->increaseQuestionAnswerVote($idAnswer); } $oTopic->setQuestionCountVote($oTopic->getQuestionCountVote()+1); $oTopicQuestionVote=new TopicEntity_TopicQuestionVote(); $oTopicQuestionVote->setTopicId($oTopic->getId()); $oTopicQuestionVote->setVoterId($oUserCurrent->getId()); $oTopicQuestionVote->setAnswer($idAnswer); if ($oEngine->Topic_AddTopicQuestionVote($oTopicQuestionVote) and $oEngine->Topic_updateTopic($oTopic)) { $bStateError=false; $sMsgTitle=$oEngine->Lang_Get('attention'); $sMsg=$oEngine->Lang_Get('topic_question_vote_ok'); $oEngine->Viewer_Assign('oTopic',$oTopic); $sTextResult=$oEngine->Viewer_Fetch("topic_question.tpl"); } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('topic_question_vote_already'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('system_error'); } } else { $sMsgTitle=$oEngine->Lang_Get('error'); $sMsg=$oEngine->Lang_Get('need_authorization'); } $GLOBALS['_RESULT'] = array( "bStateError" => $bStateError, "sText" => $sTextResult, "sMsgTitle" => $sMsgTitle, "sMsg" => $sMsg, ); ?>