예제 #1
0
 public function btnVote_Click($strFormId, $strControlId, $strParameter)
 {
     if (!QApplication::HasPermissionForThisLang('Can vote', $this->objContextInfo->Context->ProjectId)) {
         return false;
     }
     $objNarroSuggestionVote = NarroSuggestionVote::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroSuggestionVote()->ContextId, $this->objContextInfo->ContextId), QQ::Equal(QQN::NarroSuggestionVote()->SuggestionId, $strParameter), QQ::Equal(QQN::NarroSuggestionVote()->UserId, QApplication::GetUserId())));
     if (!$objNarroSuggestionVote) {
         $objNarroSuggestionVote = new NarroSuggestionVote();
         $objNarroSuggestionVote->SuggestionId = $strParameter;
         $objNarroSuggestionVote->ContextId = $this->objContextInfo->ContextId;
         $objNarroSuggestionVote->UserId = QApplication::GetUserId();
         $objNarroSuggestionVote->Created = QDateTime::Now();
     }
     if (strpos($strControlId, 'votdn') === 0) {
         $objNarroSuggestionVote->VoteValue = -1;
     } else {
         $objNarroSuggestionVote->VoteValue = 1;
     }
     $objNarroSuggestionVote->Modified = QDateTime::Now();
     $objNarroSuggestionVote->Save();
     $this->objContextInfo->Modified = QDateTime::Now();
     $this->objContextInfo->Save();
     if ($this->ParentControl->ParentControl->chkRefresh->Checked && $strControlId != $this->btnKeepUntranslated->ControlId) {
         $this->ParentControl->ParentControl->btnSearch_Click();
     }
     $this->lblText->Warning = t('Thank you for your vote. You can change it anytime by voting another suggestion.');
 }