protected function EventAdminVoteUser() { if (!$this->oUserCurrent or !$this->oUserCurrent->isAdministrator()) { return parent::EventVoteUser(); } if (!($oUser = $this->User_GetUserById(getRequest('idUser', null, 'post')))) { $this->Message_AddErrorSingle($this->Lang_Get('user_not_found'), $this->Lang_Get('error')); return; } $iValue = getRequest('value', null, 'post'); if ($this->oUserCurrent and $this->oUserCurrent->isAdministrator()) { // первичное голосование if (!($oUserVote = $this->Vote_GetVote($oUser->getId(), 'user', $this->oUserCurrent->getId()))) { $oUserVote = Engine::GetEntity('Vote'); $oUserVote->setTargetId($oUser->getId()); $oUserVote->setTargetType('user'); $oUserVote->setVoterId($this->oUserCurrent->getId()); $oUserVote->setDirection($iValue); $oUserVote->setDate(date('Y-m-d H:i:s')); $iVal = (double) $this->Rating_VoteUser($this->oUserCurrent, $oUser, $iValue); $oUserVote->setValue($iVal); $oUser->setCountVote($oUser->getCountVote() + 1); if ($this->Vote_AddVote($oUserVote) and $this->User_Update($oUser)) { $this->Message_AddNoticeSingle($this->Lang_Get('user_vote_ok'), $this->Lang_Get('attention')); $this->Viewer_AssignAjax('iRating', $oUser->getRating()); $this->Viewer_AssignAjax('iSkill', $oUser->getSkill()); $this->Viewer_AssignAjax('iCountVote', $oUser->getCountVote()); // * Добавляем событие в ленту $this->Stream_write($oUserVote->getVoterId(), 'vote_user', $oUser->getId()); } else { $this->Message_AddErrorSingle($this->Lang_Get('adm_vote_error'), $this->Lang_Get('error')); } } else { if (Config::Get('plugin.aceadminpanel.admin_many_votes')) { // * Повторное голосование админа $iNewValue = $oUserVote->getValue() + $iValue; $oUserVote->setDirection($iNewValue); $oUserVote->setDate(date('Y-m-d H:i:s')); $iVal = (double) $this->Rating_VoteUser($this->oUserCurrent, $oUser, $iValue); $oUserVote->setValue($oUserVote->getValue() + $iVal); $oUser->setCountVote($oUser->getCountVote() + 1); if ($this->Vote_UpdateVote($oUserVote) and $this->User_Update($oUser)) { $this->Message_AddNoticeSingle($this->Lang_Get('user_vote_ok'), $this->Lang_Get('attention')); $this->Viewer_AssignAjax('iRating', $oUser->getRating()); $this->Viewer_AssignAjax('iSkill', $oUser->getSkill()); $this->Viewer_AssignAjax('iCountVote', $oUser->getCountVote()); } else { $this->Message_AddErrorSingle($this->Lang_Get('adm_repeat_vote_error'), $this->Lang_Get('error')); } } else { $this->Message_AddErrorSingle($this->Lang_Get('user_vote_error_already'), $this->Lang_Get('attention')); } } } else { $this->Message_AddErrorSingle($this->Lang_Get('adm_action_for_admin_only'), $this->Lang_Get('attention')); } }